Jump to content
uniGUI Discussion Forums
mterceno

[UniDBGrid] How to define a default column sort

Recommended Posts

Hi all,

 

I have looking for a long time a solution to define a default column sort but nothing.

Currently, when I activate the sort in a UniDBGrid, none column s sorted when the Dataset opens (no icon - arrow - in title). I must click on columns header to see this sort icon.

 

How can I to show this icon on the first column directly at first data load ?

 

 

 

At initialisation => no sort

post-4662-0-03088000-1530703486_thumb.png

 

When I click on title

post-4662-0-36453500-1530703487_thumb.png

 

PS: I have found this solution but I must call this code after all clients objects / data are rendered. This solution is not good.

DBGrid reloads the data and tries to sort it while the data is already sorted in that order => no look good !

 

UniSession.AddJS(UniDBGrid1.JSName+'.store.sorters.clear()');
UniSession.AddJS(UniDBGrid1.JSName+'.store.sorters.add(new Ext.util.Sorter({property: "0", direction: "ASC"}))');
 
Thank you for your help.

Share this post


Link to post
Share on other sites

Hi,

 

Can you try this?:

 

UniDBGrid -> ClientEvents -> ExtEvents ->...

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    if (columns[0].isSortable()) {
        columns[0].sort('ASC')
    }
}

Share this post


Link to post
Share on other sites

 

Hi,

 

Can you try this?:

 

UniDBGrid -> ClientEvents -> ExtEvents ->...

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    if (columns[0].isSortable()) {
        columns[0].sort('ASC')
    }
}

 

Hi it works !!!  :D

 

I have found also other solution with that :

 

UniDBGrid.ClientEvents.UniEvents:

function store.afterCreate(sender)
{
  sender.getSorters().add(new Ext.util.Sorter({property: "0", direction: "ASC"}));
  sender.sortOnLoad = true;
}

But your code is more pretty.

 

Thank you,

Share this post


Link to post
Share on other sites
On 7/5/2018 at 3:39 PM, mterceno said:

 

Hi it works !!!  :D

 

I have found also other solution with that :

 

UniDBGrid.ClientEvents.UniEvents:


function store.afterCreate(sender)
{
  sender.getSorters().add(new Ext.util.Sorter({property: "0", direction: "ASC"}));
  sender.sortOnLoad = true;
}

But your code is more pretty.

 

Thank you,

1482,google,give me an error:

columns[0].isSortable is not a function

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×