Forum Discussion

LM's avatar
LM
Data Storage
02-28-2023

Sorting Table

Hello,

I have created an "Aggregated Table" widget using this plugin.

Using this, sorting the table by only one column is supported.

Is it possible to sort the table based on 2 columns in descending order? Perhaps something can be done using widget script? 

Kindly share any possible solution.

2 Replies

Replies have been turned off for this discussion
  • Hi LM ,

    We can add one more column to the table for sorting.
    It can have different content:

    • you can concatenate the fields you need to sort  into one.
    • you can use the "Ordering" function.

    • create your own field for sorting.

    After that, you will need to sort the table by this field.
    We can add a script to hide that cutom column.
    And in order to prevent the user from accidentally sorting by other fields, we will hide sorting from headers.

     

    let colIndex = 0;
    
    widget.on("render", function(se,ev){
     se.style.tableState.columns[colIndex].visible = false;
     
    })
    
    
    widget.on('domready',function(){
     	$('.tw-sort-head ', element).css('display', 'none');
    })

     

    I hope this helps or points you in the right direction.

    Always here to help,
    Angelina from QBeeQ
    [email protected]

  • LM's avatar
    LM
    Data Storage

    Hi Angelina_QBeeQ,

    Thanks for the reply.

    I tried the different ways you suggested, they are not working as required for us.

    Can we sort the table based on two columns using widget script only without the need to add any hidden columns  ?

    Thanks,
    LM