-
22 Feb 2008 6:18 AM #1
Feautre suggestion: TableLayout align/valign
Feautre suggestion: TableLayout align/valign
Hi there,
currently there's no possibility to align contents in table cells created via TableLayout cause the "bodyStyle" always is applied to the contained item instead of the cell itself.
I suggest to introduce
align
valign
tdStyle
as config options for table cell items. These would be applied directly to the table cell.
Here comes my code to apply these options:
I suggest to build in this feature directly into Ext.layout.TableLayout.Code:Ext.layout.TableLayout.prototype.renderItem = function(c, position, target){ if(c && !c.rendered){ var td=this.getNextCell(c); if (c.align) td.setAttribute("align",c.align); if (c.valign) td.setAttribute("valign",c.valign); if (c.tdStyle) td.setAttribute("style",c.tdStyle); c.render(td); } };
@ Jack / development team: I love your incredibly clear code!
-
25 Feb 2008 1:39 AM #2
And this piece of code works in Internet Explorer, too:
Code:Ext.layout.TableLayout.prototype.renderItem = function(c, position, target){ if(c && !c.rendered){ var td=this.getNextCell(c); var el=Ext.get(td); if (c.align) el.applyStyles("text-align:"+c.align); if (c.valign) el.applyStyles("vertical-align:"+c.valign); if (c.tdStyle) el.applyStyles(c.tdStyle); c.render(td); } };
-
15 Oct 2008 6:57 AM #3
this works great, thanks a lot! maybe should be moved to examples and extras?
-
15 Oct 2008 7:04 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Ext.layout.TableLayout already has a cellCls config option for items.
However, a cellStyle config option would be a nice addition, e.g.
Code:Ext.override(Ext.layout.TableLayout, { getNextCell : function(c){ var cell = this.getNextNonSpan(this.currentColumn, this.currentRow); var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1]; for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){ if(!this.cells[rowIndex]){ this.cells[rowIndex] = []; } for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){ this.cells[rowIndex][colIndex] = true; } } var td = document.createElement('td'); if(c.cellId){ td.id = c.cellId; } var cls = 'x-table-layout-cell'; if(c.cellCls){ cls += ' ' + c.cellCls; } td.className = cls; if(c.cellStyle){ Ext.DomHelper.applyStyles(td, c.cellStyle); } if(c.colspan){ td.colSpan = c.colspan; } if(c.rowspan){ td.rowSpan = c.rowspan; } this.getRow(curRow).appendChild(td); return td; } });
-
15 Oct 2008 7:22 AM #5
<span class="eeyore">Yes.... would be nice wouldn't it?...
http://extjs.com/forum/showthread.ph...561#post128561
</span>Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
25 Dec 2010 12:44 AM #6


Reply With Quote

