Jump to content

How to call Delphi function in ClientEvent


Masteritec

Recommended Posts

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

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

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;

 

  • Like 1
Link to comment
Share on other sites

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

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";
}

 

  • Like 1
Link to comment
Share on other sites

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:

image.png.b3bc3ecc300fb0bf0a552cedb0a4c4bc.png

Column changed checking is incorrect:

image.png.d8401c7583b778ec172c07d048a4b5a5.png

Grid3.zip

Link to comment
Share on other sites

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

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

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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...