Skip to content

Commit

Permalink
Send order_by and paging parameters via POST
Browse files Browse the repository at this point in the history
The default behavior of appending ?order_by=... to the url is inconsistent with
this.options.ajaxSettings.type when it is set to POST.

With this patch, a back-end service can be configured to ignore GET parameters
all together, which could be good in some cases.

fixes: #272
  • Loading branch information
tox2ik committed Mar 14, 2014
1 parent 3e69b2b commit e0368a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dev/jquery.jtable.paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,12 @@
var jtStartIndex = (pageNumber - 1) * this.options.pageSize;
var jtPageSize = this.options.pageSize;

if (this.options.ajaxSettings.type == 'POST') {
$.extend(this._lastPostData, {'jtStartIndex': jtStartIndex, 'jtPageSize': jtPageSize });
return url;
}
return (url + (url.indexOf('?') < 0 ? '?' : '&') + 'jtStartIndex=' + jtStartIndex + '&jtPageSize=' + jtPageSize);

},

/* Creates and shows the page list.
Expand Down
7 changes: 6 additions & 1 deletion dev/jquery.jtable.sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@
sorting.push(value.fieldName + ' ' + value.sortOrder);
});

if (this.options.ajaxSettings.type == 'POST') {
$.extend(this._lastPostData, {'jtSorting': sorting.join(',') });
return url;
}
return (url + (url.indexOf('?') < 0 ? '?' : '&') + 'jtSorting=' + sorting.join(","));

},

/* Overrides _createJtParamsForLoading method to add sorging parameters to jtParams object.
Expand All @@ -199,4 +204,4 @@

});

})(jQuery);
})(jQuery);

0 comments on commit e0368a4

Please sign in to comment.