Jump to content
uniGUI Discussion Forums
M477H13U

add new ItemMenu to Grid Column SortMenu

Recommended Posts

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 ?  -_-

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×