Sort Descending - Forum - Kendo UI Builder - Progress Community

Sort Descending

This question has suggested answer(s)

Does anyone know how to sort a grid Descending by default. I don't see any options in Kendo to do this, and I have tried adding code to the query in ABL, but I am not getting anywhere. Has anyone done this?

All Replies
  • Hello Curtis,

    There are few ways that you can go about for doing this.

    The reason why you do not see it when adding code to the query in the ABL is that the dataset/temp-table is always serialized using the primary key of the temp-table.

    One way to set a particular sort order then would be by changing the primary key of the temp-table (not the DB table).

    However, in general, you would want to use sort() method in the Kendo UI DataSource to sort the data.

    You would call the sort() method at a time when you want to sort the data. (Kendo UI Builder does not seem to have an option to set the initial sorting.)

    You can either use Client-Side Processing or Server-Side Processing for this. The difference is that when using Server-Side Processing, the sorting is done by the server and the data is returned sorted to the client. For this approach, you would use the JSON Filter Pattern to provide the support for server-side operations.

    If you are working with a relatively small number of records, then Client-Side Processing (the default) would be just fine and no additional set up is needed, just call the sort() method.

    The code using the sort() method, would look like the following (constructor in controller.public.js):

        constructor($scope, $injector, stateData) {
            super($scope, $injector);
            this.$model.options.autoBind = false;
            this.$ds[this.$primeDSName].sort({field: "Name", dir: "desc"});

    If you are using a custom view, the code would like the following:

            this.$components.grid0.options.autoBind = false;
            this.$ds.CustomerDS.sort({field: "Name", dir: "desc"});

    The usage of the autoBind property is to prevent a 2nd read from the server. (Since there is no data on the client, the sort() would cause a read on the server, then the grid would also read from the server when initializing. AutoBind tells the grid not to call read().)

    I hope this helps.

  • Thanks. I am only doing Server Side processing, so I would want "sorting is done by the server and the data is returned sorted to the client". I would even be ok hard coding it in the ABL Class, but I cannot figure out how to set the dynamic queries to sort Descending by default. Is there a way to do that using the dynamic queries?

  • You are welcome.

    For Server-Side Processing, you can use the code above with a Business Entity using JFP.

    (Related link: )

    An alternative to this approach, to do set the order right from the server, would be to change the primary index in the temp-table definition used by the Business Entity to be descending.

    Please let me know if you need more info.