Hello,
to manipulate the URL of a datatable before loading, we have built our own proxy. Specifically, it is about a default sort order that we want to control via the configuration of the datatable.
Now when I use the Datatable’s pager, the data is loaded twice each time via the proxy.
We use the following URL to load the data:
"datatableProxy->/alphaflow-contract/contractservice/contracts?i18n=true&continue=true&count=" + $$(oConfig.sTableId).getVisibleCount();
The code of the proxy looks like this:
webix.proxy.datatableProxy = {
$proxy: true,
load: function (view, params) {
let url = this.source;
if (params) {
for (const [key, value] of Object.entries(params)) {
if (key !== "filter" && key !== "sort") {
url += "&" + key + "=" + value;
} else if (key === "filter") {
for (const [filterKey, filterValue] of Object.entries(value)) {
url += "&filter[" + filterKey + "]=" + (typeof filterValue === 'object' ? JSON.stringify(filterValue) : filterValue);
}
} else if (key === "sort" && Array.isArray(value)) {
value.forEach(sortValue => {
url += "&sort[" + sortValue.id + "]=" + sortValue.dir;
});
} else if (key === "sort" && typeof value === 'object') {
url += "&sort[" + value.id + "]=" + value.dir;
}
}
}
if (url.indexOf("sort") == -1 && view.config.defaultSort) {
$$(view.config.id).markSorting();
view.config.defaultSort.forEach(sortValue => {
url += "&sort[" + sortValue.id + "]=" + sortValue.dir;
$$(view.config.id).markSorting(sortValue.id, sortValue.dir, true);
});
}
return webix.ajax(url);
}
};
Does anyone have any idea why the proxy is being called twice? Is there possibly a better solution for the default sorting?
Thanks and best regards
Gorden