jqGrid Search with dynamic date formats based on user locale
Im using jqgrid for the first time and everything has worked like a charm till now. Thanks to the developer community.
I have to enable search for the grid and I did, search works for the data type except for date. I have tried hours and my code in a mess but no luck with this one. Kindly help me with your input and let me know what is it that Im missing.
The input to the grid is an array of objects from salesforce through which I construct the colmodel. The grids date display format is in sync(dynamic) with the salesforce user locale. The column model for Production_Start_Date__clooks like this for a particular user.
{name:'Production_Start_Date__c',
editable:false,
index:'Production_Start_Date__c',
align:'center', width:'121',classes:'dtCls',
sorttype: 'int',
formatter:'date',
searchoptions: {sopt: ['eq'],
dataInit : function (elem){
j$(elem).datepicker({ changeYear: true,changeMonth: true, showButtonPanel: true}); }},
formatter: function (cellval, opts) {
if(cellval == undefined){return "";}
else{ var date1= new Date(parseInt(cellval)).toLocaleDateString("en-IN");
return (new Date(parseInt(cellval))).toLocaleDateString("en-IN");}}},
I did try a quiet a few format options with srcformat and newformat but with no breakthrough. Can someone please help me resolve this.
One significant observation is I see that the search dialog searches for formats like “1436140800000” but not the one that are displayed in the grid like “03/16/2015”. I wish I could attach screenshots.
I had same problem before and solved it at the server side . I think the best solution is to prepare data completely and pass it to jqGrid. So jqGrid does not need to do process in your data. Also, detecting the user's locale is more easy on the server. So, It's better to do any conversion, before passing data to jqGrid.
链接地址: http://www.djcxy.com/p/25960.html