Hi team Bryntum,
I am trying to implement Server side sorting. Initially when the grid loads i had to show the indicator if the data sent rom the server is sorted by Particular property.So I have given sortAscending as true in column definition on server and performing on
const sortWay = data.columns.map((ele) => {
if (ele.hasOwnProperty("sortAscending")) {
return {
field: ele.field,
ascending: ele.sortAscending,
fn: (recordA, recordB) => {
return 1;
},
};
} else {
return {
fn: (recordA, recordB) => {
return 1;
},
};
}
});
sortAscending is the property sent from the server whose value is boolean.
this sortWay array i am assigning to sorters property of store and also i have given custom sorting function to show data as it has came from server and not do the sorting on client side.
Initially this function is gettong called while loading but as i am trying to sort on basis of any column it is not getting called and doing sorting on client side.
Also I tried giving sortParamName but still doing sorting on client side.
store: {
sorters: sortWay,
// sortParamName: "sort",
// syncDataOnLoad: false,
// autoLoad: false,
tree: true,
listeners: {
sort: async function (value) {
console.log("value sorters");
console.log(value.sorters);
const sortDirection =
value.sorters[0].ascending === true ? "asc" : "desc";
const sortField = value.sorters[0].field;
const rpt_sort_by = sortField + "/" + sortDirection;
const response = await authAxios.post(
"/rpt.SaveCustomization.do?_src=report",
{
rpt_sort_by,
p_rpt_id: id,
}
);
doRefresh(new Date().getTime());
//server call
},
},
},
Above is the store we are using in config.
Can you please guide me that how should i write sorters so that my custom function gets called whenever I do sorting or how should I do to achieve the same?