Forum
12:57
10/08/2009
Hello Tony,
I have some small suggestion to improve in the code of grid.base.js in the call of $.ajax (see the lines 1687-1710).
1) Add the second parameter to the beforeSend callback and forward it to loadBeforeSend:
beginReq();
if ($.isFunction(ts.p.loadBeforeSend)) { ts.p.loadBeforeSend.call(ts, xhr, settings); }
}
It will simplify implementation of loadBeforeSend for example in case of setting custom authentication headers.
2) Include additional event beforeResponseProcessing which will be called directly at the begining of success callback:
if ($.isFunction(ts.p.beforeResponseProcessing)) {
ts.p.beforeResponseProcessing.call(ts, data, st, xhr);
}
if (dt === "xml") { addXmlData(data, ts.grid.bDiv, rcnt, npage > 1, adjust); }
...
The new event (callback) can gives more flexibility in the usage of jqGrid.
Just two examples where it can be usefull:
a) I have grids where many columns with chechboxes exist. Depend on data contain it can be very usefull to hide some columns where in full grid contain the chechboxes in the columns have false (uncheched). If allow to show only important information. I used userdata to send to jqGrid information which columns should be hidden. If one hide the columns before filling of the grid (in the new beforeResponseProcessing) the web browser can caclulate grid width abd the whole page layout more effectively. If I hide the columns one after the another inside of loadComplete the web browser have more work and grid work slowly.
b) Sometine one uses datatype as the function only to have simple way to make modification in the grid response (some decoding of data or creating an additional column based of other columns) before forwarding the data from the server to jqGrid. The introduction of new beforeResponseProcessing callback parameter will make the usage of datatype as the function unneeded in the case.
3) Include the code of success and error callbacks before
in the try {...} catch(ex) {} block. It will make hiding of loading div work allways even if some errors occuer. One can additionally include an alert or some other error message (till to calling user callback like loadError) in the catch block. Alternatively one can move endReq(); from both success and error callbacks in the additional complete callback. The small disadvantage of the way will be unblocking of grid (or hiding of loading div) at the beginning of filling of jqGrid and calling of loadComplete handler. This can change the behavier of the user GUI of jqGrid.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
35 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