Jump to content

How to change dbgrid editor on runtime


delagoutte

Recommended Posts

Hello,

i would like change the editor control of columns in runtime.

i do a simple test case :

i add a unicheckcombobox in the hidden panel

i add a radiogroup for switching the editor property for the column "city" between combobox and checkcombobox.

-> if you select combox -> the editor for column city must be a combobox

-> if you select Checkcombox -> the editor for column city must be a Checkcombobox but it is not work

 

is there anyone that could said me why it is not working and how can ido for do this change of control on runtime ?

image.png.622611e56e040fbdea7de1e486324883.png

GridEditors.zip

Link to comment
Share on other sites

18 hours ago, delagoutte said:

with this test case, change editor, and  change value -> js error

+ if value is london -> checkbox with london value,  is not checked

..

many problem

Hi,

Why are you creating editors dynamically every time?

Link to comment
Share on other sites

i want that the user could choice the type of control for each column.

the user could choice between combobox checkcombobox, checkbox, radiogroup, memo .......

i have 48 column for this grid, if i create them only on demand when it is necessary if think it is better than to have 48 combobox + 48 checkcombobox+48 checkbox+..... that are not realy used

 

and after i must do the same thing for the filter contol!!!!

Link to comment
Share on other sites

so, in my project i create all editor unicheckcombobox in designtime.

if in designtime ,i set the editor to the control unicheckcombobox there is not error message.

but

if i set the editor to a combobox in designtime and after i change the control to the unicheckcomboboxcontrol i have problem :

the value are not checked when the control display the dropdown list and when the value is set by the control i have this error message :

Quote

Uncaught TypeError: can't access property "attributes", m is null

 

for change the control at runtime i use your method

  cureditor := TUniFormControl(GetControlByName(UpperCase(aGrid.Columns[i].FieldName),aTypeControl));
  aGrid.Columns[i].Editor := cureditor ;
  aGrid.JSInterface.JSCall('setEditor', [TUniFormControl(cureditor).JSControl], aGrid.Columns[i].JSColumn);
  TUniFormControl(cureditor).JSInterface.JSAssign('valueField', ['val']);

have you got an idea to fix this ?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...