Skip to content

Commit

Permalink
json filters added to post
Browse files Browse the repository at this point in the history
refer to pull tonytomov#598
  • Loading branch information
kccarter76 committed May 13, 2014
1 parent 9f0b324 commit 71e7fff
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions js/grid.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,15 @@ $.jgrid.extend({
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
});
} else {
$.extend($t.p.postData,sdata);
var filters = '{"fields":[';
$.each(sdata,function(i,n){
var val = $.isArray(n) ? n.join('|') : n, value = $.trim(val.replace(/\\/g,'\\\\').replace(/\"/g,'\\"'));
if (value !== '') {
filters += '{"field":"' + i + '", "op": "' + sopt[i] + '", "value":"' + value + '"},';
}
});
filters = (sdata.length > 0 ? filters.slice(0,-1) : filters) + ']}';
$.extend($t.p.postData, sdata, { filters: filters } );
}
var saveurl;
if($t.p.searchurl) {
Expand Down Expand Up @@ -314,7 +322,15 @@ $.jgrid.extend({
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
});
} else {
$.extend($t.p.postData,sdata);
var filters = '{"fields":[';
$.each(sdata,function(i,n){
var val = $.isArray(n) ? n.join('|') : n, value = $.trim(val.replace(/\\/g,'\\\\').replace(/\"/g,'\\"'));
if (value !== '') {
filters += '{"field":"' + i + '", "op": "' + sopt[i] + '", "value":"' + value + '"},';
}
});
filters = (sdata.length > 0 ? filters.slice(0,-1) : filters) + ']}';
$.extend($t.p.postData, sdata, { filters: filters } );
}
var saveurl;
if($t.p.searchurl) {
Expand Down

0 comments on commit 71e7fff

Please sign in to comment.