Jump to content


Photo

Tagging some rows for easy retrieval?


  • Please log in to reply
4 replies to this topic

#1 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 10 September 2009 - 03:41 PM

Hello

At this point, to tell if I need to paint a row differently because it's a table name, I loop through all the rows, check that the first (hidden) cell is painted green, and paint all the cells of the current row that way. I'd rather use something a bit smarter if possible.

A grid doesn't have the Tag property, so is there an alternative way to easily retrieve some rows by tagging them? I see the properties "Data" and "Level". What are they used for?

Here's what it looks like, and here's the code I use:

CODE
With NextGrid4 do begin
  CellsByName['sql',0] := 'table1';
  CellsByName['key',0] := 'Table 1';

  //"Table" row = 1, "column" row = 0
  //Row[0].Tag := 1
  //Row[0].Data
  //Row[0].Level
  Cell[ColumnByName['sql'].Index,0].Color := clMoneyGreen;

  CellsByName['sql',1] := 'article.id';
  CellsByName['key',1] := 'Article ID';
  CellsByName['value',1] := '123';

  for myrow := 0 to RowCount - 1 do begin
    //Poor man's way to check what type of row it is :-/
    if Cell[0,myrow].Color = clMoneyGreen then begin
      for mycol := 0 to Columns.Count - 1 do begin
        Cell[mycol,myrow].Color := clMoneyGreen;
      end;
    end;
  end;
end;


Thank you.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 11 September 2009 - 11:42 PM

Hello Frank,

Data property is a pointer type property. You may set it to nil if a row is "parent" and to parent row when row is "normal" smile.gif

I hope that you understand me smile.gif

You may also use a ObjectReference property of Cell too.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 12 September 2009 - 07:53 PM

QUOTE (Boki (Berg) @ Sep 12 2009, 12:42 AM) <{POST_SNAPBACK}>
Data property is a pointer type property. You may set it to nil if a row is "parent" and to parent row when row is "normal". You may also use a ObjectReference property of Cell too.


Thanks for the idea. Out of curiosity, what is the Level property for?

For those interested, here's some working code:

CODE
CellsByName['sql',0] := 'table1';
CellsByName['key',0] := 'Table 1';
CellsByName['value',0] := '(not editable)';
//If nil -> table row -> paint all cells green below
Row[0].Data := nil;

CellsByName['sql',1] := 'article.id';
CellsByName['key',1] := 'Article ID';
CellsByName['value',1] := '123';
//If not nil -> columns row -> leave color to white
Row[1].Data := GetParentComponent;

CellsByName['sql',2] := 'label';
CellsByName['key',2] := 'Label';
CellsByName['value',2] := 'My label';
Row[2].Data := GetParentComponent;

for myrow := 0 to RowCount - 1 do begin
  //Paint "table" rows green
  if not Assigned(Row[myrow].Data) then begin
    for mycol := 0 to Columns.Count - 1 do begin
      Cell[mycol,myrow].Color := clMoneyGreen;
    end;
  end;
end;


Thank you.

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 12 September 2009 - 10:31 PM

Hello,

Level property indicate level of row when TreeColumn is used.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 13 September 2009 - 04:39 PM

Thanks Boki.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users