是否有任何方法来禁用“idProperty”的Extjs模型? [英] Is there any way to disable "idProperty" of Model in Extjs?

查看:168
本文介绍了是否有任何方法来禁用“idProperty”的Extjs模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的模型/代理。当我创建一个通过REST发送到服务器的模型对象时,ExtJ将生成Id并将其值放在我的id字段中,这与我的数据冲突。
有没有办法阻止这种行为或解决这个问题?

我已经读过 idProperty Sencha Docs ,但是我无法解决我的问题。请帮助。

解决方案

我遇到同样的问题,并使用ajokn答案我做到了这一点。

  Ext.define('ThemeApp.model.peopleModel',{
extends:'Ext.data.Model' ,

fields:[{name:'id',type:'int',persist:false},
{name:'xyz',type:'auto'}]

我没有设置idProperty:'login',因为它的默认值是'id ',所以只需在你的模型中为id属性设置persist:false。


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 with my data. Is there any way to stop this behavior or to solve this issue?
I have read idProperty Sencha Docs but I am not able to solve my issue. Kindly Help.

解决方案

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.

这篇关于是否有任何方法来禁用“idProperty”的Extjs模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆