TTIWAdvWebGrid How to do buttons in only some rows

If I define a column as type ctButton they show up in all rows. Turns out I only want buttons in every third row. How do I do this? How would I, for example, set button objects to Enable := False and Visible := False, assuming this is one way to accomplish this?

Or, alternately, how do I define the column type otherwise and dynamically drop buttons in the cells I want them?

I've resolved my problem by changing the column to type ctNormal and setting MouseSelect to SingleCell, but I'd still like to know if you can use ctButton and disable the buttons in some rows.


Hi,


You can use the OnGetCellType event to specify the column type for a specific row, column or cell.

Example:
procedure TIWForm1.TIWAdvWebGrid1GetCellType(Sender: TObject; RowIndex,
  ColumnIndex: Integer; var AColumnType: TTIWColumnType;
  var Editor: TTIWColumnEditor; var DynEditor: TTIWDynEditType);
begin
  if (ColumnIndex = 1) and (RowIndex = 1) then
    AColumnType := ctButton;
end;

Thanks, Bart. This is what I was looking for. Will try it out.


This component is so rich with features it is sometimes hard to figure out just how and where to implement some things.

Bart, the description of this event says it is triggered by the rendering of each grid cell, yet in my app it doesn't get triggered until Row 24, too late for my purposes. How do I force the render for each row at least, if not each cell?


What forces render?
The rendering of the grid is done with every page refresh.
The event should be triggered for each cell for every visible row of the grid.
I'm not sure why this would only start from row 24 for you. Have you tried this in a simple test project?

As I suspected because Row 24 is, in fact, the end of the page. At that point it is too late. I need to set the "column type" for each cell as they are being created/filled. I guess I'll try resetting all the cells from Row 0 to n (in this case 24) from that one event and see if that works.

Resolved. I now see the event for each cell using the code below. Since the number of rows per "table entry" is not regular I find the rows by having first stored a text string in the cells I want to convert to ctButton. Thanks for the help.


procedure TfrmNewsFeed.PostGridGetCellType(Sender: TObject; RowIndex,
  ColumnIndex: Integer; var AColumnType: TTIWColumnType;
  var Editor: TTIWColumnEditor; var DynEditor: TTIWDynEditType);
var
  iCurRow: integer;
begin
  with PostGrid do begin
    if (ColumnIndex = 1) and (Cells[1, RowIndex] = 'Like')
    then AColumnType := ctButton;
    if (ColumnIndex = 2) and (Cells[2, RowIndex] = 'Reply')
    then AColumnType := ctButton;
  end;