4myGod
30 Sep 2009, 2:57 AM
Ok, so I have a table:
<table id='log-list'>
</table>
I want to add thead with a tr:
Ext.DomHelper.append('log-list', {tag: 'thead', children:
{tag: 'tr', children: [
{tag: 'th', html: 'Reinforcements'},
{tag: 'th', html: 'Conquered Territories'},
{tag: 'th', html: ''}
]}
});
Now then I want to add the tbody:
Ext.DomHelper.append('log-list', {tag: 'tbody'});
Now though I want to do a for, and in each part of the for I want to add th's to the thead and rows to the tbody.
I tried giving them variables like:
var tableBody = Ext.DomHelper.append('log-list', {tag: 'tbody'});
then adding:
var tableRow = Ext.DomHelper.append(tableBody, {tag: 'tr',cls: even, children: [
{tag: 'td', cls: 'reinforcements', html: logStats[p].reinforcements},
{tag: 'td', cls: 'conquered', html: logStats[p].conquered},
{tag: 'td', cls: 'lib gray', html: 'Troops Lost in Battle:'}
]});
I obviously have no idea what I am doing. I have read the API many times, but I don't get what it means:
* Appends the passed element(s) to this element
* @param {String/HTMLElement/Array/Element/CompositeElement} el
* @return {Ext.Element} this
*/
appendChild: function(el){
return GET(el).appendTo(this);
},
So how do I assign an element to a var as I create (so I don't need an id for it) and then appendChildren to it?
<table id='log-list'>
</table>
I want to add thead with a tr:
Ext.DomHelper.append('log-list', {tag: 'thead', children:
{tag: 'tr', children: [
{tag: 'th', html: 'Reinforcements'},
{tag: 'th', html: 'Conquered Territories'},
{tag: 'th', html: ''}
]}
});
Now then I want to add the tbody:
Ext.DomHelper.append('log-list', {tag: 'tbody'});
Now though I want to do a for, and in each part of the for I want to add th's to the thead and rows to the tbody.
I tried giving them variables like:
var tableBody = Ext.DomHelper.append('log-list', {tag: 'tbody'});
then adding:
var tableRow = Ext.DomHelper.append(tableBody, {tag: 'tr',cls: even, children: [
{tag: 'td', cls: 'reinforcements', html: logStats[p].reinforcements},
{tag: 'td', cls: 'conquered', html: logStats[p].conquered},
{tag: 'td', cls: 'lib gray', html: 'Troops Lost in Battle:'}
]});
I obviously have no idea what I am doing. I have read the API many times, but I don't get what it means:
* Appends the passed element(s) to this element
* @param {String/HTMLElement/Array/Element/CompositeElement} el
* @return {Ext.Element} this
*/
appendChild: function(el){
return GET(el).appendTo(this);
},
So how do I assign an element to a var as I create (so I don't need an id for it) and then appendChildren to it?