Using getComboEdit as a column Editor does not allow you to type a text that is not in EditorItems. It leaves the cell blank.
To reproduce: take the VCL/DataGrid/Basic/Editing demo, and replace getComboBox by getComboEdit. It won’t allow you to type a text that is not in the list.
Shouldn’t it allow one to type a text that is not in Items list ? I thought this control was for that: offer a pre loaded list of options, but letting the user type whatever he wants, otherwise there’s no additional benefit using the edit box.
Hi,
There is code that automatically detects properties via RTTI, in comboedit it detects ItemIndex & Items, which are then linked and accepted. Since the Text property is not used, it ignores this. You can overcome this via the following event:
procedure TForm1.TMSFNCDataGrid1BeforeInplaceEditorGetValue(Sender: TObject;
ACell: TTMSFNCDataGridCellCoord; AInplaceEditor: TTMSFNCDataGridInplaceEditor;
var AValue: TTMSFNCDataGridCellValue; var AHandled: Boolean);
begin
AValue := GetObjectValue(AInplaceEditor, 'Text');
AHandled := True;
end;
except, we noticed a bug in the event handler, you will need to set AHandled to False instead of True, next version of TMS FNC UI Pack will address this.
Thanks !
BTW, “GetObjectValue” is an interesting (and usefull) disclosure! ![]()
Great idea, but with a very weird default property precedence order inside. ![]()
Agreed, it needs improvements. Thanks for the feedback ;-)
GetObjectValue(AInplaceEditor, 'Text');
didn’t work.
I had to use direct cast: ttmsfncdatagridcomboedit(ainplaceeditor).text;
And I also had to implement BeforeInplaceEditorSetText, otherwise the comboedit starts blank when activated.
procedure TFormMB.grdAMBeforeInplaceEditorSetValue(
Sender: TObject; ACell: TTMSFNCDataGridCellCoord;
AInplaceEditor: TWinControl; var AValue: TValue; var AHandled: Boolean);
begin
ttmsfncdatagridcomboedit(ainplaceeditor).text := AValue.AsString;
AHandled := True;
end;
BTW, is there a way to make the fncdatagridcomboedit close up when you press ENTER in the edit box? if you’re typing, pressing ENTER has no effect.
Hi,
We have applied some further improvements in both FMX & VCL, next version of TMS FNC UI Pack will address this. Pressing enter when typing works as expected here. I suggest to await the next version, remove the code you’ve been using as a workaround and see if the behavior is now what you expect it to be. Note that there is a bigger update coming up so it might take some time. In the mean time you can keep on using the workaround