Forum


08:34

05/10/2008

Using the following jqGrid initialization
$("#searchDetailsGrid").jqGrid({
caption: "Search Details Grid",
url: "../Controllers/GridController.aspx?type=ajax&operation=pop_Grid&term="
+ parameterContainer + "",
dataType: "json",
colNames: ['key', 'some_dt'],
colModel: [
{name:'key',index:'key', width:60, sorttype:"int"},
{name:'some_dt',index:'some_dt', width:60}
],
jsonReader:{
root: "Rows",
page: "Page",
total: "Total",
records: "Records",
repeatitems: false,
id: "0"
},
rowNum: 10,
rowList: [10,20,30],
viewrecords: true,
sortorder: "desc",
sortname:"key",
pager: $("#pagerDetails"),
imgpath: "../../Scripts/jQuery/jqGrid/themes/basic/images/"
}).navGrid("#pagerDetails",{edit:false,add:false,del:false});
Our current json serializer emits dates columns similar to "some_dt":new Date(1223140084550). It seems jqGrid can't process these columns. If I change the date to something like "some_dt":"2007-9-04" jqGrid runs fine. Am I missing some formatter declaration that would tell jqGrid how to process dates? I really need to keep the emitted dates as they are.
Thanks for your help
11:13

Moderators
30/10/2007

Hello,
If I understand right your JSON data looks like this
“some_dt”: '1223140084550'
and you expect that the grid will format it in some date format.
Remember jqGrid is more server oriented and task like this should be done server side in most cases.
jqGrid does not have cellrendering features. (It uses already formated)
This is not trivial task
1. We need to known the source format and
2. We need to set our desired format.
Instead of this you can format data your own way - just use afterInsertRow event and setCell method - something like this
afterInsertRow: function(rowid, cellrow) {
jQuery("#mygrid").setCell(rowid,'some_dt',myformater(cellrow.some_dt));
}
...
function myformater(src)
{
//perform here your formt
return new_formated_value
}
Also refer to example pages for ths
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
92 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66