Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread TGrid: Mix of bound and unbound mode
Thu, Jul 24 2014 7:44 AMPermanent Link

Uli Becker

For Android I had to replace the comboboxes in EWB by a combination of
edit and a grid.
The grid is bound to a dataset and contains several folder names in this
case.

Now I want an additional row "All folders" at the beginning of the list.
Is that possible?

I found:  Grid1.insertRow(0);

but I didn't find out how to change the value (if possible).

Another way I tried was to insert a row into the datase:

 dsBooks.first;
 dsBooks.Insert(false);
 dsBooks.Columns['Titel'].AsString := 'Alle Ordner';
 dsBooks.Save;

That works, but the new row is always appended at the end. How can I
insert a row at the top?

Thanks Uli


Thu, Jul 24 2014 12:55 PMPermanent Link

Walter Matte

Tactical Business Corporation

Uli:

Will SORT help?

//  dsBooks.Columns['Titel'].SortDirection :=sdNone;
//  dsBooks.Sort;

 dsBooks.Columns['Titel'].SortDirection:=sdAscending;
 dsBooks.Sort;


Walter
Thu, Jul 24 2014 1:12 PMPermanent Link

Uli Becker

Walter,

> Will SORT help?
>
> //  dsBooks.Columns['Titel'].SortDirection :=sdNone;
> //  dsBooks.Sort;
>
>    dsBooks.Columns['Titel'].SortDirection:=sdAscending;
>    dsBooks.Sort;

Unfortunately not, because the line which I want to insert, is not the
first in alphabetical order.

Thanks Uli
Thu, Jul 24 2014 6:33 PMPermanent Link

Jeff Cook

Aspect Systems Ltd

Avatar

Uli Becker wrote:

>

> That works, but the new row is always appended at the end. How can I
> insert a row at the top?

Hi Uli

I have done a similar thing in a DBISAM3 app and instead of using "ALL', I used '***ALL***' which sorts before alphanumeric characters ...

Cheers

Jeff
Thu, Jul 24 2014 7:34 PMPermanent Link

Leslie

Uli,

you can modify webdata.wbs to use your custom sort function.

  ...
  TRowChangedEvent = procedure (Sender: TObject; Column: TDataColumn) of object;
   
// NEW CODE
 TCompareRowsProc = procedure (Row1: TDataRow; Row2: TDataRow; Compared :Boolean; Result : Integer ) of object;

  TDataSet = class(TComponent)
  ...
     public
        // NEW CODE
        OnCompareRows: TCompareRowsProc;
...

function TDataRow.Compare(Value: TDataRow;
                         CaseInsensitive: Boolean=False): Integer;
var
  I: Integer;

 // NEW CODE
  Compared : Boolean = False;
begin
  // NEW CODE START
  if Assigned(FDataSet.OnCompareRows) then
    begin
       FDataSet.OnCompareRows(Self, Value, Compared , Result);
       if Compared then
          Exit;
    end;
  // NEW CODE END

  Result:=CMP_EQUAL;
  ...
end;

After this all you need is a custom compare function in your project  and assign it to dsBooks.OnCompareRows. Only the special cases ( when different sort is required)  need to be handled here. Set Compared to True if that was the case. Leave it false to go on with the normal compare.


Cheers,
Leslie
Fri, Jul 25 2014 6:55 AMPermanent Link

Uli Becker

Leslie,

thanks for that. If I don't find a simpler solution, I'll have a look.

Uli
Fri, Jul 25 2014 6:55 AMPermanent Link

Uli Becker

Jeff,

> I have done a similar thing in a DBISAM3 app and instead of using "ALL', I used '***ALL***' which sorts before alphanumeric characters ...

Thanks, yes, that's a possibility.

Uli
Image