Jump to content

Check Key in OnColumnSort Event


Ario.Paxaz

Recommended Posts

Hi,

 

Maybe through with "global" listeners:

 

1.

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniDBGrid1 do
  begin
    UniSession.AddJS('document.addEventListener("keydown", function(e){if (e.ctrlKey){ajaxRequest('+JSName+', "_keydownup", ["ctrlKey="+e.ctrlKey])}})');
    UniSession.AddJS('document.addEventListener("keyup", function(e){if (!e.ctrlKey){ajaxRequest('+JSName+', "_keydownup", ["ctrlKey="+e.ctrlKey])}})');
  end;
end;

2.

public
  { Public declarations }
  ctrlKey: Boolean;
end;

3.

procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_keydownup' then
    ctrlKey := StrToBool(Params.Values['ctrlKey'])

end;

4.

procedure TMainForm.UniDBGrid1ColumnSort(Column: TUniDBGridColumn;
  Direction: Boolean);
begin
  if ctrlKey then ...
end;
Link to comment
Share on other sites

Let me remind that using JS code proposed by our moderator above should be done at your own risk.

We can't guarantee that above code will work, fit your purpose and will be compatible with future versions of Ext JS.

 

Thanks

 

Yes, he's right!

 

And forgive me, that I give you such decisions :)

it is better to open a request in our support portal, we will try to realise this feature

 

Best regards,

Link to comment
Share on other sites

Better use like this:

 

1. UniForm -> KeyPreview = True

 

2.

public
  { Public declarations }
  ctrlKey: Boolean;
end;

3.

procedure TMainForm.UniFormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  ctrlKey := ssCtrl in Shift;
end;

procedure TMainForm.UniFormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  ctrlKey := ssCtrl in Shift;
end;

4.

procedure TMainForm.UniDBGrid1ColumnSort(Column: TUniDBGridColumn;
  Direction: Boolean);
begin
  if ctrlKey then ...
end;
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...