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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM