I would like sort values in to the list of each field.
Is it possible to do this?
https://snippet.webix.com/9epwt405
Tanks
Ivan
I would like sort values in to the list of each field.
Is it possible to do this?
https://snippet.webix.com/9epwt405
Tanks
Ivan
You can override the “data” methods of Backend service, and place custom logic here which will sort, filter or alter the requested data in any necessary way
class MyData extends window.query.services.Backend {
data(name){
let options = super.data(name);
if (name == "age"){
return options.then(data => {
const order = [ ...data];
order.sort((a,b) => a.age < b.age ? 1 : -1);
return order;
});
}
return options;
}
}
Thank you maksim, but what I want is to have all the values sorted not only by Age but also by Country, City, Last Name, etc.
So I think sorting on data is not the right way.
I wonder if we can act on the query.ui object with some tricks.
this makes customization more simple
class MyData extends window.query.services.Backend {
data(name){
let options = super.data(name);
return options.then(data => {
const order = [ ...data];
order.sort((a,b) => a[name] < b[name] ? 1 : -1);
return order;
});
return options;
}
}
Hi maksim, this is perfect for me.
Tanks
Ivan