IT Monkey:   Join the Cireson Community today for your chance to win $50!
We appreciate you taking the time to vote and add your suggestions to make our products awesome! Your request will be submitted to the community for review and inclusion into the backlog.

We recommend reviewing what is submitted before posting, in case your idea has already been submitted by another community member. If it has been submitted, vote for that existing feature request (by clicking the up arrow) to increase its opportunity of being added to Cireson solutions.

For more information around feature requests in the Cireson Community click here.

Alphabetise the Query Results field on the Portal

Tony_CollettTony_Collett Cireson Support Ninja IT Monkey ✭✭✭✭
When loading a Request Offering, every time every query result field is sorted entirely randomly. 

It would be great if this was sorted Alphabetical Order (A-Z) by default

It should sort from the left-most column. 

To add to this, I have created a simple javascript which sorts all Query Result fields (If it has 1 column, it sorts that column. If it has multiple columns, it sorts the right-most column). It's not perfect, but it's a good start point. 
$(function(){
      $(".k-link").click();
});


16 votes

Submitted · Last Updated

Comments

  • joivan_hedrickjoivan_hedrick Cireson Consultant Advanced IT Monkey ✭✭✭
    I've created something similar before which will sort query results by the first column. The following javascript should do what you are looking for. It's a bit longer than what you have, but it also works with query results that depend on previous answers to populate the dataset. 

    $(window).load(function () {
        if (document.URL.indexOf("/SC/ServiceCatalog/RequestOffering/") === -1) { //Only worry about request offering forms
            return; 
        }
        
        //Get all objects that hold our kendo grids.
        var divGridControls = $("div[data-control=checkboxGridByCriteria");
        for (var i = 0; i < divGridControls.length; i++) {
            
            //Re-get this element as an object.
            var thisKendoGrid = $(divGridControls[i]).getKendoGrid();
            var firstColumnName = thisKendoGrid.columns[0].field;
            //var firstColumnTitle = thisKendoGrid.columns[0].title;
            var numberOfRows = thisKendoGrid.dataSource.data().length
            if (numberOfRows > 0) 
            {
                //This grid control already has data. 
                //Sort this grid, using the first column. This will sort only once, after initial page load, whether items exist in the grid or not.
                thisKendoGrid.dataSource.query({
                  sort: { field: firstColumnName, dir: "asc" },
                  page: 1,
                  pageSize: 20,
                });
            }
            else{
                //If this request offering grid uses a previous question filter, then the initial sort won't work. Set up a one-time sort event. 
                thisKendoGrid.one("dataBound", function (e){
                    //Note to self. the dataBound fires after the rows are returned, and dataBinding fires before. 
                    var thisEventKendoGrid = e.sender;
                    console.log(e.sender);
                    
                    var firstEventColumnName = thisEventKendoGrid.columns[0].field;
                    var firstEventColumnTitle = thisEventKendoGrid.columns[0].title;
                    //console.log("Databinding changed in event. Sorting by first column '" + firstEventColumnName + "', '" + firstEventColumnTitle + "'");
                    thisEventKendoGrid.dataSource.query({
                      sort: { field: firstEventColumnName, dir: "asc" },
                      page: 1,
                      pageSize: 20,
                    });
                });
            }
        }
    });
  • AJ_WittenbrinkAJ_Wittenbrink Customer IT Monkey ✭
    This worked like a charm guys.  We have a series of dependent MP queries, that did filtering,  Cleaned it up nicely!
  • AJ_WittenbrinkAJ_Wittenbrink Customer IT Monkey ✭
    Since out update to V6, the solution by Joivan has not worked.  any suggestions?
  • AJ_WittenbrinkAJ_Wittenbrink Customer IT Monkey ✭
    ok I figured it out, change this line
        var divGridControls = $("div[data-control=checkboxGridByCriteria");
    
    to     
    var divGridControls = $("div[data-control=checkboxGridByCriteriaOld");
  • Morten_Aulie_PettersMorten_Aulie_Petters Premier Partner IT Monkey ✭
    Seems like both the scripts work, but only for the first Query Result box. I have a RO where I have 2 Query Result boxes on separate pages using the Layout function of the Advanced Request Offering, and the second box is not affected by the script.
  • S_TerryS_Terry Member Advanced IT Monkey ✭✭✭
    edited November 20
    Would be ideal if you could manage how these are sorted through the ARO.
Sign In or Register to comment.