1.columns列[一個單元格] 添加combobox下拉選項
$("#userGrid").datagrid({
singleSelect: true,
onClickCell: function (index, field, value) {
//Field = field;
// var rows = $('#' + UserGrid).datagrid('getRows'); //获得所有行
// var row = rows[index]; //根据index获得其中一行。
// WorkidValue = row.Workid;
debugger
if (client.endEditing()) { //endEditing:自定義方法
$('#' + UserGrid).datagrid('selectRow', index)
.datagrid('editCell', { index: index, field: field }); //editCell:自定義方法
editIndex = index; //editIndex:全局變量
}
},
columns: [[ {
field: 'Name',
title: '排班出勤',
80,
align: 'center',
editor: {type: 'combobox',options: {}}
sortable: true
//hidden:hidden
}]]
});
endEditing: function () {
if (editIndex == undefined) { return true }
if ($('#' + UserGrid).datagrid('validateRow', editIndex)) {
$('#' + UserGrid).datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
}
else {
return false;
}
},
//userGrid單行編輯點擊事件
$.extend($.fn.datagrid.methods, {
editCell: function (jq, param) {
return jq.each(function () {
var opts = $(this).datagrid('options');
var fields = $(this).datagrid('getColumnFields', true).concat($(this).datagrid('getColumnFields'));
for (var i = 0; i < fields.length; i++) {
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor1 = col.editor;
if (fields[i] != param.field) {
col.editor = null;
}
}
$(this).datagrid('beginEdit', param.index);
for (var i = 0; i < fields.length; i++) {
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor = col.editor1;
}
});
}
});