Jump to content

[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.
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')
    }
}
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,

Link to post
Share on other sites
  • 6 months later...
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

Link to post
Share on other sites
  • 1 year later...
On 7/5/2018 at 12:59 AM, Sherzod said:

Hi,

 

Can you try this?:

 

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



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

👍

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...