Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add params to personalize ajax requests #1311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions dev/jquery.jtable.paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
pageSizes: [10, 25, 50, 100, 250, 500],
pageSizeChangeArea: true,
gotoPageArea: 'combobox', //possible values: 'textbox', 'combobox', 'none'
pageSizeParam: 'jtPageSize',
startIndexParam: 'jtStartIndex',

messages: {
pagingInfo: 'Showing {0}-{1} of {2}',
Expand Down Expand Up @@ -326,8 +328,8 @@
var jtParams = base._createJtParamsForLoading.apply(this, arguments);

if (this.options.paging) {
jtParams.jtStartIndex = (this._currentPageNo - 1) * this.options.pageSize;
jtParams.jtPageSize = this.options.pageSize;
jtParams[this.options.startIndexParam] = (this._currentPageNo - 1) * this.options.pageSize;
jtParams[this.options.pageSizeParam] = this.options.pageSize;
}

return jtParams;
Expand Down Expand Up @@ -388,7 +390,7 @@
* PRIVATE METHODS *
*************************************************************************/

/* Adds jtStartIndex and jtPageSize parameters to a URL as query string.
/* Adds startIndexParam and pageSizeParam parameters (old jtStartIndex and jtPageSize) to a URL as query string.
*************************************************************************/
_addPagingInfoToUrl: function (url, pageNumber) {
if (!this.options.paging) {
Expand All @@ -398,7 +400,7 @@
var jtStartIndex = (pageNumber - 1) * this.options.pageSize;
var jtPageSize = this.options.pageSize;

return (url + (url.indexOf('?') < 0 ? '?' : '&') + 'jtStartIndex=' + jtStartIndex + '&jtPageSize=' + jtPageSize);
return (url + (url.indexOf('?') < 0 ? '?' : '&') + this.options.startIndexParam + '=' + jtStartIndex + '&' + this.options.pageSizeParam + '=' + jtPageSize);
},

/* Creates and shows the page list.
Expand Down
11 changes: 6 additions & 5 deletions dev/jquery.jtable.sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
options: {
sorting: false,
multiSorting: false,
defaultSorting: ''
defaultSorting: '',
sortingParam: 'jtSorting'
},

/************************************************************************
Expand Down Expand Up @@ -165,7 +166,7 @@
this._reloadTable();
},

/* Adds jtSorting parameter to a URL as query string.
/* Adds sortingParam parameter (old jtSorting) to a URL as query string.
*************************************************************************/
_addSortingInfoToUrl: function (url) {
if (!this.options.sorting || this._lastSorting.length == 0) {
Expand All @@ -177,7 +178,7 @@
sorting.push(value.fieldName + ' ' + value.sortOrder);
});

return (url + (url.indexOf('?') < 0 ? '?' : '&') + 'jtSorting=' + sorting.join(","));
return (url + (url.indexOf('?') < 0 ? '?' : '&') + this.options.sortingParam + '=' + sorting.join(","));
},

/* Overrides _createJtParamsForLoading method to add sorging parameters to jtParams object.
Expand All @@ -191,12 +192,12 @@
sorting.push(value.fieldName + ' ' + value.sortOrder);
});

jtParams.jtSorting = sorting.join(",");
jtParams[this.options.sortingParam] = sorting.join(",");
}

return jtParams;
}

});

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