【发布时间】:2014-12-26 10:40:56
【问题描述】:
在我的 JQGrid 中,我有复选框列,下拉下拉菜单是通过 edittype: 'select' 创建的,复选框是通过“custom formatter”创建的,例如这个 edittype: 'checkbox',formatter: returnCheckBox,我想写我自己的“onChange”事件。
因此,因为我能够为复选框编写“onchange”事件并且它工作正常,但是当我单击复选框单元格中的其他位置(不在复选框上)并单击返回复选框时,它会停止触发“ onchange”事件。我认为行选择它会导致问题如何停止它。
这就是我正在做的事情
$("#theGrid").jqGrid({
datatype: 'local',
sortname: 'value1',
sortorder: 'desc',
cellsubmit: 'clientArray',
editurl: 'clientArray',
cellEdit: true,
colNames: ['SName', 'SType', 'DName', 'DType', 'Nullable'],
colModel: [
{ name: 'SName', index: 'SName', width: 100 },
{ name: 'SType', index: 'Type', width: 100 },
{
name: 'DName',
index: 'DName',
width: 100,
editable: true,
edittype: 'select',
editoptions: { value: "1:ID;2:Name" },
},
{
name: 'DType',
index: 'DType',
width: 100,
editable: true,
edittype: 'select',
editoptions: { value: "1:BigInt;2:VarChar(50)" }
},
{
name: 'Nullable',
index: 'Nullable',
width: 100,
editable: true,
edittype: 'checkbox',
//formatter: "checkbox",
formatter: checkedStateChange,
sortable: false,
formatoptions: {disabled : false},
}
]
});
var gridData = [
{ SName: 'ID', SType: 'BigInt', DName: 'ID', DType: 'BigInt' },
{ SName: 'Name', SType: 'VarChar(50)', DName: 'Name', DType: 'VarChar(50)' },
];
for (var i = 0; i < gridData.length; i++) {
$("#theGrid").jqGrid('addRowData', gridData[i].value0, gridData[i]);
}
function checkedStateChange(cellvalue, options, rowObject) {
return '<input type="checkbox" class="gridCheckBox"/>';
}
$('.gridCheckBox').on('change',function(){
alert('I am in checkBoxChange method');
});
【问题讨论】:
-
您继续忽略 cmets 到您之前的问题并继续发布不清楚的问题。您应该开始 "accept" 回答您的旧问题,并写下 your cmets 作为 cmets 对您的问题的回答。关于您当前的问题:您最好发布显示您所做工作的 JavaScript 代码,而不是仅描述您所做的工作。
-
@Oleg 我已经编辑了我的问题并添加了我的代码。希望现在你可以指导我。
标签: jqgrid