Jump to content


Photo

add new ItemMenu to Grid Column SortMenu


  • Please log in to reply
4 replies to this topic

#1 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 23 October 2017 - 10:02 AM

Hello everyone ! (:

 

Is it possible to add another entry to the 'sort menu' of a tUniDBGrid?

For instance, in my case I would like to add an entry in order to cancel a sort on a specific column !

 

How would I do that ?  -_-


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.


#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3663 posts

Posted 23 October 2017 - 12:23 PM

Hi,

 

You can try this:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniDBGrid1.JSInterface do
    JSAddListener('viewready',  JSFunction('me', 'me.headerCt.getMenu().insert(2, {id: "myID", itemId:"myItemId", text: "myitem", handler: function(){alert(this.id)}})'));
end;

Best regards,


  • 0

#3 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 23 October 2017 - 12:39 PM

Yeah,

 

I manage to find a JS code: 

function afterCreate(sender)
{
  var menu = sender.headerCt.getMenu();
  menu.add([{
     text: 'Custome Item',
     handler: function() {
     var columnDataIndex = menu.activeHeader.dataIndex;
     alert('custom item for column "'+columnDataIndex+'" was pressed');
     }
  }]); 
}
But I prefer your version as my manager does not like JS .. (:
My next step now would be to bind the JS handler to a Delphi event; would that be possible ? :3

  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.


#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3663 posts

Posted 23 October 2017 - 12:54 PM

Use ajaxRequest
  • 0

#5 M477H13U

M477H13U

    Member

  • uniGUI Subscriber
  • PipPip
  • 46 posts

Posted 23 October 2017 - 01:03 PM

Nothing is fired in onAjaxEvent while clicking in headerMenu :(

 

ps: I misread, you meant the onAjaxEvent event of the grid or a JS workaround ? If so, could you be more precise, please ? :o

 

Edit: I got the idea( http://forums.unigui...equest/?p=47899), thanks  ^_^


  • 0

M477h13U,

 

UniGUIVersion: 1.0.0.1416.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users