PDA

View Full Version : Grid column hide



Choleriker
28 Feb 2007, 3:53 PM
Hello,

the new grid col menu is cool. But makes it sence that the end user can hide all columns in a grid? And how to hide columns completely for the user on livetime, so the user cant reshow this column with the menu?

KimH
1 Mar 2007, 5:05 AM
It should be possible to remove all but the last column.

It would be great if we can set a flag for each column wether or not it can be hidden. Probably already in the code... I haven't checked :wink:

Choleriker
1 Mar 2007, 8:43 AM
wether or not it can be hidden. Probably already in the code... I haven't checked

No there isnt. The grid-view renders the column-show/hide menu only with checked or not, there isnt a way to hide a column completely.

My suggestion ist to add a property to the column-model where a row can be hidden completely from ui.

Animal
1 Mar 2007, 9:16 AM
You just wouldn't add add a ColumnModel config for a mapping to a Record field that you didn't want the UI to know about. That's the beauty of the Ext 1.0 model!

Choleriker
1 Mar 2007, 9:23 AM
You just wouldn't add add a ColumnModel config for a mapping to a Record field that you didn't want the UI to know about. That's the beauty of the Ext 1.0 model!

This sounds nice. But how to plug / unplug columns add runtime? This is the clou i want. In 0.44 alpha there was an method called reset() for the grid which has worked fine. Is there a way to add / remove columns at runtime dynamically?

thejoker101
1 Mar 2007, 9:57 AM
I agree that you shouldn't be able to remove all the columns, I guess I just don't see the point. Or at least allow a config option to leave one column remaining.

As for hiding columns, you can call setHidden(colindex) in the ColumnModel to hide it. Though, right clicking the header allows you to unhide it again. If you don't want that to be allowed, then I would think you wouldn't put it in the ColumnModel in the first place.

jack.slocum
1 Mar 2007, 10:28 AM
As for hiding the last column - I agree it's not very useful. It's on the list but low priority.

Brooksie
31 Oct 2008, 2:59 AM
I have a grid which I either want to include or not include at runtime - I thought I might be able to do this by adding each column to the column model array 1 by 1, and then wrapping the one I may or may not want to include inside and if clause - but this seems to cause an error.


this.colums = new Ext.grid.ColumnModel();
this.colums[0] = {
header: 'Entity',
sortable: true,
width: 250,
id: 'grid-entity-header',
dataIndex: 'entity',
summaryType: 'sub_total'
};
Error:
config is undefined
http://10.10.158.236/ans-dev/sbrooks/ui-sprint5/php/js/ext/ext-all-debug.js?last_modified=1219825582
Line 31732

Animal
31 Oct 2008, 3:41 AM
Build an Array in the usual way, then create a ColumnModel from it.

To have a hidden, and unshowable column use



hidden: true,
hideable: false


The hidden config hides it, the hideable config says whether to add it to the show/hide menu that the user sees.

So that column will then be under programmatic control only to show or hide it, not user control.

ravi_mura
25 Nov 2008, 11:37 PM
Hi,

I have some problem in building column model dynamically.
The grid renders and works fine.

The only problem is with the show/hide column menu, which keeps on changing each time I click on it. Some of the column names appear multiple times in the menu.

Anyone has faced such issue?

- Ravi

Condor
25 Nov 2008, 11:41 PM
The column menu is simply filled with all columns from the column model (except the ones with fixed:true or hideable:false).

Do you modify your column model?

ravi_mura
26 Nov 2008, 12:15 AM
Thanks for the response.
Yes, I do modify column model after rendering.

code looks somethign like:


//default headers


columnHeaders = [selectionModel, {


header: "Name",



tooltip: "Name",


dataIndex: 'configName',


renderer:Matrix.EndUserResults.renderConfigName,


css:'border-right: 1px solid #e8e8e8; padding-left: 0px; padding-right: 0px;',


width:160



},{


header: "Status",



tooltip: "Status",


dataIndex: 'configStatus',


css:'border-right: 1px solid #e8e8e8; padding-left: 0px; padding-right: 0px;',


align:"center",


width:80



}

];





//columnmodel

columnModel = new Ext.grid.ColumnModel(columnHeaders);



Later..... After render



Ext.each(perspectiveCoumns, function(r) {




columnHeaders.push({




id: r.id,


header: r.name,


ttooltip: r.name,


dataIndex: 'groupedComponents',


width:250,


css:'border-right: 1px solid #e8e8e8; padding-left: 0px; padding-right: 0px;',
renderer: renderComponents

});

});
columnModel.setConfig(columnHeaders);

can you see any loophole in this?

Animal
26 Nov 2008, 12:33 AM
Yuo probably need to reconfigure then.

Condor
26 Nov 2008, 12:44 AM
@Animal: No need to call grid.reconfigure(), colModel.setConfig() is just as good.

@ravi_mura: Are you sure your column ids are unique?

ravi_mura
26 Nov 2008, 1:01 AM
@Animal: No need to call grid.reconfigure(), colModel.setConfig() is just as good.

@ravi_mura: Are you sure your column ids are unique?


Yes, column ids are unique, I have even tried giving number sequence for column ids.

Do we have doc on how hide/show menu is created?
I think it is created everytime it is viewed, because i get different list each time
(without changing column model)

Animal
26 Nov 2008, 1:06 AM
Cool! I just noticed the event linkage. I'll update the docs to explain that this happens.

ravi_mura
26 Nov 2008, 1:23 AM
Eventhough the menu is created each time, it should not lead to duplicate items in the list. It doesn't seem to append to existing list also.
Only 3-4 items are duplicated each time.

ravi_mura
28 Jan 2009, 9:45 PM
I digged into ext lib and found out this:

When menu is created on 'beforeColMenuShow', items (column names) are added dynamically.

If some columns dont have ids, those column names are not added to the menu.

In my case, if you see code above, I havent given ids to first few columns. Also the for loop in dynamic rendering was asssigning duplicate ids, which i didnt notice earlier.

My problem was solved when i fixed these issues.