TMS FNC Grid

I checked that in the TMSFNCGrid documentation there is an editor option for the etEditBtn column, but when adding a column to the grid this option does not appear, showing only etEdit.

Is there any way to have the column with an etEditBtn? I need to use this feature.

etEditBtn in fact is mentioned in the documentation, but there's no such value. Maybe it was planned, and not implemented, or just misdocumented, once VCL UI Pack Grid has an edEditBtn option.

By using etCustom, you should be able to use an TTMSFNCEditButton as an inplace editor, BUT, I could make it work only in a VCL apllication. In TMS Web Core, with exactly the same code, it raises some errors.

This is the related code:

procedure TForm2.TMSFNCGrid1CellEditGetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TWinControl; var CellString: string);
begin
  if ACol = 2 then
    TTMSFNCEditButton(CellEditor).Text := CellString;
end;

procedure TForm2.TMSFNCGrid1CellEditSetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TWinControl; var CellString: string);
begin
  if ACol = 2 then
    CellString := TTMSFNCEditButton(CellEditor).Text;
end;

procedure TForm2.TMSFNCGrid1GetCellEditorCustomClassType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorCustomClassType: TTMSFNCGridEditorClass);
begin
  if ACol = 2 then
    CellEditorCustomClassType := TTMSFNCEditButton;
end;

procedure TForm2.TMSFNCGrid1GetCellEditorProperties(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TWinControl);
begin
  if ACol = 2 then
    with TTMSFNCEditButton(CellEditor) do begin
      { here you set other properties as needed }
      OnButtonClick := MyButtonClick;
    end;
end;

procedure TForm2.TMSFNCGrid1GetCellEditorType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorType: TTMSFNCGridEditorType);
begin
  if ACol = 2 then
    CellEditorType := TTMSFNCGridEditorType.etCustom;
end;

It works perfectly in VCL. In WEB, it shows the inplace editor, but everytime I leave the cell I get errors like:

Uncaught TypeError: Cannot use 'in' operator to search for '4' in undefined | TypeError: Cannot use 'in' operator to search for '4' in undefined at Object.UpdateElementData (http://localhost:8000/Project2/Project2.js:30700:59) at Object.UpdateElementData (http://localhost:8000/Project2/Project2.js:74113:57) at Object.UpdateElement (http://localhost:8000/Project2/Project2.js:30561:14) at Object.CreateControl (http://localhost:8000/Project2/Project2.js:31359:16) at Object.CreateControl (http://localhost:8000/Project2/Project2.js:32768:35) at Object.InternalUpdateParent (http://localhost:8000/Project2/Project2.js:30755:14) at Object.UpdateParent (http://localhost:8000/Project2/Project2.js:30743:12) at Object.SetParent (http://localhost:8000/Project2/Project2.js:30858:14) at Object.HideEdit (http://localhost:8000/Project2/Project2.js:126109:35) at Object.HandleMouseMove (http://localhost:8000/Project2/Project2.js:124869:16)
at http://localhost:8000/Project2/Project2.js [30700:59]
1 Like

Perfect, it worked!