PDA

View Full Version : ExtJs4.2: Grid column visibility feature using external button to grid



offshoreteam
11 Jun 2013, 2:25 AM
We are trying to add grid column visibility feature to external button outside grid.

Problem:
Columns are populated properly but we are facing some issues related to nesting columns. If we check the checkbox for parent menu, the child menu's are not getting checked automatically. Also if we uncheck the parent menu the child menu's are not getting unchecked.


code:var menuList = grid.headerCt.getMenuItems();

Ext.create('Ext.Button', {
renderTo: 'spnCustomControl',
text: 'Columns',
menu: menuList
});

slemmon
12 Jun 2013, 8:20 PM
I'm afraid what you've posted is not enough to go on to help you move forward. I'm not sure based on your description (or the code snippet) what you're trying to do or where in your code you're getting stuck.

Can you elaborate?

offshoreteam
13 Jun 2013, 6:19 AM
We are trying to achieve grid columns show\hide functionality outside grid(on a button). For this, We have one button, clicking on button a list of all the column headers should appear through which user should be able to show\hide columns.

We are able to achieve this functionality using below code :


var menuList = grid.headerCt.getMenuItems(); Ext.create('Ext.Button', {
renderTo: 'spnCustomControl',
text: 'Columns',
menu: menuList
});


However, Above code is not working as expected if a grid has a column which has sub columns.(pls refer attached image headerGrouping.png)
It behaves incosistent for eg We have Architect as a header column and Name, City, Phone number as its sub columns. If user wants to hide Architect(which includes its sub columns) through unchecking checkbox near to Architect column then columns get hide, however checkboxes of the sub column remains checked.(Please see attached image gridColumnsVisibility.png).

slemmon
14 Jun 2013, 12:30 PM
It looks like it works ok in the example:
http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/build/KitchenSink/ext-theme-neptune/#grouped-header-grid

I suspect you'll need to inspect the source to see how that's being accomplished in the framework and see if you can export that functionality to your menu.