首页 > 代码库 > 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???