代码之家  ›  专栏  ›  技术社区  ›  esskar

在动态添加的选项卡中添加表

  •  1
  • esskar  · 技术社区  · 16 年前

    我对extjs还比较陌生。我采用了一些示例,并添加了通过单击某个链接向选项卡控件添加选项卡的功能。到现在为止,一直都还不错。现在,我想将一个extjs表加载到新选项卡的上。项目(行、列)在服务器端的数据库中定义。您能给我一些提示吗?在创建选项卡时如何自动添加表?

    2 回复  |  直到 9 年前
        1
  •  2
  •   Mark Porter    16 年前

    自动加载很适合从服务器端代码中提取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();
                }
            }
        }
    

    网格有很多选项,但是上面的例子显示了通过回调自动更新网格。

        2
  •  0
  •   esskar    16 年前

    好的,我做了一些进一步的阅读,我认为Autoload属性在这里帮助了我很多。 我从这里走。