sencha gridpanel checkbox 复选框的勾选 以及和单机行冲突

gridpanel显示checkbox:

添加SelectionModel为Checkbox Selection Model

{

                    xtype: 'gridpanel',

                    id: 'Grid1',

                    header: false,

                    title: '条线列表',

                    deferRowRender: false,

                    forceFit: true,

                    store: 'NewTiaoXianStore',

                    columns: [

                        {

                            xtype: 'gridcolumn',                           

                            dataIndex: 'Id',

                            text: 'Id'

                        },

                        {

                            xtype: 'gridcolumn',

                            dataIndex: 'Name',

                            text: '条线名称'

                        },

                        {

                            xtype: 'gridcolumn',

                            dataIndex: 'Description',

                            text: '条线描述'

                        }

                    ],

                    selModel: Ext.create('Ext.selection.CheckboxModel', {

           checkOnly: true //防止单击行的时候,其他选中的checkbox被取消选中

                    })

                }

 

 

复选框的勾选

在load回调中根据字段checked值判断是否勾选

var store=Ext.getStore("Store");

store.proxy.extraParams={method:"GetList"};

store.load({

    callback:function(records, options, success){

        for(var i in records)

            {

                if(records[i].data.checked)

                    {                   

                        Ext.getCmp("Grid1").getSelectionModel().select(records[i],true); //勾选该记录

                    }

            }

}});

 

 

//grid根据行号(从0开始)选中

//第一个参数可以是行号或者records合集,第二个参数true表示保持之前勾选的(追加)

Ext.getCmp("Grid1").getSelectionModel().select(rowIndex,true); 

 

From:http://www.cnblogs.com/xuejianxiyang/p/5220397.html

posted @ 2016-02-26 14:44  Ace001  阅读(1979)  评论(1编辑  收藏  举报