Sherzod Posted March 14, 2021 Share Posted March 14, 2021 On 3/9/2021 at 7:59 PM, Masteritec said: Grid3.zip 146.55 kB · 5 downloads Unclear, but in this test case you are not using UniSession.SendResponse ('true / false') Quote Link to comment Share on other sites More sharing options...
Masteritec Posted March 15, 2021 Author Share Posted March 15, 2021 Hi, Please see below code and sample Grid4. If LastName and FirstName is empty, other columns is not allow edit, but if LastName or FirstName column change position, below code will wrong. if ((context.field == 3) || (context.field == 4) || (context.field == 5) || (context.field == 6) || (context.field == 7) || (context.field == 8)) { return ajaxRequest(this, "GridEditing", [], false).responseText == "true"; }; Quote procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'GridEditing' then begin if (ClientDataSet1.FieldValues['LastName'] = '') and (ClientDataSet1.FieldValues['FirstName'] = '') then begin UniSession.SendResponse('false'); end else begin UniSession.SendResponse('true'); end; end; end; Quote function beforeedit(editor, context, eOpts) { if ((context.field == 3) || (context.field == 4) || (context.field == 5) || (context.field == 6) || (context.field == 7) || (context.field == 8)) { return ajaxRequest(this, "GridEditing", [], false).responseText == "true"; }; } Grid4.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 15, 2021 Share Posted March 15, 2021 29 minutes ago, Masteritec said: Grid4.zip 145.88 kB · 0 downloads Hi, OK, I'll check your testcase. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 15, 2021 Share Posted March 15, 2021 1 hour ago, Masteritec said: Grid4.zip 145.88 kB · 0 downloads Can you try to use this approach? 1. function beforeedit(editor, context, eOpts) { return ajaxRequest(this, "GridEditing", ["colIdx=" + context.field], false).responseText == "true"; } 2. procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var ColIdx: Integer; begin if EventName = 'GridEditing' then begin ColIdx := Params.Values['colIdx'].ToInteger; if ((Sender as TUniDBGrid).Columns[ColIdx].FieldName <> 'LastName') and ((Sender as TUniDBGrid).Columns[ColIdx].FieldName <> 'FirstName') and (ClientDataSet1.FieldValues['LastName'] = '') and (ClientDataSet1.FieldValues['FirstName'] = '') then begin UniSession.SendResponse('false'); end else begin UniSession.SendResponse('true'); end; end; end; 1 1 Quote Link to comment Share on other sites More sharing options...
Masteritec Posted March 15, 2021 Author Share Posted March 15, 2021 Hi, is OK. Thanks 1 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.