likemike Posted December 18, 2021 Share Posted December 18, 2021 Hello! I want to open a special edit form, when the user tries to edit a text column in an UnimDBGrid. I know, that there isn't an OnEnter method in UnimDBGrid, but is there a workaround? Thanks in advance Mike Link to comment Share on other sites More sharing options...
Sherzod Posted December 18, 2021 Share Posted December 18, 2021 46 minutes ago, likemike said: when the user tries to edit a text column in an UnimDBGrid Hello, How? Link to comment Share on other sites More sharing options...
likemike Posted December 18, 2021 Author Share Posted December 18, 2021 The fields in the grid are editable. The user can edit them by directly write into the grid. Link to comment Share on other sites More sharing options...
Sherzod Posted December 28, 2021 Share Posted December 28, 2021 On 12/18/2021 at 7:35 PM, likemike said: The fields in the grid are editable. The user can edit them by directly write into the grid. Do you want to open the form when the cell is activated? Link to comment Share on other sites More sharing options...
likemike Posted December 28, 2021 Author Share Posted December 28, 2021 Yes - that's the plan. That means, when the user clicks in the field to fill something in. In a "normal" DBGrid there are the events "OnEnter" and "OnExit". Link to comment Share on other sites More sharing options...
likemike Posted January 6, 2022 Author Share Posted January 6, 2022 Any suggestions? Link to comment Share on other sites More sharing options...
Sherzod Posted January 6, 2022 Share Posted January 6, 2022 34 minutes ago, likemike said: Any suggestions? Sorry for the late response. On 12/18/2021 at 7:35 PM, likemike said: The fields in the grid are editable. The user can edit them by directly write into the grid. Could you please make a simple testcase? Link to comment Share on other sites More sharing options...
likemike Posted January 7, 2022 Author Share Posted January 7, 2022 I don't think that a testcase would be helpful. What I need is an OnEnter-event and an OnExit-event in an UnimDBGrid. Link to comment Share on other sites More sharing options...
Sherzod Posted January 7, 2022 Share Posted January 7, 2022 8 minutes ago, likemike said: I don't think that a testcase would be helpful. It would be great with your grid settings. Link to comment Share on other sites More sharing options...
likemike Posted January 7, 2022 Author Share Posted January 7, 2022 OK! This is the demo-project "DBGrid Editors" (modified with activated "CellEditor"-property). DBGrid Editors.rar When I want to display a calculator, when the user edits the salary-column, I need an event fireing when the user doubleclick the salary-field. And I want to display an extra editor-form when the user edits the name-colum for example. In my application one column holds a lot of text and calculations, so I need to open a special editor-form when the user double-click this cell. Link to comment Share on other sites More sharing options...
Sherzod Posted January 7, 2022 Share Posted January 7, 2022 52 minutes ago, likemike said: When I want to display a calculator, when the user edits the salary-column, I need an event fireing when the user doubleclick the salary-field. If it's ok for you, you can disable editing, and handle childdoubletap event on the client side. Link to comment Share on other sites More sharing options...
Sherzod Posted January 7, 2022 Share Posted January 7, 2022 For example like in this post: Link to comment Share on other sites More sharing options...
likemike Posted January 7, 2022 Author Share Posted January 7, 2022 Hello! It's a step in the right direction. But I need the CellEditor for most of the columns and a "special" editor for a few columns. If I disable option "dgEditing", I have to open my editor for every column which the user wants to edit - that's not good. If I enable option "dgEditing", it works nearly perfect, but to make my editor work correctly, I need to disable "dgEditing" before the editor opens. After closing the editor I try to enable "dgEditing" again, but that doesn't work. Here's my code: procedure TForm.UnimDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var columnIDX : INTEGER; begin if EventName = '_doubleclick' then begin columnIDX:=Params['colidx'].AsInteger; if columnIDX=2 then begin try UnimDBGrid1.Options:=UnimDBGrid1.Options-[dgEditing]; FEditor.ShowModal; finally UnimDBGrid1.Options:=UnimDBGrid1.Options+[dgEditing]; // that has no effect end; // here I save the text in my editor memo to the text-field QTable.FieldByName('TEXT').AsString:=FEditor.UnimMemo1.Text; end; end; end; Link to comment Share on other sites More sharing options...
Sherzod Posted January 7, 2022 Share Posted January 7, 2022 11 minutes ago, likemike said: But I need the CellEditor for most of the columns and a "special" editor for a few columns. Okay. There is a solution for this case. I'll try to give a solution tomorrow. Link to comment Share on other sites More sharing options...
Sherzod Posted January 8, 2022 Share Posted January 8, 2022 8 hours ago, likemike said: But I need the CellEditor for most of the columns and a "special" editor for a few columns. Solution. 1. procedure TMainmForm.UnimFormCreate(Sender: TObject); begin // for example for ColumnIndex=5 UnimDBGrid1.JSInterface.JSAddListener('beforeedit', 'function(me, location){return (location.columnIndex !== 5)}'); UnimDBGrid1.JSInterface.JSAddListener('childdoubletap', 'function(me, location){if (location.columnIndex == 5) {ajaxRequest(me, "_childdoubletap", ["colIndx="+location.columnIndex])}}') end; 2. procedure TMainmForm.UnimDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_childdoubletap' then begin // custom logic ShowMessage(Params.Values['colIndx']) end; end; Link to comment Share on other sites More sharing options...
likemike Posted January 8, 2022 Author Share Posted January 8, 2022 That works great! Thanks a lot!! 1 Link to comment Share on other sites More sharing options...
Recommended Posts