javascript代码实例教程-Extjs store load json data,store fields mapping can't show data

发布时间:2019-02-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-Extjs store load json data,store fields mapping can't show data脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

Extjs ext4.2.2.1144

Store fields mapping : 'user.lastName' store.loadData()后数据显示不正确,编辑显示也不正确,用store.loadRawData()可以。
loadData through reader use loadRawData

  Ext.onReady(function() {  Ext.create('Ext.data.Store', {     storeid : 'emptyStore',     fields : [],     data : []    });   VAR grid = Ext.create('Ext.grid.Panel', {     tITle : 'usergrid',     tbar : [{      text : 'test',      handler : function(b, e) {        var store = Ext.create('Ext.data.Store', {          storeId : 'userStore',          fields : [{             name : 'user',             mapping : 'user.lastName'            }, {             name : 'address',             mapping : 'address.country'            }]         });       var columns = [{          text : 'user',          dataindex : 'user',          flex : 1,          editor : 'textfield'         }, {          text : 'address',          dataIndex : 'address',          editor : 'textfield',          renderer : function(value, metaData,            record, rowIndex, colIndex, store,            view) {           return value;          }         }];        grid.reconfigure(store, columns);       store.loadRawData([{          user : {           FirstName : 'wan',           lastName : 'donglei'          },          address : {           country : 'zhongguo',           city : 'nanjing'          }         }]);       }     }],     store : Ext.data.StoreManager.lookup('emptyStore'),     columns : [],     plugins : [Ext.create('Ext.grid.plugin.CellEditing', {        clicksToEdit : 1,        listeners : {         beforeedit : function(editor, e, eOpts) {          var record = e.record;          console.LOG(record.raw.address.city)          var value = e.value;          if ('-' == value) {           return false;          } else {           return true;          }         },         edit : function(editor, e, eOpts) {          var record = e.record;          console            .log(record.raw.address.city = 'shanghai')         }        }        })],     height : 200,     width : 300,     renderTo : Ext.getBody()    }); })  


参考:

https://docs.sencha.COM/extjs/4.0.7/#!/api/Ext.data.Store-method-loadRawData
https://www.sencha.com/forum/showthread.php?192809

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-Extjs store load json data,store fields mapping can't show data全部内容,希望文章能够帮你解决javascript代码实例教程-Extjs store load json data,store fields mapping can't show data所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。