网站建设

jquery easyui datagrid 自定义checkbox

发表时间:2013-05-29 06:05:00 编辑:admin

最近蝉印网络在使用jquery easyui插件开发系统的时候需要对checkbox进行自定义,比如某行的checkbox不让选中,后来想不让选中的checkbox话还不如直接去掉这行的checkbox 。

于是查阅了一下datagrid的api,发现一个可用的函数:formatter
开始动手:

 

{
    field: 'ck1',
    checkbox: true,
    width: 100,
    align: 'center',
    formatter: function(value, rowData, rowIndex) {
        return rowData.disabled == 1 ? '': ''
    }
}

发现不管用,后来才知道checkbox列是系统保留的formatter不生效

于是干脆就自己写一个checkbox,
 

columns: [[
{
    field: 'ck',
    title: '',
    width: 30,
    align: 'center',
    formatter: function(value, rowData, rowIndex) {
        return rowData.disabled == 1 ? '': '';


    }
}]]
	//全选
	$("#check_all").click(function(){
		if($(this).attr('checked')=='checked'){
			$("input[name='user_list']").attr("checked",'checked');
		}else{
			$("input[name='user_list']").removeAttr("checked");
		}
	});