carrera Posted November 3, 2015 Share Posted November 3, 2015 Hi, I need to trap Enter Key in UniDBGrid for Refreshing Calculate Field when user press enter in cell editor, cursor will focus to the next column and calculate field value will be changed (refresh) i use TForm........UniDBGrid.OnKeyDown if Key = VK_RETURN then <-- it doesn't work, cannot trap enter key RefreshDataset; Thank you Environment Delphi XE7 UniGui 0.99.80.1214 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 3, 2015 Share Posted November 3, 2015 I need to trap Enter Key in UniDBGrid for Refreshing Calculate Field when user press enter in cell editor, cursor will focus to the next column and calculate field value will be changed (refresh) i use TForm........UniDBGrid.OnKeyDown if Key = VK_RETURN then <-- it doesn't work, cannot trap enter key RefreshDataset; Hi, One of the possible solutions, may help, try For now, you can use: UniDBGrid ... function edit(editor, context, eOpts) 1. UniDBGrid1 -> ClientEvents -> ExtEvents function edit(editor, context, eOpts) { function _post () { ajaxRequest(editor.grid, '_post', []); } setTimeout(_post, 200); } 2. procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName = '_post' then begin if (UniDBGrid1.DataSource.DataSet.State in [dsEdit]) then UniDBGrid1.DataSource.DataSet.Post; end; end; Best regards. Quote Link to comment Share on other sites More sharing options...
carrera Posted November 7, 2015 Author Share Posted November 7, 2015 Thanks, It's work great Quote Link to comment Share on other sites More sharing options...
d.bernaert Posted October 26, 2022 Share Posted October 26, 2022 Hi, I'm trying to implement this and it works good, but the event is also fired when pressing the tab button to go to the next field in line of the grid. This makes that by tabbing to the next field the record is posted and the user needs to click the selected field again to edit it. Is there a workaround for this? Thx, Dominique Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 26, 2022 Share Posted October 26, 2022 Hello Dominique, Seems I couldn't reproduce your case. Quote Link to comment Share on other sites More sharing options...
d.bernaert Posted October 26, 2022 Share Posted October 26, 2022 I will try to create a testcase. Quote Link to comment Share on other sites More sharing options...
d.bernaert Posted October 27, 2022 Share Posted October 27, 2022 I've been able to solve this, but i have another problem. I have attached a testcase. I have a button to create a new record. I do an append, fill in the default values, post the data and put the table in edit mode. When entering data in the line When creating a new line and entering data in the value of the field is reset when going to another field. You can see it in the attached screenshot, the value of the second column is reset after entering the third field and going to the next field. Gridedit.mp4 TestGridEdit.zip Quote Link to comment Share on other sites More sharing options...
d.bernaert Posted October 27, 2022 Share Posted October 27, 2022 Is there still somebody of Unigui available here? It's really quiet here.... I'm getting very worried. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2022 Share Posted October 28, 2022 Yes sorry, maybe we need to find another way to do this. Why do you need autopost? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2022 Share Posted October 28, 2022 Can you try this approach? 1. function edit: function edit(editor, context, eOpts) { /*function _post () { ajaxRequest(editor.grid, '_post', []); } setTimeout(_post, 200);*/ return ajaxRequest(editor.grid, '_post', [], false).responseText == "true"; } 2. AjaxEvent: procedure TMainForm.GridLinesAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_post' then begin if (GridLines.DataSource.DataSet.State in [dsInsert, dsEdit]) then begin GridLines.DataSource.DataSet.Post; UniSession.SendResponse('true'); end; end; end; 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.