Webix Datatable Server side filtering or sorting

Hi folks,

I am developing angular app with webix datatable, am able to populate the datatable with GET request using express js and mongodb. But how can I achieve the server side filtering or sorting with the same GET request, please share some idea.

Hey @Jay, with server-side filtering you’re basically forming a query to get the wanted entries, so you will have to form the request dynamically and parse the incoming result. For example, here is a sample with a text filter that will form queries upon the entered value and parse the end result (don’t forget to clear the datatable before you parse new data): https://snippet.webix.com/g4m1pfm9.

In this example I’m filtering the data by using the ?filter[your-column]=value. You can sort the data in the same exact way.

Although, this doesn’t seem like the best way to do this. You can also use server filters included in the datatable widget, basically it will form the queries on the fly without any hassle, for example: https://snippet.webix.com/dfcd73d8.

You can read more about datatable filtering/sorting and filtering/sorting in general here and here (including the server filter examples).

Hi Dzmitry,

First of all I thank you for your response, I am using MEAN stack, here is the code I wrote on the server side to get the filtered rows as below

detailsAllData.collection(‘details’).find(
{
fname: {
$regex: searchName,
$options: “i”
}},
function(err,allDetails) {
console.log(‘alldetails= ===>’, allDetails);
res.json(allDetails);
});

It is bascially mongodb query the ‘searchName’ is the value retrieved from the query string ?filter[your-column]=value, but for express js I used some middleware such as url and querystring to fetch the exact value.

Thanks a lot for your support :slight_smile:

-Jay