zoukankan      html  css  js  c++  java
  • sencha touch change model data of store but load function not work

    In the process of my project development,I need to change data of model stored in store of  one list,in order to refresh the list without any unnesscary ajax request.But  after you changed the model in store,when your store load data again,the returned data can not bind to the store.It means that your store could not load new data from server,it show the modified data that you set manually.

    Follows is the source code:

     1  mergeData: function(rawData) {
     2         var me = this,
     3             fields = me.getFields().items,
     4             ln = fields.length,
     5             data = me.data,
     6             i, field, fieldName, value, convert;
     7 
     8         for (i = 0; i < ln; i++) {
     9             field = fields[i];
    10             fieldName = field.getName();
    11             convert = field.getConvert();
    12             value = rawData[fieldName];
    13 
    14             if (value !== undefined && !me.isModified(fieldName)) {//if field is modified,Sencha will do nothing and mantains the dirty data that you                                            //changed manually
    15                 if (convert) {
    16                     value = convert.call(field, value, me);
    17                 }
    18 
    19                 data[fieldName] = value;
    20             }
    21         }
    22 
    23         return this;
    24     },
        isModified : function(fieldName) {
            return this.modified.hasOwnProperty(fieldName);
        }

    Sencha use this method to judge fields if not modified. And now we want the changed fields be bind data from server,so we just set model.modified={} after you change your data.It works well;

  • 相关阅读:
    jquery 获取当前元素的索引值
    JQuery中根据属性或属性值获得元素(6种情况获取方法)
    jquery如何获取某一个兄弟节点
    JAVA学习<六>
    JAVA学习<四>
    JAVA学习<三>
    iOS定位到崩溃代码行数
    Swift3.0基础语法学习<五>
    Swift3.0基础语法学习<四>
    Swift3.0基础语法学习<三>
  • 原文地址:https://www.cnblogs.com/fengjian/p/2975051.html
Copyright © 2011-2022 走看看