jahlxx Posted February 2, 2017 Share Posted February 2, 2017 Hi. Is possible to change grid column editor in run-time? Thanks. Quote Link to comment Share on other sites More sharing options...
jahlxx Posted February 3, 2017 Author Share Posted February 3, 2017 any idea? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 3, 2017 Share Posted February 3, 2017 Hi, Sorry, can you clarify your question again, do you want to change the editor or to assign? Because, one editor can not be assigned to multiple columns Best regards. Quote Link to comment Share on other sites More sharing options...
jahlxx Posted February 3, 2017 Author Share Posted February 3, 2017 assign one editor in run time Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 4, 2017 Share Posted February 4, 2017 Hi, Can you try this?: procedure TMainForm.UniBitBtn1Click(Sender: TObject); begin // ColumnsIndex=1 // Editor=UniEdit1 UniDBGrid1.JSInterface.JSCall('getColumns()[1].setEditor', [UniEdit1.JSControl]); end; Best regards. Quote Link to comment Share on other sites More sharing options...
jahlxx Posted February 5, 2017 Author Share Posted February 5, 2017 well. could work. But I don't know when assign the editor. I think the correct way is to assign just before enter in roweditor, but I don't know how to catch that event of the grid. How can I do? THanks. Quote Link to comment Share on other sites More sharing options...
ttamturk Posted April 10, 2017 Share Posted April 10, 2017 Hi, Maybe this will help you to do; procedure BaseGridAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var colIndex : Integer; begin inherited; if EventName = 'select' then begin colIndex := BaseGrid.ColumnByName('FieldValue').Index; case TFieldType of ftDateTime : begin UniSession.AddJS(BaseGrid.JSName + '.columnManager.columns[' + IntToStr(colIndex) + '].setEditor(' + ' new Ext.form.field.Date({' + ' id: ''' + BaseGrid.JSName + 'columnsEditor' + IntToStr(colIndex) + ''', ' + ' xtype: ''datefield'',' + ' format: ''d.m.Y'',' + ' anchor: ''100%'',' + ' })' + ' );'); end; ftInteger : begin UniSession.AddJS(BaseGrid.JSName + '.columnManager.columns[' + IntToStr(colIndex) + '].setEditor(' + ' new Ext.form.field.Number({' + ' id: ''' + BaseGrid.JSName + 'columnsEditor' + IntToStr(colIndex) + ''', ' + ' xtype: ''numberfield'',' + ' anchor: ''100%'',' + ' })' + ' );'); end; else begin UniSession.AddJS(BaseGrid.JSName + '.columnManager.columns[' + IntToStr(colIndex) + '].setEditor(' + ' new Ext.form.field.Text({' + ' id: ''' + BaseGrid.JSName + 'columnsEditor' + IntToStr(colIndex) + ''', ' + ' xtype: ''textfield'',' + ' anchor: ''100%'',' + ' })' + ' );'); end; end; end; end; Quote Link to comment Share on other sites More sharing options...
ttamturk Posted April 10, 2017 Share Posted April 10, 2017 you can't use beforeEdit event, i am not sure why but grid cancel editing automatically. And i can create a checkbox on runtime, it says "checkbox is not a constructor" etc. still working on it. if anyone can find a better solution for this please let us know, this is very critical issue for most developers i think. Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 Hi! @Sherzod How can I prevent dbgrid editors Tcontrol (unicombobox) from being automatically deleted after change editor on runtime? If I create control like showed above in ttamturk's post everithing works fine, but after change the editor the combobox will be removed/deleted/freed (second time I can't use it, I need to create again) I could need a different editor in every row depend on the data type. Combobox could contains hundred of items, so I think is not too good to create and release every time users clicks on it. thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 24 minutes ago, csaszko said: How can I prevent dbgrid editors Tcontrol (unicombobox) from being automatically deleted after change editor on runtime? If I create control like showed above in ttamturk's post everithing works fine, but after change the editor the combobox will be removed/deleted/freed (second time I can't use it, I need to create again) I could need a different editor in every row depend on the data type. Combobox could contains hundred of items, so I think is not too good to create and release every time users clicks on it. Hello, I'm sorry, your case is not very clear to me. Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 1 hour ago, Sherzod said: Hello, I'm sorry, your case is not very clear to me. I will try to say explain other way. I have tables something like this id, t2.field_name, t1.field_value, t1. field_type... etc in dbgrid col0=field_name, column1=field_value (something like propertygrid but more columns) column1 could contains different type of data so i need different kind of editor (date, text, combo) if I scroll/change row I need to show the specific editor for the actual row (not column). I can create editors runtime, but if user navigate an another row which has a different kind of data, it will change the editor and the previous editor control won't be availabe again, I can't reach that combobox anymore. (Cannot read properties of null) with date and free text, there is no problem, but with combobox with a lot of items... so is not good create each time when user want to edit that record. Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 2 hours ago, Sherzod said: Hello, I'm sorry, your case is not very clear to me. I need something like in verticaltreegrid, in each row could be a different editor. Unfortunately verticalgrid is not working form me neither, because of I use the same field for different type, and not different field. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 17 minutes ago, csaszko said: field for different type Have you tried searching the forum for solutions? Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 1 hour ago, Sherzod said: Have you tried searching the forum for solutions? Yes of course (you can check my forum history) , and demo, and source code and google.. and tried different comp. found this in unidbgrid.pas: // we must destroy picker each time column is reconfigured. Ext JS issue. Check again in 6.5 ok this is for datetimepicker.. not combobox , but at some point destroying as well Any idea, or did you find a forum solution what I could not? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 44 minutes ago, csaszko said: or did you find a forum solution what I could not? I will try to find later. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 2 hours ago, csaszko said: Any idea, or did you find a forum solution what I could not? You can also try searching with the keyword "seteditor". Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 23 minutes ago, Sherzod said: You can also try searching with the keyword "seteditor". I have read every post in this forum about that. I have been searching for two days, so please help me. I have hidden panel where I put combobox. On runtime I fill these combobox with desired items. I use this code: case 0:works one times, case 1: works fine. UniDBGrid1AjaxEvent: if EventName = 'select' then begin colIndex := 1; Case IndexText(fajl_extra_infok_ZQuery.FieldByName('extra_inf_tipus') .AsString, ['combo', 'datum']) of 0: begin with UniDBGrid1 do JSInterface.JSCall('setEditor', [UniComboBox1.JSControl], ColumnByName('extra_inf_ertek').JSColumn); end; 1: begin UniSession.AddJS(UniDBGrid1.JSName + '.columnManager.columns[' + IntToStr(colIndex) + '].setEditor(' + ' new Ext.form.field.Date({' + ' id: ''' + UniDBGrid1.JSName + 'columnsEditor' + IntToStr(colIndex) + ''', ' + ' xtype: ''datefield'',' + ' format: ''d.m.Y'',' + ' anchor: ''100%'',' + ' })' + ' );'); end; else begin UniSession.AddJS(UniDBGrid1.JSName + '.columnManager.columns[' + IntToStr(colIndex) + '].setEditor(' + ' new Ext.form.field.Text({' + ' id: ''' + UniDBGrid1.JSName + 'columnsEditor' + IntToStr(colIndex) + ''', ' + ' xtype: ''textfield'',' + ' anchor: ''100%'',' + ' })' + ' );'); end; end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 Of course we will try to help you. But to be clear... 6 hours ago, csaszko said: column1 could contains different type of data so i need different kind of editor (date, text, combo) How you define is not very clear. 6 hours ago, csaszko said: if I scroll/change row I need to show the specific editor for the actual row (not column). 6 hours ago, csaszko said: I can create editors runtime, but if user navigate an another row which has a different kind of data, it will change the editor and the previous editor control won't be availabe again, I can't reach that combobox anymore. (Cannot read properties of null) It's also not clear. 6 hours ago, csaszko said: with date and free text, there is no problem, but with combobox with a lot of items... so is not good create each time when user want to edit that record. ? Can you create a simple example with few records to understand your case? Quote Link to comment Share on other sites More sharing options...
csaszko Posted March 31, 2022 Share Posted March 31, 2022 2 hours ago, Sherzod said: Of course we will try to help you. But to be clear... How you define is not very clear. It's also not clear. ? Can you create a simple example with few records to understand your case? I modified the demo. try to edit variable_value column more than one record. GridEditors alter.zip Quote Link to comment Share on other sites More sharing options...
csaszko Posted April 6, 2022 Share Posted April 6, 2022 On 3/31/2022 at 7:45 PM, Sherzod said: Of course we will try to help you. But to be clear... How you define is not very clear. It's also not clear. ? Can you create a simple example with few records to understand your case? Would you check please? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 6, 2022 Share Posted April 6, 2022 2 hours ago, csaszko said: Would you check please? Hello, Sorry for the late response. I just checked your case, I'll try to analyze it again tomorrow, maybe it's better to do it on the client side. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 8, 2022 Share Posted April 8, 2022 On 4/1/2022 at 1:11 AM, csaszko said: try to edit variable_value column more than one record. Hello, Sorry, I haven’t been able to implement it yet, and I think it can’t be implemented right now, especially for some types (date, time). Quote Link to comment Share on other sites More sharing options...
csaszko Posted April 8, 2022 Share Posted April 8, 2022 9 minutes ago, Sherzod said: Hello, Sorry, I haven’t been able to implement it yet, and I think it can’t be implemented right now, especially for some types (date, time). Hi, Sorry for hear that. OK. I will find other way then. Tanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 8, 2022 Share Posted April 8, 2022 2 minutes ago, csaszko said: Sorry for hear that. OK. I will find other way then. I'll try again, if I succeed I'll let you know. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.