PDA

View Full Version : Grid's width with percentage is not working properly



AtulDawkhare
9 Apr 2012, 7:48 AM
Hi
I am using the "itscomponentcolumn" component to display Grid with select box.

Now I want to show the Grid column depending upon the condition.
i.e. say I have 5 columns , on certain condition I want to show 3 columns or 2 columns etc

So my queries is I want to the Grid width should get atomically adjusted, so that It will look nice.
but it is not working as expected.



grid = Ext.create('Ext.grid.Panel', {
id: 'GridId',
layout:'fit',
region:'center',
store: Add_People_Store,
enableColumnMove:false,
columns: CreateGridColumns(true,true,true,true,true,true),
height: '20%',
width: '100%',
renderTo: 'My_Div'
});


And my column Code is



xtype: 'itscomponentcolumn',
text : '<b>Project</b>',
sortable:false,
width: 125,
dataIndex: 'project',
items: function(value) {
return {
xtype: 'combobox',
store: [[0,'View Only'], [1,'View & Edit'], [2,'View,Edit & Delete'],[3,'No Access'],[4,'Custom']],
displayField: 'display',
valueField: 'value',
queryMode : 'local',
forceSelection:true,
id:'project',
width: 115,
listeners: {
change: function(comboField, newValue, oldValue, eOpts)
{
AssignToHiddenComponent(newValue,this.id);
},
afterrender: function(combo) {
var recordSelected = combo.getStore().getAt(0);
if(projectValue==undefined)
combo.setValue(recordSelected.get('field1'));
else
combo.setValue(projectValue);
}
}
};
}


i.e. when I show Grid with all Columns
33783
and When due to some condition, If i want o disabled some column, my Grid show like

33785

I want the extra space should get adjusted automatically.[i.e. shown in red above]

Please suggest what is wrong here.

scottmartin
9 Apr 2012, 8:58 AM
You have your grid in the center region with width: '100%', how does it know to change when you are telling it to use all 100%?

Regards,
Scott.

gaurav.kohli@yagnaiq.com
12 Apr 2012, 2:44 AM
Sorry to reply little late.

I didn't get you,Can you please suggest what is wrong here?

My requirement is.
1] Grid should have 100 % width, and when I am deleting any column remaining columns should get fit into the available are i.e. within '100%' So that it will not look odd.
But When I am trying to change the column width to '%' it didnt work.

So please suggest me what changes I need to do so that It will work Properly.

scottmartin
12 Apr 2012, 4:37 AM
Have you tried forceFit, and you can set your columns to use flex.

Regards,
Scott.

AtulDawkhare
12 Apr 2012, 5:41 AM
Thanks a lot it's working for me now.