EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rangaNadha on July 31, 2015, 04:04:57 AM



Title: Datagrid: Filter Menu on click column header
Post by: rangaNadha on July 31, 2015, 04:04:57 AM
Hi,

We are unable to identify, how to add a menu on click the column header in datagrid.
In that menu there will be some sub menus also.

Please find the attachment image for the sample model.


Thanks and Regards
Pandu Ranga.


Title: Re: Datagrid: Filter Menu on click column header
Post by: aswzen on July 31, 2015, 04:23:24 AM

are you using extJs?
 
wrong forum  ;D


Title: Re: Datagrid: Filter Menu on click column header
Post by: rangaNadha on July 31, 2015, 04:31:02 AM
That is developed in extJs but we need to implement the same in our application using jquery easy ui.


Title: Re: Datagrid: Filter Menu on click column header
Post by: aswzen on July 31, 2015, 04:41:41 AM
there are no feature to do that, you can only achieve it by custom.

i once made custom like that by separately create a window to custom the table preview like the screenshot below..


Title: Re: Datagrid: Filter Menu on click column header
Post by: zolotoy on August 03, 2015, 06:16:49 AM
Can you please show your code that triggers a popup window when you click on the header?

Thanks


Title: Re: Datagrid: Filter Menu on click column header
Post by: aswzen on August 04, 2015, 06:18:28 PM
there are no custom code attached to the column header because it already atached to sort/unsort column by easyui..

i pop up the window by a button..


Title: Re: Datagrid: Filter Menu on click column header
Post by: zolotoy on August 04, 2015, 06:40:45 PM
So, you are attaching custom sorter or something?


Title: Re: Datagrid: Filter Menu on click column header
Post by: jmansur on August 05, 2015, 07:09:17 AM
Hi.

You neet to use the onHeaderContextMenu of datagrid.
I use this option for show and hide columns.

and change de code of menu basic.
http://www.jeasyui.com/demo/main/?plugin=Menu&theme=default&dir=ltr&pitem=

Regardssss


onHeaderContextMenu:
               // Muestro u Oculta columnas
               function(e, field){
                  e.preventDefault();
                  if (!cmenu){ createColumnMenu(); }
                  cmenu.menu('show', { left:e.pageX,top:e.pageY } );
JAVASCRIPT FUNCTION
        var cmenu;
   function createColumnMenu(){
      cmenu = $('<div/>').appendTo('body');
      cmenu.menu({
         onClick: function(item){
            if (item.iconCls == 'icon-check_16'){
               $('#tt').datagrid('hideColumn', item.name);
               cmenu.menu('setIcon', { target: item.target, iconCls: 'icon-ver_ocultar_16'   });
            } else {
               $('#tt').datagrid('showColumn', item.name);
               cmenu.menu('setIcon', {   target: item.target, iconCls: 'icon-check_16'   });
            }
         }
      });
      var fields = $('#tt').datagrid('getColumnFields');

      // Arranco de 1 para evitar que me proponga para ocultar la columna que muestra los nodos
      for(var i=0; i<fields.length; i++){
         var field = fields;
         var col = $('#tt').datagrid('getColumnOption', field);
         cmenu.menu('appendItem', { text: col.title,   name: field, iconCls: 'icon-check_16'   });
      }
   }   
},


Title: Re: Datagrid: Filter Menu on click column header
Post by: zolotoy on August 05, 2015, 07:37:44 AM
And which line of your code will popup w window as it's shown in the message above mine?


Title: Re: Datagrid: Filter Menu on click column header
Post by: jmansur on August 05, 2015, 07:56:20 AM
createColumnMenu();


Title: Re: Datagrid: Filter Menu on click column header
Post by: zolotoy on August 05, 2015, 07:58:41 AM
Which one?
Code:
function createColumnMenu(){
      cmenu = $('<div/>').appendTo('body');
      cmenu.menu({
         onClick: function(item){
            if (item.iconCls == 'icon-check_16'){
               $('#tt').datagrid('hideColumn', item.name);
               cmenu.menu('setIcon', { target: item.target, iconCls: 'icon-ver_ocultar_16'   });
            } else {
               $('#tt').datagrid('showColumn', item.name);
               cmenu.menu('setIcon', {   target: item.target, iconCls: 'icon-check_16'   });
            }
         }
      });