Ulugbek Posted July 22, 2013 Share Posted July 22, 2013 Hi All can you help me TUniDbgrid how get cell value and column name from cell? Link to comment Share on other sites More sharing options...
mhmda Posted July 22, 2013 Share Posted July 22, 2013 procedure TMainForm.UniDBGrid1CellClick(Column: TUniDBGridColumn); var val:string; clmn_name:string; begin val:=Column.Field.AsString; clmn_name:=Column.FieldName; end; Link to comment Share on other sites More sharing options...
Ulugbek Posted July 22, 2013 Author Share Posted July 22, 2013 10x Mohammad How with button click get not cell click .. I try this but this work only first column procedure TMainForm.est1Click(Sender: TObject); var val1:string; clmn_name1:string; begin val1:=UniDBGrid1.Columns[0].Field.AsString; clmn_name1:=UniDBGrid1.Columns[0].Field.FieldName; ShowMessage(Concat(val1,' ',clmn_name1)); end; Link to comment Share on other sites More sharing options...
Sherzod Posted July 23, 2013 Share Posted July 23, 2013 Hi Ulugbek. Try this: type TDBGridHack = class(TuniDBGrid) private function GetCurrCol: Integer; end; function TDBGridHack.GetCurrCol: Integer; begin Result := CurrCol; end; procedure TMainForm.UniBitBtn1Click(Sender: TObject); var i: Integer; begin i := TDBGridHack(UniDBGrid1).GetCurrCol; ShowMessage(UniDBGrid1.Columns[i].Field.AsString + ' ' + UniDBGrid1.Columns[i].FieldName); end; Link to comment Share on other sites More sharing options...
Ulugbek Posted July 24, 2013 Author Share Posted July 24, 2013 big thank's Link to comment Share on other sites More sharing options...
M477H13U Posted July 20, 2018 Share Posted July 20, 2018 Hello there ! (: is it possible to access the value of a the current cell in onKeyDown event ? Here's the use case: I'm in my cell, updating my value I press for instance F3 key for a specific action I obtain the cell value (the dataSource have not been update yet so UniDBGrid1.Columns[i].Field.AsString give the old value!) Do my stuff. How my I obtain the cell value ? Regards, Link to comment Share on other sites More sharing options...
M477H13U Posted August 6, 2018 Share Posted August 6, 2018 Up ! Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2018 Share Posted August 6, 2018 Hi, Hello there ! (: is it possible to access the value of a the current cell in onKeyDown event ? Here's the use case: I'm in my cell, updating my value I press for instance F3 key for a specific action I obtain the cell value (the dataSource have not been update yet so UniDBGrid1.Columns[i].Field.AsString give the old value!) Do my stuff. How my I obtain the cell value ? Regards, Sorry, can you make a simple testcase for this?.. Link to comment Share on other sites More sharing options...
M477H13U Posted September 20, 2018 Share Posted September 20, 2018 Hello Sherzod! Sorry for the delay, I did not had time to manage this issue. You can find bellow a testCase that highlight the issue I am talking about ! Can't wait to read you ! TestGridEdit+KeyDown.7z Link to comment Share on other sites More sharing options...
M477H13U Posted October 31, 2018 Share Posted October 31, 2018 Hello there uniGUI ! Did you have the time to check my simple test case ? I am looking forward for a solution! Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 Hello, Sorry for the delay, Can you make a simple testcase without "SQLite" ?! Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 15 minutes ago, Sherzod said: Can you make a simple testcase without "SQLite" ?! Ok, sorry, test case is not needed Link to comment Share on other sites More sharing options...
M477H13U Posted October 31, 2018 Share Posted October 31, 2018 Hello Sherzod ! What do you suggest then ? (: Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 Hello, It seems you quickly select and at the same time press key Link to comment Share on other sites More sharing options...
M477H13U Posted October 31, 2018 Share Posted October 31, 2018 Indeed, I am quiclkly editing a cell and by pressing my Key, I would like to extract the new value. It is done with TUniStringGrid.Cell[Row, Col] Is there a way to achieve the same thing with uniDBGrid ? Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 Just for an additional info, can you make a gif file... How are you editing and pressing? Link to comment Share on other sites More sharing options...
M477H13U Posted October 31, 2018 Share Posted October 31, 2018 Have you even open my project ? Everything is detailed in the header of the form .. Anyhow, here's the gif you asked Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 Ok, thx for the gif, I will check... 1 Link to comment Share on other sites More sharing options...
M477H13U Posted October 31, 2018 Share Posted October 31, 2018 Thanks for the quick answer Looking forward to see your workaround Link to comment Share on other sites More sharing options...
Sherzod Posted October 31, 2018 Share Posted October 31, 2018 Perhaps this solution is not very suitable for you, but try this "workaround": 1. UniDBGrid -> OnKeyDown, do not use this event: procedure TMainForm.UniDBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin // do not use this event // if Key = vk_F4 then // begin // ShowMessage('Cell value is '''+UniDBGrid1.Columns[UniDBGrid1.CurrCol].Field.AsString+'''.'); // end; end; 2. UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns.forEach(function(col) { if (col.getEditor()) { col.getEditor().on('keydown', function(field, e) { if (e.keyCode == 115) { // keyCode can also be passed ajaxRequest(sender, '_keydown', ['val=' + field.value]) } }) } }) } 3. UniDBGrid -> OnAjaxEvent: procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_keydown' then ShowMessage(Params.Values['val']); end; Link to comment Share on other sites More sharing options...
M477H13U Posted November 5, 2018 Share Posted November 5, 2018 Hey Sherzod, thanks for the answer !! There is a problem with editor's event : col.getEditor().on('keydown', function(field, e) { as it is never fired! Did I miss something ??:O But I managed to extract field value with this code, if anyone need it ! function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns.forEach(function(col){ if(col.getEditor()){ console.log(col.getEditor()); sender.on('keydown', function(e, t, eOpts){ console.log(e.keyCode); if(e.keyCode == 115){ ajaxRequest(sender, '_keydown', ['val='+col.field.value]); } }) } }) } On 10/31/2018 at 8:27 PM, Sherzod said: Perhaps this solution is not very suitable for you I am going to validate this with my manager and give you a feedback on that solution ! (: Link to comment Share on other sites More sharing options...
PS1 Posted October 25, 2023 Share Posted October 25, 2023 @Sherzod Can u please fix your ,,reconfigure" function ? M477H13U's Answer doesn't work for me. "col.field.value" doesn't return any value. Link to comment Share on other sites More sharing options...
Sherzod Posted October 25, 2023 Share Posted October 25, 2023 5 minutes ago, PS1 said: Can u please fix your ,,reconfigure" function ? What exactly? Describe your case and issue in full. Make a simple testcase if possible. Link to comment Share on other sites More sharing options...
PS1 Posted October 25, 2023 Share Posted October 25, 2023 Testcase made from demo project. You can just focus DBGrid and click any key. Alert should be shown but it is not. 2. UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns.forEach(function(col) { if (col.getEditor()) { col.getEditor().on('keydown', function(field, e) { if (e.keyCode == 115) { // keyCode can also be passed ajaxRequest(sender, '_keydown', ['val=' + field.value]) } }) } }) } The part : col.getEditor().on('keydown', function(field, e) { ...} This function does not fire. Grid - Infinite Scroll.zip Link to comment Share on other sites More sharing options...
Sherzod Posted October 25, 2023 Share Posted October 25, 2023 44 minutes ago, PS1 said: You can just focus DBGrid and click any key. Alert should be shown but it is not. In edit mode? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now