Ulugbek Posted July 22, 2013 Posted July 22, 2013 Hi All can you help me TUniDbgrid how get cell value and column name from cell? Quote
mhmda Posted July 22, 2013 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; Quote
Ulugbek Posted July 22, 2013 Author 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; Quote
Sherzod Posted July 23, 2013 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; Quote
M477H13U Posted July 20, 2018 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, Quote
Sherzod Posted August 6, 2018 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?.. Quote
M477H13U Posted September 20, 2018 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 Quote
M477H13U Posted October 31, 2018 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! Quote
Sherzod Posted October 31, 2018 Posted October 31, 2018 Hello, Sorry for the delay, Can you make a simple testcase without "SQLite" ?! Quote
Sherzod Posted October 31, 2018 Posted October 31, 2018 15 minutes ago, Sherzod said: Can you make a simple testcase without "SQLite" ?! Ok, sorry, test case is not needed Quote
M477H13U Posted October 31, 2018 Posted October 31, 2018 Hello Sherzod ! What do you suggest then ? (: Quote
Sherzod Posted October 31, 2018 Posted October 31, 2018 Hello, It seems you quickly select and at the same time press key Quote
M477H13U Posted October 31, 2018 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 ? Quote
Sherzod Posted October 31, 2018 Posted October 31, 2018 Just for an additional info, can you make a gif file... How are you editing and pressing? Quote
M477H13U Posted October 31, 2018 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 Quote
M477H13U Posted October 31, 2018 Posted October 31, 2018 Thanks for the quick answer Looking forward to see your workaround Quote
Sherzod Posted October 31, 2018 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; Quote
M477H13U Posted November 5, 2018 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 ! (: Quote
PS1 Posted October 25, 2023 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. Quote
Sherzod Posted October 25, 2023 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. Quote
PS1 Posted October 25, 2023 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 Quote
Sherzod Posted October 25, 2023 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? Quote
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.