datasource override sort parameter name
1 Answer 3 Views
Craig
Top achievements
Rank 1
Iron
Craig asked on 16 Jun 2021, 01:19 AM | edited on 16 Jun 2021, 01:33 AM

Hi I have a remote server api that expects the sort params to be "sortBy" (name of field to sort), and "sort" (direction).

How can I change the kendo ui datasource transport read event to send these instead of the default "sort" object.

the below does not work, because Sort is getting overwritten by the underlying kendo code:


data: function (e) {
                        
                        if (e.sort) {
                            var r = { sortBy: e.sort[0].field, sort: e.sort[0].dir };
                            
                            console.log(r);
                            return r;
                        }
                        else return "";
                        
                    }

1 Answer, 1 is accepted

Sort by
0
Craig
Top achievements
Rank 1
Iron
answered on 16 Jun 2021, 01:56 AM

Nevermind, I forgot about parameterMap:


,
                parameterMap: function (e, type) {
                    if (e.sort[0]) {
                        
                        e.sortBy = e.sort[0].field;
                        e.sort = e.sort[0].dir;                      
                    }
                    console.log(e);
                    return e;
                }

Asked by
Craig
Top achievements
Rank 1
Iron
Answers by
Craig
Top achievements
Rank 1
Iron
Share this question
or