Jump to content
uniGUI Discussion Forums
A.Soltani

Check Key in OnColumnSort Event

Recommended Posts

Hi

 

How to I can check Control Key (Ctrl , Alt , Shift ) in OnColumnSort Event?

I want do job 1  in OnColumnSort Event and when user press Ctrl and click on column do another job.

 

 

 

 

Best Regards.

Share this post


Link to post
Share on other sites

 

 

Are you already using multi sorting?

 

 

No

Share this post


Link to post
Share on other sites

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;

Share this post


Link to post
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

Share this post


Link to post
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,

Share this post


Link to post
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;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×