Detect sorting in table


#1

Hello i’m using a Raw Data Table in a react application, i have some components tha are rendered based on a query using the Chartfactor querying data syntax, I need to detect when a table column is sorted and take that sorting configuration to apply it to the group with the same name as that column within the corresponding query, is that possible?


#2

Yes, you can use the sort-changed event in the Raw Data Table, let me show you an example:

let myChart = myData.graph("Raw Data Table")
    .limit(100)
    .on("sort-changed", data => console.log(data))
    .execute();

// this will print an object like this:
//{
//    "name": "sort-changed",
//    "chart": "visf7ea8336-aafa-487a-8c28-3a12166b4d49",
//    "data": [
//        {
//            "colId": "company",
//            "sort": "asc"
//        }
//    ]
//}

The colId property is the field name, so with that you can do your changes


#3

Man that looks great!, just what I need, thanks for your quick response.