Jump to content

unidbgrid: get set sorting state of column


SebiDev123
 Share

Recommended Posts

Hi Marlon and Abaksoft,
Thats not what SebiDev123 is searching for. He ask for sorting a column by code as it would be when i click on the column header (So the column header shows the sorting direction with the small triangle). In the demo, the same problem occurs. If the form is opened, the grid shows no column as sorted, but in fact the data is sorted by the first column, so the first column header should shown as sorted. See the screenshots below.

 

Second is, it would be nice if we could detect which columns are sorted in which manner, write this per example in a cookie and if the user comes back opening the grid again, whe could sort the data and SHOW the Columns in the same manner as he leaved the grid before. Thas the point i think.

post-1520-0-19222100-1432624915_thumb.png

post-1520-0-45443400-1432625165_thumb.png

  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

I have a solution (works great for me) : 

function added(sender, container, pos, eOpts)
{ 
  sender.getStore().sorters.add(new Ext.util.Sorter({property: '1',direction: 'DESC'}));
}

Where '1' is SECOND column... 0: first column.....etc

Link to comment
Share on other sites

  • 1 year later...
  • 6 months later...

In my case it works if you add the following statement:

 

sender.view.refresh();

 

Then, the complete solution should be:

 

function added(sender, container, pos, eOpts)
{
sender.getStore().sorters.add(new Ext.util.Sorter({property: '1',direction: 'DESC'}));

sender.view.refresh();
}

Link to comment
Share on other sites

  • 5 years later...

Dear Sherzod, 
first of all, thank you very much for your quick reply.

  UniDBGrid1.ClientEvents.ExtEvents.SetText('reconfigure=function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)'+
          ' {    if (columns[3].isSortable()) { columns[3].sort('''+cSort+''')  }}');

In principle your solution works, but has some side effect to the "Locate" command I am using to select a specific row in the UniDBGrid.

procedure TuDashboardFrame.UniDBGrid1AfterLoad(Sender: TUniDBGrid);
var
  FD : TFDQuery;
  iTID : integer;
begin
  iTID := UniMainModule.TicketID;
  FD := TFDQuery(UniDBGrid1.Datasource.DataSet);
  if GetValueAsInteger(FD,'Ticket_Id') <> iTID then
  begin
    FD.Refresh;
    FD.Locate('Ticket_ID',iTID,[]);
  end;
end;

The "Locate" no longer works. Do you have another suggestion? Finally, I just want to get control over the sort indicator without having it also re-sort the contents of the assigned column.

Link to comment
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.

 Share

×
×
  • Create New...