PDA

View Full Version : Adding Grid to ContentPanel


griffiti93
11-20-2006, 07:05 PM
I have a center region using BorderLayout. I would like to add a Grid to the center region through a ContentPanel. I've tried ContentPanel and GridPanel but cannot seem to get the Grid to auto size columns. Any ideas what I'm doing wrong?



_dh.append('app', {tag: 'div', id: 'order-list'});
var ordersGrid = new YAHOO.ext.grid.Grid('order-list', dm, cm);
ordersGrid.render();

var ordersPanel = new YAHOO.ext.GridPanel(ordersGrid, {title:'Orders', fitToFrame:true, closable: true});
_layout.beginUpdate();
_layout.add('center', ordersPanel);
_layout.endUpdate();

tryanDLS
11-20-2006, 07:27 PM
Don't specify width on your columnmodel entries

griffiti93
11-20-2006, 07:42 PM
I don't. :(


var columns = [
{header: 'ID', sortable: true},
{header: 'Date', sortable: true},
{header: 'Price', sortable: true, renderer: money},
{header: 'Status', sortable: true}
];

tryanDLS
11-20-2006, 07:49 PM
Hmm.. My example built a ContentPanel instead of GridPanel and then just rendered the grid into another div inside the contentpanel div. Not sure why there would be a difference, unless it's an issue of not specifying height/width on the grid container via CSS.

jack.slocum
11-21-2006, 06:37 AM
I don't see autoSizeColumns set to true or a call to grid.getView().autoSizeColumns(). Is that somewhere else?

griffiti93
11-23-2006, 09:50 AM
Thanks, Jack. That worked for me. I put that line of code in the callback handler to the data model load() method. Once the data is loaded, the grid adjusts the columns nicely inside the content panel.

When I resize the splitter on an east or west panel, or collapse an east or west panel, the grid doesn't readjust. Is there a listener I can wire up for that?

jack.slocum
11-23-2006, 02:18 PM
Yep. Take a look at at the events under:

http://www.yui-ext.com/docs/#output/YAHOO.ext.LayoutRegion.html