Is there any way to disable “idProperty” of Model in Extjs?

后端 未结 3 1265
渐次进展
渐次进展 2021-01-23 16:53

I have a simple Model/proxy. When I create a object of model to send to server via REST, ExtJs is generating Id and putting its value in my \"id\" field and that is conflicting

相关标签:
3条回答
  • 2021-01-23 17:38

    I ran into same problem and using ajokn answer I did this.

    Ext.define('ThemeApp.model.peopleModel', {
        extend: 'Ext.data.Model',
    
        fields: [ 
            {name: 'id', type: 'int', persist: false},
            {name: 'xyz', type: 'auto'}
        ]
    }
    

    I didn't set the idProperty : 'login' cause its default value is 'id', so simply set persist: false for id property in your model.

    0 讨论(0)
  • 2021-01-23 17:40

    Set the idProperty to a non existing field. Its dirty I know, but this should do it.

    Ext.define('User', {
        extend: 'Ext.data.Model',
        idProperty : 'foo'
    });
    
    0 讨论(0)
  • 2021-01-23 17:47

    Set config options: persist: false.

    Ext.define('User', {
        extend: 'Ext.data.Model',
        idProperty : 'login'
        fields: [
            {name: 'login', type: 'string', persist: false},
            {name: 'username', type: 'string'},
            {name: 'password', type: 'string'}
        ]
    });
    
    0 讨论(0)
提交回复
热议问题