Php jqgrid-使用带有动态colModel的数据选择器

Php jqgrid-使用带有动态colModel的数据选择器,php,ajax,jqgrid,Php,Ajax,Jqgrid,我有一个关于用jqgrid实现datepicker的问题。我认为这个问题太具体了。我想知道,有没有人能够用动态jqGrid实现日期选择器?colModel、colNames以及在我的例子中的数据都是通过ajax请求在服务器端生成的,然后在本地显示。在服务器上,我使用PHP创建了一个具有colModel结构的数组,然后在将其发送回客户端之前对其进行JSON编码。有效的JSON会在键周围加引号,但根据示例,而且(重要的是),我不应该这样做 我尝试使用regex删除引号,但这只会导致javascrip

我有一个关于用jqgrid实现datepicker的问题。我认为这个问题太具体了。我想知道,有没有人能够用动态jqGrid实现日期选择器?colModel、colNames以及在我的例子中的数据都是通过ajax请求在服务器端生成的,然后在本地显示。在服务器上,我使用PHP创建了一个具有colModel结构的数组,然后在将其发送回客户端之前对其进行JSON编码。有效的JSON会在键周围加引号,但根据示例,而且(重要的是),我不应该这样做

我尝试使用regex删除引号,但这只会导致javascript错误,因为它无法再解析现在无效的JSON

是否可以使用带有动态colModel的日期选择器

以下是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',
    });
   }
  });
});
还有一个示例模型:

{
 "editable":true,
 "name":"date",
 "index":"date",
 "sorttype":"date",
 "editrules":{"date":true},
 "editoptions":{"dataInit":"initDateEdit"}
}

看看答案。这应该能解决你的问题。

还是不走运。我正在使用
var functionsMapping={“initDateEdit”:函数(elem){setTimeout(函数(){$(elem).datepicker();},100);}
for(i=0;isetTimeout是毁了我的东西。