implement jqgrid cell edit datepicker
I know that cell editing with datepicker is possible because of references here and here. However, when I click on the cell, no datepicker shows up. Below is the colModel entry for the column in question. I have datepicker UI available.
In the other examples, dataInit is not surrounded by quotes. It is in my code because the whole colModel is dynamically created by PHP during an AJAX request. I build it as an array, then json_encode it to be passed back to jqGrid. PHP's json_encode creates valid JSON, so all keys are quoted as strings. Must I remove the quotes in order for jqGrid to work properly? If so, how?
The colModel entry for a date column:
{
"editable":true,
"name":"date",
"index":"date",
"sorttype":"date",
"editrules":{"date":true},
"editoptions":{
"dataInit":"function(elem){
setTimeout(function(){
$(elem).datepicker();
},100);
}"
}
}
Here is the structure of the ajax request:
$(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',//cha开发者_Python百科nges are not sent to server
cellEdit: true,
cellsubmit: 'clientArray',
});
}
});
});
Also, I'm using jqGrid 4.0.0
I had the same problem with passing a function with PHP's json_encode, which is impossible but if you are using Zend Framework you could use Zend_Json_Expr('function ...') to use a function and then encode with Zend_Json::encode($var).
Still this won't solve the problem cause the event will not be fired if you insert it later thru AJAX.
You could have a look to Pike_Grid to see how it's done there.
精彩评论