EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: lexa on June 24, 2015, 01:53:42 AM



Title: datagrid contextmenu
Post by: lexa on June 24, 2015, 01:53:42 AM
Hi, All!
I'm a newby in EasyUI, but is very exited of it.
First of all i decided to write simple application for web, using EasyUI to look like usual windows program written in delphi.

My question is: in datagrid i can bind contextmenu ONLY to records of data, but not for entire table? if i have no record in table menu would not appear?

I've done what i need, but it looks not readable:

Code:
$('.datagrid-view .datagrid-view2 .datagrid-body').bind('contextmenu', function (e) { 
  ...
});

It's working, but... is there a more wright way to do this?

p.s. sorry for my poor english...


Title: Re: datagrid contextmenu
Post by: jarry on June 24, 2015, 07:08:02 PM
Please use the 'onRowContextMenu' event instead. If no row is clicked, the 'index' parameter value is -1. Before use this feature please download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.2-patch.zip.
Code:
$('#dg').datagrid({
  onRowContextMenu:function(e,index,row){
  }
});


Title: Re: datagrid contextmenu
Post by: lexa on June 25, 2015, 03:57:36 PM
Hi, jarry!

Thaks a lot. Exactly what i wanted and needed. Due to your help js code reduced significant!

Once more: Thank You.