Jump to content


Photo

UniDBGrid MultiColumnSort


  • Please log in to reply
7 replies to this topic

#1 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 298 posts

Posted 14 January 2015 - 03:44 PM

Hello,

Have you got a sample with unidbgrid and an Implementation of MultiColumnSort ?

The Event OnMulticolumnsort return always one column

 

Other question :

Have you got a sample for having 3 state for sorting column when click on column title.

First click = asc

second click = desc

third click = none


  • 0

#2 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 10 October 2017 - 08:15 AM

Up


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.


#3 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 298 posts

Posted 10 October 2017 - 09:04 AM

clientevents->unievents :

function beforeInit(sender, config) 
{
    config.multiColumnSort = true;
}

 On grid :

procedure TMainForm.MainGridMultiColumnSort(Columns: TUniDBGridColumnArr;
  Directions: TUniSortDirections);
var
  I: Integer;
  IndxFldNames: string;
begin
  IndxFldNames := '';
  fIdxStr:= '';
  //read the multisort
  for I := High(Columns) downto 0 do
  begin
    case Directions[I] of
      True :
        begin
          IndxFldNames := IndxFldNames + Columns[I].FieldName + ':A;';
          fIdxStr := fIdxStr + Columns[I].Title.Caption +' Ascendant, ';
        end;
      False:
        begin
          IndxFldNames := IndxFldNames + Columns[I].FieldName + ':D;';
          fIdxStr := fIdxStr + Columns[I].Title.Caption +' Descendant, ';
        end;
    end;
  end;
  //apply sort to dataset
  unimainmodule.MainQuery.IndexFieldNames := IndxFldNames;
end;

  • 0

#4 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 10 October 2017 - 09:57 AM

I'm a bit confuse:

  • Why do you use fIdxStr for?
  • I was using this same method a few months ago in another project, without defining ClientDataSet1.IndexDefs and it was working fine.. but now when I pass IndxFldNames value to UniMainModule.ClientDataSet1.IndexFieldNames, I got a "EDatabaseError with message 'ClientDataSet1: Field 'City:A' not found". If I do not precise the ':A' or ':D' options, the error is not fired ..

Any idea ? What am I missing ?  :blink:  


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.


#5 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 298 posts

Posted 10 October 2017 - 10:32 AM

sorry , it's a copy of my code.

fIdxStr is a gloval var that i use for display the current sort in the status bar for inform user.

 

I'm using firedac and fdquery. See demo gridcolumnsort for apply a sort with cliendataset and adapt my code


  • 0

#6 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 10 October 2017 - 12:15 PM

My bad then, I thought that UniMainModule.ClientDataSet1.IndexName propertie works only for monoSorting .. I could have find a workaround by myself !  <_<

 

Anyhow, I just notice that we can sort only three column: is it possible to sort more than 3 columns ?

 

Thanks, mister DelaGoutte  ^_^


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.


#7 delagoutte

delagoutte

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 298 posts

Posted 10 October 2017 - 12:39 PM

doc in sencha

active multisort :

http://docs.sencha.c...multiColumnSort

 

set limit (default 3):

http://docs.sencha.c...-multiSortLimit

 

in unigui :

for limit at 10 

      aGrid.ClientEvents.ExtEvents.Values['store.load'] :=
      'function store.load(sender, records, successful, eOpts)'+#13#10+
      '{'+#13#10+
      '    sender.multiSortLimit=10;'+#13#10+
      '}';

  • 0

#8 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 10 October 2017 - 03:59 PM

Wicked, thank you delagoutte! (:


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users