我是ExtJS的新手。我采用了一些示例,并添加了通过单击某个链接向选项卡控件添加选项卡的功能。到现在为止还挺好。现在我想在新选项卡上加载一个ExtJS表。项(行,列)在服务器端的数据库中定义。在创建选项卡时,您能给我一些提示如何自动添加表格吗?
答案 0 :(得分:2)
Autoload非常适合从服务器端代码中提取HTML表格。这些数据是否会更新?如果是这样,您将需要重新加载整个HTML。我建议改用网格:
// tabPanel definitinon
{
xtype:"grid",
//tabId is a unique value created at the time of the tab
id:"general_props_status_grid_" + tabId,
ds: C.createStore({
storeId:"general_props_status_grid_" + tabId,
autoLoad:true
proxy: new Ext.data.HttpProxy({
//path to a serverside page that gerenates a JSON table contents
url: '?fuseaction=qry_statuses'
}),
reader: new Ext.data.JsonReader({
id: 'status_id',
root:'data'
}, [
{name: 'status_id'},
{name: 'name'}
]),
remoteSort: false
}),
columns:[{
header: "Status ID",
dataIndex: 'status_id',
width:20,
hidden:true,
sortable:true
},{
header: "Name",
dataIndex: 'name',
hideable:false,
renderer:function(val){
return "<span class='link'>" + val +"</span>"
},
width:150,
sortable:true
}],
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
loadMask: true,
listeners: {
activate:function(thisGrid){
//this will reload the grid each time this tab is selected
thisGrid.getStore().reload();
}
}
}
网格有很多选项,但上面的示例显示了通过回调自动更新网格。
答案 1 :(得分:0)