2016最后一贴,终于调通一个测试示例,并发现一个BUG???

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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???的主要内容,如果未能解决你的问题,请参考以下文章

2016北京集训测试赛(十七)- 小结

AngularJS:工厂和服务? [复制]

java通过JNA调用动态库

java通过JNA调用动态库

利用java webservice调用天气预报实践

Retrofit 2.0 使用总结