Ext Grid 多选

//显示策略下发情况的表格grid        
    var check_select = new Ext.grid.CheckboxSelectionModel();
    var cm = new Ext.grid.ColumnModel([    
        new Ext.grid.RowNumberer(),check_select,    
        {header:'ID',dataIndex:'id',width:50,sortable:true},
        {header:'名称',dataIndex:'name',width:100,sortable:true},
        {header:'所属部门',dataIndex:'parent_name',width:100,sortable:true},
        {header:'策略应用状态',dataIndex:'apply_status',width:100,sortable:true,renderer:function(value){
            if(value==0){
                return "<span><font color='red'>没有下发策略</font></span>";
            }else if(value==1){
                return "<span><font color='green'>策略已经下发</font></span>";
            }if(value==2){
                return "<span><font color='blue'>策略已经生效</font></span>";
            }
        }},
        {header:'策略起效时间',dataIndex:'complete_time',width:120,sortable:true},
        {header:'策略下发时间',dataIndex:'apply_time',width:120,sortable:true},
        {header:'角色',dataIndex:'role',width:150,sortable:true}
    ]);
    var person_ds = new Ext.data.Store({
        id:            'group_datasource',
        baseParams:    {deptid:'all'},
        proxy: new Ext.data.HttpProxy({url:'module/list_policy.php'}),
        reader: new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
        }, [
            {name: 'id'},
            {name: 'name'},
            {name: 'parent_name'},
            {name: 'apply_status'},
            {name: 'complete_time'},
            {name: 'apply_time'},
            {name: 'role'}
        ])
    });

    var person_grid = new Ext.grid.GridPanel({
        bodyStyle:'margin:0px;padding:0px;',
        width:300,
        autoScroll: true,
        //autoHeight:true,
        autoSizeColumns:true,
        ds: person_ds,
        cm: cm,
        sm: check_select,
        tbar:[
            {                    
                text:"刷新列表",
                tooltip:'刷新列表',
                iconCls:'x-tbar-loading',
                handler:function(){
                    person_ds.reload();
                }
            },{xtype:'tbseparator'},{
                text:"查看详情",
                id :    'show_detail_btn',
                tooltip:'查看详情',
                iconCls:'user',
                handler:function(){
                    var record = getSelectRecord();
                    if(record==false || record.indexOf(',')!=-1){
                        Ext.getCmp('show_detail_btn').setDisabled(true);
                    }else{
                        Ext.Msg.alert('提示信息','查看详情');
                    }
                }
            }
        ],
        bbar:new Ext.PagingToolbar({
            pageSize: 1000,
            store: person_ds,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
            emptyMsg: "没有记录"
        })
    });
   
    person_ds.load({params:{start:0,limit:1000}});    
    //选中表格的事件,控制按钮是否可用。
    person_grid.addListener('cellclick', cellclick);
    function cellclick(person_grid, rowIndex, columnIndex, e) {
        var record = getSelectRecord();
        if(record==false){
            Ext.getCmp('move-next').setDisabled(true);
        }else{
            Ext.getCmp('move-next').setDisabled(false);
        }
        if(record!=false && record.indexOf(',')==-1){
            Ext.getCmp('show_detail_btn').setDisabled(false);
        }else{
            Ext.getCmp('show_detail_btn').setDisabled(true);
        }
    }   

// 获取选定记录
    function getSelectRecord(){
        var records=person_grid.getSelectionModel().getSelections();
            if(records.join('')=='') {
                return false;
            }
            var ids = [];
            for(var i=0; i<records.length; i+=1){
                var member = records[i].get('id');  
                ids.push(member);                //向数组后添加元素
        }
        return ids.toString();
    }






baseParams:    {deptid:'all'},
person_ds.baseParams = {deptid:dept_id};
person_ds.load({params:{start:0,limit:10}});   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值