admin管理员组

文章数量:1417070

Hello I have worked with regular tables and javascript to add new rows at the end of table, could someone help me out with adding new row containing html elements at the end of table?

Hello I have worked with regular tables and javascript to add new rows at the end of table, could someone help me out with adding new row containing html elements at the end of table?

Share Improve this question asked Mar 15, 2011 at 14:21 machamacha 7,49719 gold badges65 silver badges85 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

The easiest way is with an Ext.Template

var tpl = new Ext.Template(
    '<tr>',
        '<td>{0}</td>',
    '</tr>'
);
tpl.append('myTable', [ Ext.id() ]);

Check a working example here: http://jsfiddle/chrisramakers/xG3wq/

Updated example:
http://jsfiddle/chrisramakers/ZcQAX/

If you are dealing with a more plicated dom insert you might consider using a template created using Ext.DomHelper shown below.

var tpl = Ext.DomHelper.createTemplate({
    tag: 'tr', children: [{
        tag: 'td', html: '{0}'
    }]
});
tpl.append('myTable', [ Ext.id() ]);

http://dev.sencha./deploy/dev/docs/?class=Ext.DomHelper

本文标签: javascriptHow to add new row to a html table in ExtJSStack Overflow