Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Sort on click only in specific row

Hi,

Is it possible to sort on click only in specific header row like in this example:

image

Comments

  • 5 Comments sorted by Votes Date Added
  • There is unfortunately no automatic way.  However if you implement sorting manually you can distinct which header row was clicked by handling the OnHeaderSectionCellClick event (where you have access to all properties of the clicked header cell). Example:

    procedure TfrmLMDElXTree_MHeader.ElXTreeMHeaderHeaderSectionCellClick(
      Sender: TElXCustomHeader; Section: TElXHeaderSection; Cell: TElXHeaderCell);
    begin
      Showmessage(IntToStr(Cell.RowIndex));
    ...


  • Is it possible to publish TCustomElXTree.OnHeaderSectionClick  sorting routine (as public method) that You using? I was looking in the source code and it's complicated (multisort etc.)

    Best regards,
    Grzegorz
    Best regards,
    Grzegorz
  • TCustomElXTree.OnHeaderSectionClick uses complex logic of preparing sorting sections and sort modes for them.
    However, this sorting routine itself is already public, it is procedure TElXTreeItem.Sort.

  • Yes I know but I need the all magic that the TCustomElXTree.OnHeaderSectionClick do before it's call  FItems.FRoot.Sort(true);
    My idea was to use this like that:

    void
    __fastcall
    TfoCalculationEngineTest::ElXTreeHeaderSectionCellClick(TElXCustomHeader
    *Sender, TElXHeaderSection *Section, TElXHeaderCell *Cell)
    {
        if(Cell->RowIndex == (Sender->RowCount-1))//only for last row
        {
            //I do something else (not sorting)
        }
        else
        if(Cell->RowIndex == (Sender->RowCount-2))
        {
            //I do sort trying to imitate sort click
           
            TElXTree* pTElXTree = dynamic_cast<TElXTree*>(Section->Owner->Owner);
            if(pTElXTree)
            {
                pTElXTree->OnHeaderSectionClick(Sender, Section);
            }
        }
    }
    Best regards,
    Grzegorz
Sign In or Register to comment.