全选
var ckAll=function () { if($('#ckAll').prop('checked')){ $("#example tr:gt(0)").each(function(){ $(this).find("input:checkbox").prop("checked",true); }); }else{ $("#example tr:gt(0)").each(function(i,n){ $(this).find("input:checkbox").attr("checked",false); }); } }
点击tr的任意地方使得checked选中
$("#example tr:gt(0)").on("click",function(){
if($(this).hasClass("selected")){
$(this).removeClass("selected").find("input:checkbox").attr("checked",false);
}else{
$(this).addClass("selected").find("input:checkbox").prop("checked",true);
}
});
将combobox框便成不可编辑
$("#sale_store_value").combobox({ disabled: true }).combobox('setValue', jsondata[3].trim());
combobox加checkbox多选
$("#JobNo").combobox({
width: 235,
multiple: true,
url: '../../SaleManage/SaleOut/GetEmployeeList',
valueField: 'JOB_NO',
textField: 'NAME',
formatter: function (row) { //formatter方法就是实现了在每个下拉选项前面增加checkbox框的方法
var opts = $(this).combobox('options');
return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField]
},
onSelect: function (row) { //选中一个选项时调用
var opts = $(this).combobox('options');
//获取选中的值的values
$("#JobNo").val($(this).combobox('getValues'));
//设置选中值所对应的复选框为选中状态
var el = opts.finder.getEl(this, row[opts.valueField]);
el.find('input.combobox-checkbox')._propAttr('checked', true);
},
onUnselect: function (row) {//不选中一个选项时调用
var opts = $(this).combobox('options');
//获取选中的值的values
$("#JobNo").val($(this).combobox('getValues'));
var el = opts.finder.getEl(this, row[opts.valueField]);
el.find('input.combobox-checkbox')._propAttr('checked', false);
}
});