Home General Discussion

Views

CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

Dear All,

I need some code which will sort the grid view descending order by the first column.

Do you have some code for this?

Kind Regards

Daniel

Answers

  • James_JohnsonJames_Johnson Customer Advanced IT Monkey ✭✭✭

    Hello,

    Here is an example of how you can get a Kendo grid and update the properties on it. Here I am sorting by the "Queue" column asc as well some other changes.

    $(document).ready(function (){
        var url = window.location.href;
        if(url.indexOf("/Page/9e5780c8-5e0a-4520-893f-b13f522d6241#/") > -1){ // Verify we are on the report page
                setTimeout(function() { // Grid is not ready when the document is ready, so this delay is necessary
                        var grid = $('[data-role=grid]') // Get the grid object
                        if(grid.length > 0){ // If the grid object is not found for whatever reason, we don't want the page load to fail
                            console.log("found grid")
                            if(grid.data('kendoGrid').dataSource._filter == null){
                            // If we are in here, that means the user never applied any kendo filtering elements. The code to change the pagination would then go here.
                                grid.data('kendoGrid').dataSource.group({field: "Queue"});
                                grid.data('kendoGrid').dataSource.sort({field: "Queue", dir: "asc"});
                                
                                grid.find(".k-grid-pager").insertBefore($(".k-grouping-header")); // Moves the pagination numbers up
                                grid.data('kendoGrid').dataSource.pageSize(100); // Sets the default page size to 200
                                console.log("settings applied")
                            }
                        }
                },2000);
        }
    });
    


  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    Dear James,

    I have a promoted view would this work for this? So the url would look for /view/.....

    Kind Regards

    Daniel

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    Its a promoted view in the incident section.

    Kind Regards

    Daniel

  • James_JohnsonJames_Johnson Customer Advanced IT Monkey ✭✭✭

    I haven't really worked with promoted views but as long as the URL has some kind of unique value in it such as the GUID then the detection part will work, just update the part in the quotes with what it might be. And if there is only one kendo grid on the page then the rest of it should work.

Sign In or Register to comment.