日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

ExtJS TreeGrid的使用方法

發布時間:2024/9/19 综合教程 35 生活家
生活随笔 收集整理的這篇文章主要介紹了 ExtJS TreeGrid的使用方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

假設您是第一次使用ExtJS的TreeGrid的話,我相信總會有一些小麻煩的,以下就來說一說ExtJS中TreeGrid的使用。

本人使用的ExtJS版本號為4.1.1,而且使用了MVC模式。假設不了解ExtJS的MVC模式的話我個認為還是有必要去學學的,
學完后你肯定會喜歡上的。
事實上在ExtJS中并沒有TreeGrid這么一個類,這個說法是從EasyUI中借用過來的,ExtJS中的TreeGrid功能已經合在了Ext.tree.Panel中。

TreeGrid顯示出來大概是這個樣子:

以下是這個樣例的源代碼:

View:

Ext.define("node.view.NodeListPanel", {
    extend : "Ext.tree.Panel",
    alias : "widget.nodelistpanel",
    title : "節點管理",
    columnLines : true,
    region: 'center',
    root:{
        id:'root',
        name:'節點管理',
        expanded:true
    },
    columns: [{
        xtype : 'treecolumn',
        header: '節點名稱',  dataIndex: 'name', sortable:false,flex:1
    }, {
        header: '節點編碼', dataIndex: 'code',align : 'center',sortable:false,150
    }, {
        header: '節點IP',  dataIndex: 'ip', align : 'center',sortable:false,150
    }, {
        header: '端口號', dataIndex: 'port',align : 'center',sortable:false,50
    }, {
        header: '節點描寫敘述', dataIndex: 'desc',align : 'center',sortable:false,200
    }],
    loadMask:{
        msg : '正在載入數據,請稍等...'
    },
    store : Ext.create('node.store.NodeStore'),
    //store : "NodeStore",
    renderTo: Ext.getBody()
});


Store:

Ext.define("node.store.NodeStore", {
    extend : 'Ext.data.TreeStore',
    //model : 'node.model.Node',//用model傳遞不了數據
    proxy : {
        type : 'ajax',
        url : 'data/NodeTree.json',
        reader : 'json',
        autoLoad : true
    },
    fields : [{
        name: 'id',
        type: 'string'
    }, {
        name: 'name',
        type: 'string'
    }, {
        name: 'code',
        type: 'string'
    }, {
        name: 'ip',
        type: 'string'
    }, {
        name: 'port',
        type: 'string'
    }, {
        name: 'desc',
        type: 'string'
    }]

});

NodeTree.json :

{
    "id":"root",
    "leaf":false,
    "name" : "root",
    "children":[{
        "id":"1",
        "leaf":true,
        "name" : "公安",
        "code" : 452363214,
        "ip" : "192.168.0.203",
        "port" : 8080,
        "desc" : "公安節點"
    }, {
        "id":"4",
        "leaf":true,
        "name" : "法院",
        "code" : 452364587,
        "ip" : "192.168.0.204",
        "port" : null,
        "desc" : "法院節點"
    }, {
        "id":"9",
        "leaf":true,
        "name" : "檢查院",
        "code" : 452312365,
        "ip" : "192.168.0.205",
        "port" : null,
        "desc" : "檢查院節點"
    }, {
        "id":"10",
        "leaf":false,
        "name" : "紀檢委",
        "code" : 45234596,
        "ip" : "192.168.0.235",
        "port" : null,
        "desc" : "紀檢委節點",
        "expanded":true,
        "children":[{
            "id":"2",
            "leaf":true,
            "name" : "測試節點",
            "code" : 45239658,
            "ip" : "192.168.0.255",
            "port" : null,
            "desc" : "測試節點"
        }]
    }]
}


Controller:

Ext.define('node.controller.NodeController', {
    extend:'Ext.app.Controller',
    init:function(){
        this.control({

        });
    },
    views: [
        'NodeListPanel'
    ],
    stores: [
        //"NodeStore"
    ],
    models: [
        //"Node"
    ]
});

app.js :

Ext.onReady(function(){
    Ext.Loader.setConfig({
        enabled : true
    });

    Ext.application({
        name : "node",
        appFolder : ".",
        launch : function() {
            Ext.create("Ext.container.Viewport", {
                layout : "border",
                items : [{
                    xtype : "nodelistpanel"
                }]
            });
        },
        controllers : [
            'NodeController'
        ]
    });
});

在這里有兩個非常奇怪的地方:
1. NodeListPanel指定Store時,不能直接配置成store:"NodeStore"讓其動態載入,而要直接創建出來,所以在Controller中不指定NodeStore也是能夠的
2. NodeStore不能直接指定Model。而應該配置其fields屬性取代,由于配置Model對TreeStore來說根本不起作用
以上兩點至于為什么會這樣,本人也沒有去深究,望高人直接指點。

另一個須要注意的地方就是一定要為TreePanel配置root屬性,否則無法顯示樹形

總結

以上是生活随笔為你收集整理的ExtJS TreeGrid的使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。