TTMSFMXGrid

Hi,


I'm adding nodes to a grid to replace a VCL component (TIxObjectInspector).  It is similar to a value list editor that parses properties and streams component values directly without the need for assigmnent of each property.  While this doesn't exist for the TMSFMXGrid, the appearance can be duplicated and I'm adding nodes like this:

  WheelGrid.Cells[0, 0] := 'Property';
  WheelGrid.Cells[1, 0] := 'Value';
  WheelGrid.AddNode(1, 2);
  WheelGrid.Cells[0, 1] := 'Font Properties - General';
  WheelGrid.Cells[0, 2] := 'AutoSizeFont';
  WheelGrid.Cells[0, 3] := 'DegreeAsPortion';
  WheelGrid.AddNode(4, 4);
  WheelGrid.Cells[0, 4] := 'Font Sizes - General';
  WheelGrid.Cells[0, 5] := 'AscensionFontSize';
  WheelGrid.Cells[0, 6] := 'InfoFontSize';
 ...

The node is expanded and shows as (-), but when I collapse the nodes, they seem to exist in both positions (where it was in the nth row and higher up in the new row location).  It seems to me that the old node location should be moved, but how?  Do I have to keep track of each of the node locations, where they exist and their state and calculate whether each one is collapsed or expanded?  I see in the documentation that there is a RemoveNode() procedure, but keeping track of these can get very complicated and would require me to ascertain where the user clicked on the grid each time.  Is there a better way?

I suppose that I could calculate the total number of rows based upon whether a node is expanded or not and that would get rid of the former nodes lower down in the grid by setting WheelGrid.RowCount... ?

I solved the above problem on my own, but what I don't get is when you assign and object to a cell such as a combobox, how to access the value the user sets when you do this in code:


WheelGrid.AddComboBox(1, 2, cbTF.Items, False);  // TF = True/False

I've been looking through the demos and found this:


  TMSFMXGrid1.CellComboBox.Items.Add('Mercedes');
  TMSFMXGrid1.CellComboBox.Items.Add('Audi');
  TMSFMXGrid1.CellComboBox.Items.Add('Bugatti');
  TMSFMXGrid1.CellComboBox.Items.Add('Alfa Romeo');
  TMSFMXGrid1.CellComboBox.Items.Add('Jaguar');
  TMSFMXGrid1.CellComboBox.Items.Add('BMW');

and...

procedure TForm719.TMSFMXGrid1GetCellEditorType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
  case ACol of
    1: CellEditorType := etComboBox;
    3: CellEditorType := etTrackBar;
    4: CellEditorType := etDatePicker;
    5: CellEditorType := etArcDial;
    6: CellEditorType := etColorComboBox;
    7: CellEditorType := etCustom;
  end;
end;

Because it is an object inspector replacement that I'm building I'd be making use of several different input types and the etComboBox would have to have different items because one will take in line style such as DashDotDot, another will take a different set of enumerated types depending upon the row because each row has a separate Property = Value.  The problem I'm currently having is how to set the combobox items depending upon the current row and reading them back again from user selections.

Perhaps the answer is to write up the different enumerations as sets and depending upon the current row (there are over 60 needed) set the enumeration according to the appropriate property field.  I would prefer not to have to do this at run time though and set it up during design time statically.

Hi, 


There is currently no option to configure the content of an editor at designtime. This needs to be done at runtime, and can be done before the editor is displayed in the OnCellEditGetData

procedure TForm1.TMSFMXGrid1CellEditGetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
var
  cbo: TComboBox;
begin
  if (CellEditor is TComboBox) then
  begin
    cbo := (CellEditor as TComboBox);
    cbo.BeginUpdate;
    cbo.Items.Clear;
    //add items
    cbo.EndUpdate;
  end;
end;

Kind Regards, 
Pieter

Then reading the data selected by the user would be like this?


procedure TFormChartDesign.WheelGridCellEditGetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
begin
case ARow of
  1: AutoSizeFont :=  (CellEditor as TCombobox).ItemIndex;
          2: ColorStyle := (CellEditor as TCombobox).ItemIndex;
else...
end;

What triggers OnCellEditGetData?

Hi, 


Correct, the OnCellEditGetData is triggered when editing has finished (editor is set hidden). If you want to catch the value when the editor is still active you need to implement the OnCellComboCloseUp, which is triggered when the user has selected an item.

Kind Regards, 
Pieter

Thanks!


And when setting cell editor type is there a way to set a default value?

procedure TFormChartDesign.WheelGridGetCellEditorType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
  if (ACol = 1) then
  case ARow of
    6..9: CellEditorType := etSpinBox;
    11..13: CellEditorType := etSpinBox;
    15..19: CellEditorType := etSpinBox;
    22, 24, 25, 28, 32: CellEditorType := etSpinBox;
  end;
end;

Hi, 


You could link the value of the cell with the CellString parameter in the OnCellEditGetData. If the value is empty, or invalid, you could initialize the value of the editor with a default value. If the value is valid, you can initialize the value of the editor with a conversion of the string. for a combobox this would be the text value and the index of the cell string matches the predefined list of values. For a spinbox this could be a floattostr of the cellstring.

Kind Regards, 
Pieter
Writing this doesn't work because the TSpinBox class is not recognized.

procedure TFormChartDesign.WheelGridCellEditSetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
begin
  if ACol = 1 then
    case ARow of
      6: (CellEditor as TSpinBox).Value := InfoFontSize;
    end;
end;

OK. Thanks!

Because the unit FMX.SpinBox is not included in the uses list I suppose?

Ok.  Thanks!  That works too.