Jump to content


Photo

Check Key in OnColumnSort Event

OnColumnSort UniDbGrid

  • Please log in to reply
6 replies to this topic

#1 A.Soltani

A.Soltani

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 157 posts
  • LocationTehran-Iran

Posted 10 July 2018 - 05:19 PM

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.


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 10 July 2018 - 05:38 PM

Hi,

 

Are you already using multi sorting?


  • 0

#3 A.Soltani

A.Soltani

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 157 posts
  • LocationTehran-Iran

Posted 10 July 2018 - 07:13 PM

 

 

Are you already using multi sorting?

 

 

No


  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 11 July 2018 - 05:29 AM

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;

  • 0

#5 Farshad Mohajeri

Farshad Mohajeri

    Administrator

  • Administrators
  • 10426 posts

Posted 11 July 2018 - 06:44 AM

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


  • 0

#6 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 11 July 2018 - 06:59 AM

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,


  • 0

#7 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 11 July 2018 - 07:09 AM

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;

  • 0





Also tagged with one or more of these keywords: OnColumnSort, UniDbGrid

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users