首页 > 代码库 > 2016最后一贴,终于调通一个测试示例,并发现一个BUG???
2016最后一贴,终于调通一个测试示例,并发现一个BUG???
真的难点在于第一次调通。纠结五天,终于搞出界面。
也发现了一个书上代码,编辑用户时死活不通的情况,我将Links去了,改在data里,我X,,全OK了。。
原来的代码:
onAdd: function(button, e, options){ this.createDialog(null); }, onEdit: function(button, e, options){ var me = this, records = me.getRecordsSelected(); if(records[0]){ me.createDialog(records[0]); } }, createDialog: function(record){ var me = this, view = me.getView(); console.log(record); me.dialog = view.add({ xtype: ‘user-form‘, viewModel: { data: { title: record ? ‘Edit: ‘ + record.get(‘name‘) : ‘Add User‘ }, links: { currentUser: record || Ext.create(‘Packt.model.security.User‘) } } }); me.dialog.show(); }, getRecordsSelected: function(){ var grid = this.lookupReference(‘usersGrid‘); return grid.getSelection(); },
更改后的代码:
onAdd: function(button, e, options){ this.createDialog(null); }, createDialog: function(record){ var me = this, view = me.getView(); //#1 me.dialog = view.add({ xtype: ‘user-form‘, //#2 viewModel: { //#3 data: { title: record ? ‘Edit: ‘ + record.get(‘name‘) : ‘Add User‘, currentUser: record || { //#6 type: ‘User‘, //#7 create: true }//#4 } } }); me.dialog.show(); //#7 }, onEdit: function(button, e, options){ var me = this, records = me.getRecordsSelected(); //#1 if(records[0]){ //#2 me.createDialog(records[0]); //#3 } }, getRecordsSelected: function(){ var grid = this.lookupReference(‘usersGrid‘); //#4 return grid.getSelection(); //#5 },
2016最后一贴,终于调通一个测试示例,并发现一个BUG???
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。