Recent

Author Topic: Step by step to publish component on OPM  (Read 3130 times)

five

  • New Member
  • *
  • Posts: 13
Re: Step by step to publish component on OPM
« Reply #30 on: January 22, 2023, 02:48:55 am »

If possible, I'd suggest you to implement the same functionality for TZQuery component from Zeoslib, as this is widley used in many DB connections.


@giacomarko

I just added the automatic sorting functionalities for the TZQuery and TZTable dataset components : https://gitlab.com/lazaruscomponent/dbgridcontroller
but TZQuery, TZTable do not support Asc and Desc modifier... the default sorting icon are set to asc by default

Advise me if everything is ok.

giacomarko

  • New Member
  • *
  • Posts: 10
Re: Step by step to publish component on OPM
« Reply #31 on: January 22, 2023, 10:35:09 am »
Hi five,

tried right now using Zeoslib, same data table

sorting has some issue, when I click on title column (any) I got the column sorted Ascending, this is fine,
but when I click a second time do get Descending sort, nothing happen, to be honest I see few records (3 o 4) in the middle ot the table inverting their order but no more, and the arrow remain the same.

five

  • New Member
  • *
  • Posts: 13
Re: Step by step to publish component on OPM
« Reply #32 on: January 22, 2023, 03:20:16 pm »
tried right now using Zeoslib, same data table

sorting has some issue, when I click on title column (any) I got the column sorted Ascending, this is fine,
but when I click a second time do get Descending sort, nothing happen, to be honest I see few records (3 o 4) in the middle ot the table inverting their order but no more, and the arrow remain the same.

Of what I understand, the Zeoslib TZQuery is only supporting ascending sorting on columns, the work is done with the help of IndexFieldNames property. Also it didn't have the IndexDef property like the TSQLQuery so we are limited on this feature. Since I never worked with this component my knowledge is limited do you have an other way to sort on this dataset?, can you provide me an example? I can easily implement that.

Remember... the sorting is done by the dataset, not by the controller.

BTW you can always use the OnSortColumn event handle of the controller to process sorting on the db server side like the example I provided in this post.
« Last Edit: January 22, 2023, 03:40:23 pm by five »

five

  • New Member
  • *
  • Posts: 13
Re: Step by step to publish component on OPM
« Reply #33 on: January 22, 2023, 05:45:51 pm »

sorting has some issue, when I click on title column (any) I got the column sorted Ascending, this is fine,
but when I click a second time do get Descending sort, nothing happen, to be honest I see few records (3 o 4) in the middle ot the table inverting their order but no more, and the arrow remain the same.

I did some research and I found this https://zeoslib.sourceforge.io/viewtopic.php?t=384

So for TZQuery and TZtable I replaced IndexFieldNames by SortedFields for sorting ... @giacomarko can you give a try with the latest version: https://gitlab.com/lazaruscomponent/dbgridcontroller

giacomarko

  • New Member
  • *
  • Posts: 10
Re: Step by step to publish component on OPM
« Reply #34 on: January 22, 2023, 06:07:28 pm »
Hi,

I know ZQuery has IndexFieldNames as well as an internally implemented Sort functionality via two properties, don't know if this can be helpfull for you:
SortedFields where you can write several fields and get the query sorted, like -> Nation;City;Address
and
SortType that can be one of those parameters: TSortType = (stAscending, stDescending, stIgnored); 

usually, when I use ZQuery, I used to implement sorting catching OnTitleClick event out of DBGrid, this is easy

This is DBGrid without Controller: it works
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DBGrid2TitleClick(Column: TColumn);
  2. begin
  3.   if (ZQuery1.SortType=stAscending) then
  4.   begin
  5.     ZQuery1.SortedFields:=Column.Title.Caption;
  6.     ZQuery1.SortType:=stDescending;
  7.   end
  8.   else
  9.   begin
  10.     ZQuery1.SortedFields:=Column.Title.Caption;
  11.     ZQuery1.SortType:=stAscending;
  12.   end;
  13. end;
  14.  

this is on DBGrid with Controller: it doesn't work
Code: Pascal  [Select][+][-]
  1. procedure TForm1.dxDBGridController1SortColumn(Sender: TObject;
  2.   Column: TColumn; IndexFieldNames, AscFieldNames, DescFieldNames, IndexName,
  3.   SQLOrderBy: String);
  4. begin
  5.   if (ZQuery1.SortType=stAscending) then
  6.   begin
  7.     ZQuery1.SortedFields:=Column.Title.Caption;
  8.     ZQuery1.SortType:=stDescending;
  9.   end
  10.   else
  11.   begin
  12.     ZQuery1.SortedFields:=Column.Title.Caption;
  13.     ZQuery1.SortType:=stAscending;
  14.   end;
  15. end;
  16.  

(see picture)

giacomarko

  • New Member
  • *
  • Posts: 10
Re: Step by step to publish component on OPM
« Reply #35 on: January 22, 2023, 06:10:04 pm »
Ohhh !

we where writing to each other in same time  :D

let me try right now.

giacomarko

  • New Member
  • *
  • Posts: 10
Re: Step by step to publish component on OPM
« Reply #36 on: January 22, 2023, 06:26:38 pm »
Hi five,

PERFECT !!   :D :D

Tried sort, multiple sort, multiple sort having filter, remove filter... sort again

It works great !

thank & congrat for your job,

marco

 

TinyPortal © 2005-2018