Masteritec Posted March 8, 2021 Share Posted March 8, 2021 1. Delphi has LockColumn function to determine column is readonly or not. function TMainForm.LockColumn(ColIdx: Integer): boolean; begin if ColIdx in [1,2] then begin Result:= ClientDataSet1.FieldByName('EmpNo').AsInteger < 20; end; end; 2. UniDBGrid -> ClientEvents -> ExtEvents -> beforeedit to call LockColumn. function beforeedit(editor, context, eOpts) { return MainForm.LockColumn(context.colIdx); } Please refer sample, can't call LockColumn to get lock or not Grid.zip Link to comment Share on other sites More sharing options...
mhmda Posted March 8, 2021 Share Posted March 8, 2021 ajaxRequest(MainForm.window,'myfunction',[]);//js code to call a function inside MainForm->AjaxEvents Link to comment Share on other sites More sharing options...
Masteritec Posted March 8, 2021 Author Share Posted March 8, 2021 Hi, Thanks for reply. If Delphi function return True/False, how to pass back to JS? like below: LockColumn(context.colIdx) return True/False function beforeedit(editor, context, eOpts) { return MainForm.LockColumn(context.colIdx); } Link to comment Share on other sites More sharing options...
Sherzod Posted March 8, 2021 Share Posted March 8, 2021 1 hour ago, Masteritec said: If Delphi function return True/False, how to pass back to JS? Hi, Something like this: 1. function beforeedit(editor, context, eOpts) { return ajaxRequest(this, 'getCheck', [], false).responseText == 'true'; } 2. procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'getCheck' then begin if ClientDataSet1.FieldByName('EmpNo').AsInteger < 20 then UniSession.SendResponse('true') else UniSession.SendResponse('false') end; end; 1 Link to comment Share on other sites More sharing options...
Masteritec Posted March 8, 2021 Author Share Posted March 8, 2021 This work well. Thanks 1 Link to comment Share on other sites More sharing options...
Masteritec Posted March 9, 2021 Author Share Posted March 9, 2021 Hi, context.colIdx return is not match with Column.ColID when some column is hide. Eg. Column1 - Visible, Column2 - Visible, Column3 - Visible, Column4 - Hide, Column5 - Hide, Column6 - Visible, Column6 - context.colIdx is 3, but Column.ColID is 6. Any solution match with context.colIdx? Link to comment Share on other sites More sharing options...
Sherzod Posted March 9, 2021 Share Posted March 9, 2021 1 minute ago, Masteritec said: Any solution match with context.colIdx? You may need dataIndex? Link to comment Share on other sites More sharing options...
Masteritec Posted March 9, 2021 Author Share Posted March 9, 2021 10 minutes ago, Sherzod said: You may need dataIndex? Only Index, but also can't match with context.colIdx. Link to comment Share on other sites More sharing options...
Sherzod Posted March 9, 2021 Share Posted March 9, 2021 15 minutes ago, Masteritec said: Only Index, but also can't match with context.colIdx. Maybe I don't quite understand your case, could you re-create the test case to see the problem? Link to comment Share on other sites More sharing options...
Masteritec Posted March 9, 2021 Author Share Posted March 9, 2021 17 minutes ago, Sherzod said: Maybe I don't quite understand your case, could you re-create the test case to see the problem? Refer below: colIdx 4 is not City, cause i hide few columns. Refer test case Grid2.zip Link to comment Share on other sites More sharing options...
Sherzod Posted March 9, 2021 Share Posted March 9, 2021 Ok, I will check it. Link to comment Share on other sites More sharing options...
Sherzod Posted March 9, 2021 Share Posted March 9, 2021 29 minutes ago, Masteritec said: Grid2.zip 146.42 kB · 0 downloads Can you check with this code? function beforeedit(editor, context, eOpts) { return ajaxRequest(this, "GridEditing", ["colIdx="+context.field], false).responseText == "true"; } 1 Link to comment Share on other sites More sharing options...
Masteritec Posted March 9, 2021 Author Share Posted March 9, 2021 Hi, It work well, thank you. 1 Link to comment Share on other sites More sharing options...
Masteritec Posted March 9, 2021 Author Share Posted March 9, 2021 Hi, I want to check if column is 'Last Name' or 'First Name' in beforeedit like below: Quote function beforeedit(editor, context, eOpts) { if ((context.field == 1) || (context.field == 2)) { return ajaxRequest(this, "GridEditing", ["colIdx="+context.field], false).responseText == "true"; }; } But if column change position will get wrong, any solution? Column no change checking is correct: Column changed checking is incorrect: Grid3.zip Link to comment Share on other sites More sharing options...
Sherzod Posted March 10, 2021 Share Posted March 10, 2021 12 hours ago, Masteritec said: But if column change position will get wrong, any solution? I think we need to reconsider our decisions with you. Please tell me again the main goal, what would you like to achieve. Link to comment Share on other sites More sharing options...
Masteritec Posted March 10, 2021 Author Share Posted March 10, 2021 7 minutes ago, Sherzod said: I think we need to reconsider our decisions with you. Please tell me again the main goal, what would you like to achieve. 1. Column A, Column B, Column C, Column D 2. Column D read only is depend on Column A is empty or not. If Column A empty then Column D can't assign value. 3. Customer allow to move Column position. Link to comment Share on other sites More sharing options...
Sherzod Posted March 10, 2021 Share Posted March 10, 2021 1 hour ago, Masteritec said: 1. Column A, Column B, Column C, Column D 2. Column D read only is depend on Column A is empty or not. If Column A empty then Column D can't assign value. 3. Customer allow to move Column position. Ok, I'll analyze again. Link to comment Share on other sites More sharing options...
Masteritec Posted March 12, 2021 Author Share Posted March 12, 2021 On 3/10/2021 at 1:25 PM, Sherzod said: Ok, I'll analyze again. Hi, Any solution for it? thanks Link to comment Share on other sites More sharing options...
Sherzod Posted March 12, 2021 Share Posted March 12, 2021 On 3/10/2021 at 10:25 AM, Sherzod said: 2. Column D read only is depend on Column A is empty or not. If Column A empty then Column D can't assign value. Hi, What if there is such a scenario? 1. The user will assign the value to Column A 2. Then the user will assign the value to Column D 3. After, the user will delete the value in Column A Link to comment Share on other sites More sharing options...
Masteritec Posted March 12, 2021 Author Share Posted March 12, 2021 8 minutes ago, Sherzod said: Hi, What if there is such a scenario? 1. The user will assign the value to Column A 2. Then the user will assign the value to Column D 3. After, the user will delete the value in Column A Delete the value in Column A and system auto delete the value in Column D. Link to comment Share on other sites More sharing options...
Masteritec Posted March 12, 2021 Author Share Posted March 12, 2021 Hi, Quote function beforeedit(editor, context, eOpts) { if ((context.field == 1) || (context.field == 2)) { return ajaxRequest(this, "GridEditing", ["colIdx="+context.field], false).responseText == "true"; }; } above coding can be write on the fly? Then I can assign context.field after column move in grid. Link to comment Share on other sites More sharing options...
Masteritec Posted March 13, 2021 Author Share Posted March 13, 2021 Hi, any idea for it? Link to comment Share on other sites More sharing options...
Sherzod Posted March 14, 2021 Share Posted March 14, 2021 9 hours ago, Masteritec said: Hi, any idea for it? Hi, Do you mean these values "==1, ==2" ? Link to comment Share on other sites More sharing options...
Masteritec Posted March 14, 2021 Author Share Posted March 14, 2021 11 hours ago, Sherzod said: Hi, Do you mean these values "==1, ==2" ? Yup, how to dynamic it when column position change. Link to comment Share on other sites More sharing options...
Sherzod Posted March 14, 2021 Share Posted March 14, 2021 59 minutes ago, Masteritec said: Yup, how to dynamic it when column position change. I will try to provide you one of the possible solutions. 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