Forum
November 2nd, 2014
A
A
A
The forums are currently locked and only available for read only access
Topic RSS
requestComplete : json pre process
08/09/2008
16:46
16:46
caseman
New Member
Members
Forum Posts: 1
Member Since:
08/09/2008
08/09/2008
Offline
I would like to pre-process the json (responseText) from the server before loading the grid. I have completed the work and created a patch:
Basically, I created a function call responseComplete, and (in code) mimic'd loadComplete in set up. I then called responseComplete with the responseText from the server
Index: grid.base.js =================================================================== --- grid.base.js (revision 3438) +++ grid.base.js (working copy) @@ -56,6 +56,7 @@ onRightClickRow: null, onPaging: null, onSelectAll: null, + responseComplete: null, loadComplete: null, loadError: null, loadBeforeSend: null, @@ -499,11 +500,12 @@ var ts = this; $("").insertBefore(this); $(this).attr({cellSpacing:"0",cellPadding:"0"}); - var onSelectRow = this.p.onSelectRow, ondblClickRow = this.p.ondblClickRow, onSortCol=this.p.onSortCol, loadComplete = this.p.loadComplete, loadError = this.p.loadError, loadBeforeSend = this.p.loadBeforeSend; + var onSelectRow=this.p.onSelectRow, ondblClickRow=this.p.ondblClickRow, onSortCol=this.p.onSortCol, responseComplete=this.p.responseComplete, loadComplete=this.p.loadComplete, loadError=this.p.loadError, loadBeforeSend=this.p.loadBeforeSend; var onRightClickRow = this.p.onRightClickRow, afterInsRow = this.p.afterInsertRow; if(typeof onSelectRow !== 'function') {onSelectRow=false;} if(typeof ondblClickRow !== 'function') {ondblClickRow=false;} if(typeof onSortCol !== 'function') {onSortCol=false;} + if(typeof responseComplete !== 'function') {responseComplete=false;} if(typeof loadComplete !== 'function') {loadComplete=false;} if(typeof onRightClickRow !== 'function') {onRightClickRow=false;} if(typeof loadError !== 'function') {loadError=false;} @@ -693,7 +695,7 @@ switch(ts.p.datatype) { case "json": - $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"json",data: gdata, complete:function(JSON,st) { if(st=="success") {addJSONData(eval("("+JSON.responseText+")"),ts.grid.bDiv); if(loadComplete) {loadComplete();}}}, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); + $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"json",data: gdata, complete:function(JSON,st) { if(st=="success") {if(responseComplete){addJSONData(responseComplete(JSON.responseText),ts.grid.bDiv);}else{addJSONData(eval("("+JSON.responseText+")"),ts.grid.bDiv);} if(loadComplete) {loadComplete();} } }, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} break; case "xml":
Forum Timezone: Europe/Sofia
Most Users Ever Online: 715
Currently Online:
61 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