我知道由于引用,可以使用日期选择器进行单元格编辑here and here。但是,当我单击单元格时,没有显示日期选择器。下面是相关列的 colModel 条目。我有可用的日期选择器用户界面。
在其他示例中,dataInit 没有用引号引起来。它在我的代码中,因为整个 colModel 是由 PHP 在 AJAX 请求期间动态创建的。我将其构建为数组,然后对其进行 json_encode 以传递回 jqGrid。 PHP 的 json_encode 创建有效的 JSON,因此所有键都被引用为字符串。我必须删除引号才能使 jqGrid 正常工作吗?如果是这样,怎么办?
日期列的 colModel 条目:
{
"editable":true,
"name":"date",
"index":"date",
"sorttype":"date",
"editrules":{"date":true},
"editoptions":{
"dataInit":"function(elem){
setTimeout(function(){
$(elem).datepicker();
},100);
}"
}
}
下面是ajax请求的结构:
$(document).ready(function(){
$.ajax({
type: "GET",
datatype: "json",
success: function(result){
try{
//alert(result);
result = jQuery.parseJSON(result);
}catch(err){
alert("error in success json " + err);
return;
}
var colN = result.colNames;
var colM = result.colModelList;
var colD = result.colDataList;
grid.jqGrid({
datatype: 'local',
colNames:colN, //column names
colModel:colM, //column options
data:colD, //table data
editurl: 'clientArray',//changes are not sent to server
cellEdit: true,
cellsubmit: 'clientArray',
});
}
});
});
另外,我正在使用 jqGrid 4.0.0