简体   繁体   中英

How to add new row to a html table in ExtJS

您好,我已经使用常规表格和javascript在表格末尾添加新行,有人可以帮助我在表格末尾添加包含html元素的新行吗?

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.net/chrisramakers/xG3wq/

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

If you are dealing with a more complicated 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.com/deploy/dev/docs/?class=Ext.DomHelper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM