Forum


11:42

24/02/2009

i have a grid which has actions defined for the onPaging, onSelectRow and gridComplete events
When i use the jqGridExport function to export the grid to the server it seems to work OK, but when i run the JSON that it creates through JSONLint it says the JSON is invalid for these actions.
My jqGridExport command is:
var jsonGrid = jQuery("#tableReport").jqGridExport({exptype: "jsonstring", root: "tableReport"});
$.post("/SOA/Grid.soa", {grid: jsonGrid, report: "today"});
The code for my onSelectRow event is:
if(id && id!==lastRow){
$("#tableReport").saveRow(lastRow, false);
$("#tableReport").editRow(id,true);
lastRow=id;
}
}
The JSON created is:
"beforeSelectRow": null,
"onSelectRow": function (id) {
if (id && id !== lastRow) {
$("#tableReport").saveRow(lastRow,
false); $("#tableReport").editRow(id,
true); lastRow = id;
}
},
"onSortCol": null,
…….
The JSONLint message is: 'syntax error, unexpeted TINVALID at line nnn'
Just a thought, could it be because i am in Belgium? i know that in some applications i need to use semicolons as value delimiters in lists
i have resolved this by making my Server code strip out the event methods. Then in my jqGridImport call i re-add them.
16:43

29/03/2010

17:34

24/02/2009

No, i had to work arround it. when i save the grid i have to first edit it in the java service code to remove all events before saving it to the database.
The code i use to do that is as follows
public void saveGrid(String grid, String user, String report) {
System.out.println(">>>GridServiceImpl.saveGrid");
// strip out all grid events (e.g. onSelectRow, onPaging, gridComplete
int i = grid.indexOf("onSelectRow");
int j = grid.indexOf("onSortCol") - 1;
grid = grid.substring(0, i) + "onSelectRow\":null," + grid.substring(j) ;
i = grid.indexOf("onPaging");
j = grid.indexOf("onSelectAll") - 1;
grid = grid.substring(0, i) + "onPaging\":null," + grid.substring(j) ;
i = grid.indexOf("gridComplete");
j = grid.indexOf("loadError") - 1;
grid = grid.substring(0, i) + "gridComplete\":null," + grid.substring(j) ;
System.out.println(grid);
try {
Model.perform("saveGrid", new Object[] {user, report, grid });
} catch (Exception e) {
e.printStackTrace();
}
}
Then in my javascript i reload the events after the jqGridImport function
jQuery('#tableReport').jqGrid('setGridParam', { 'onPaging':function(btn){
$("#tableReport").appendPostData({refresh:false});
var vSelectedIds;
vSelectedIds = $("#tableReport").getGridParam('selarrrow');
$("#tableReport").appendPostData({ticked:vSelectedIds});
}});
hope that helps.
john
Most Users Ever Online: 715
Currently Online:
179 Guest(s)
Currently Browsing this Page:
1 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