|
|
@@ -137,6 +137,7 @@
|
|
|
data: [],
|
|
|
method: 'get',
|
|
|
url: undefined,
|
|
|
+ ajax: undefined,
|
|
|
cache: true,
|
|
|
contentType: 'application/json',
|
|
|
dataType: 'json',
|
|
|
@@ -348,7 +349,9 @@
|
|
|
this.initToolbar();
|
|
|
this.initPagination();
|
|
|
this.initBody();
|
|
|
- this.initServer();
|
|
|
+ if (this.options.sidePagination === 'server') {
|
|
|
+ this.initServer();
|
|
|
+ }
|
|
|
this.initKeyEvents();
|
|
|
};
|
|
|
|
|
|
@@ -1463,10 +1466,11 @@
|
|
|
searchText: this.searchText,
|
|
|
sortName: this.options.sortName,
|
|
|
sortOrder: this.options.sortOrder
|
|
|
- };
|
|
|
+ },
|
|
|
+ request;
|
|
|
|
|
|
- if (!this.options.url) {
|
|
|
- return;
|
|
|
+ if (!this.options.url && !this.options.ajax) {
|
|
|
+ throw new Error("Using Server requires either a `url` or a custom `ajax` method");
|
|
|
}
|
|
|
|
|
|
if (this.options.queryParamsType === 'limit') {
|
|
|
@@ -1499,8 +1503,7 @@
|
|
|
if (!silent) {
|
|
|
this.$loading.show();
|
|
|
}
|
|
|
-
|
|
|
- $.ajax($.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
|
|
|
+ request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
|
|
|
type: this.options.method,
|
|
|
url: this.options.url,
|
|
|
data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
|
|
|
@@ -1522,7 +1525,13 @@
|
|
|
that.$loading.hide();
|
|
|
}
|
|
|
}
|
|
|
- }));
|
|
|
+ });
|
|
|
+
|
|
|
+ if (this.options.ajax) {
|
|
|
+ calculateObjectValue(this, this.options.ajax, [request], null);
|
|
|
+ } else {
|
|
|
+ $.ajax(request);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.initKeyEvents = function () {
|
|
|
@@ -2162,7 +2171,7 @@
|
|
|
|
|
|
if (typeof option === 'string') {
|
|
|
if ($.inArray(option, allowedMethods) < 0) {
|
|
|
- throw "Unknown method: " + option;
|
|
|
+ throw new Error("Unknown method: " + option);
|
|
|
}
|
|
|
|
|
|
if (!data) {
|