carrera Posted March 29, 2017 Share Posted March 29, 2017 Hi, Let's say i have 3 columns in UniDBGrid Row No | ColA | ColB 1 111 + 2 222 + 3 333 - ........ if cursor point on row that ColA Value = '222', i need to disable UniDBGrid key press I Think ExtJS Event can handle this, but not sure how do i call js function function keypress(e, t, eOpts) { var me = MainForm.UniDBGrid1; // not sure how to get dbgrid value in JS // ex. if Dataset.fieldByName('ColA').AsString = '222' then // Key := #0 } Thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 29, 2017 Share Posted March 29, 2017 Hi, By doing this what you wanted?! Cancel editing? Quote Link to comment Share on other sites More sharing options...
carrera Posted March 29, 2017 Author Share Posted March 29, 2017 Hi Delphi Dev, I need to revert value before editing or prevent user key into grid if condition met Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 29, 2017 Share Posted March 29, 2017 Hi, Can you try this approach for now ?!: UniDBGrid -> ClientEvents -> ExtEvents -> beforeedit fn: function beforeedit(editor, context, eOpts) { var me=context; if (me.column.dataIndex == "1" && me.originalValue == "222") { return false; } } Best regards. Quote Link to comment Share on other sites More sharing options...
carrera Posted March 29, 2017 Author Share Posted March 29, 2017 If i want to get value from Another Column, how can i re-write this code Assume user click (Focus) in column B and i need to get value from Column A if (me.column.dataIndex == "2" && ColAValue = "222") { return false; } Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 29, 2017 Share Posted March 29, 2017 Ok, then you can use this: function beforeedit(editor, context, eOpts) { var me=context; //me.record.data[yourColIndx] if (me.record.data[1] == "222") { return false } } Quote Link to comment Share on other sites More sharing options...
carrera Posted March 29, 2017 Author Share Posted March 29, 2017 Ok, then you can use this: function beforeedit(editor, context, eOpts) { var me=context; //me.record.data[yourColIndx] if (me.record.data[1] == "222") { return false } } Work as expected! Thank you Quote Link to comment Share on other sites More sharing options...
Masteritec Posted July 9, 2019 Share Posted July 9, 2019 On 3/30/2017 at 1:46 AM, Sherzod said: Ok, then you can use this: function beforeedit(editor, context, eOpts) { var me=context; //me.record.data[yourColIndx] if (me.record.data[1] == "222") { return false } } Hi Sherzod, If grid column is allow to move the index maybe wrong, how to get the colindex by field name. Can you assist me in this. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 9, 2019 Share Posted July 9, 2019 2 hours ago, Masteritec said: If grid column is allow to move the index maybe wrong, how to get the colindex by field name. Hi, Maybe you need to use like this: me.record.data[context.colIdx] Quote Link to comment Share on other sites More sharing options...
Masteritec Posted July 9, 2019 Share Posted July 9, 2019 4 hours ago, Sherzod said: Hi, Maybe you need to use like this: me.record.data[context.colIdx] This still cannot work. I am using Unigui demo Column Sort to test. Example For row City = "Christiansted", for row City = "Christiansted" and Company Column field not allow to edit. function beforeedit(editor, context, eOpts) { var me=context; if ((me.column.dataIndex == "1") && (me.record.data[4] == "Christiansted")) { return false; } } Above code is ok if Column City & Company not allow to move. If allow to move still wrong. Please advice Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 10, 2019 Share Posted July 10, 2019 3 hours ago, Masteritec said: Above code is ok if Column City & Company not allow to move If not difficult can you make a simple testcase for reproduce? Quote Link to comment Share on other sites More sharing options...
Masteritec Posted July 10, 2019 Share Posted July 10, 2019 28 minutes ago, Sherzod said: If not difficult can you make a simple testcase for reproduce? This testcase is ok if you no move the column Requirment is Row Customer No 1384 & 1356 city is Christiansted, so Company Column for this 2 row is not allow to edit. other is allow to edit. Testing steps Step 1 : You try to move the Company Column after Addr1 Issue : Company Column become allow to edit and Addr1 not allow to edit ====> because me.column.dataIndex == "1" Step 2 : You try to move the City Column after State Issue : All column allow to edit ====> because me.record.data[4] == "Christiansted" Please advice. Thanks Cell Disable.7z Quote Link to comment Share on other sites More sharing options...
Masteritec Posted July 12, 2019 Share Posted July 12, 2019 On 7/10/2019 at 11:21 AM, Masteritec said: This testcase is ok if you no move the column Requirment is Row Customer No 1384 & 1356 city is Christiansted, so Company Column for this 2 row is not allow to edit. other is allow to edit. Testing steps Step 1 : You try to move the Company Column after Addr1 Issue : Company Column become allow to edit and Addr1 not allow to edit ====> because me.column.dataIndex == "1" Step 2 : You try to move the City Column after State Issue : All column allow to edit ====> because me.record.data[4] == "Christiansted" Please advice. Thanks Cell Disable.7z Any update on this? 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.