• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
    當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

    ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore

    來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 22:36:12
    文檔

    ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore

    ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore:從數(shù)據(jù)庫(kù)獲取構(gòu)造樹(shù)結(jié)構(gòu)是ExtJS TreePanel的核心技術(shù),常用方法是TreeStroe里配置proxy,這種方式的root成了一個(gè)不受控制的節(jié)點(diǎn)。 TreeStroe的root實(shí)際是一個(gè)層疊json數(shù)據(jù),大部分情況是直接寫(xiě)一些簡(jiǎn)單數(shù)據(jù),但在實(shí)際應(yīng)用中必定是要從數(shù)據(jù)庫(kù)讀取的。我的方法
    推薦度:
    導(dǎo)讀ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore:從數(shù)據(jù)庫(kù)獲取構(gòu)造樹(shù)結(jié)構(gòu)是ExtJS TreePanel的核心技術(shù),常用方法是TreeStroe里配置proxy,這種方式的root成了一個(gè)不受控制的節(jié)點(diǎn)。 TreeStroe的root實(shí)際是一個(gè)層疊json數(shù)據(jù),大部分情況是直接寫(xiě)一些簡(jiǎn)單數(shù)據(jù),但在實(shí)際應(yīng)用中必定是要從數(shù)據(jù)庫(kù)讀取的。我的方法

    從數(shù)據(jù)庫(kù)獲取構(gòu)造樹(shù)結(jié)構(gòu)是ExtJS TreePanel的核心技術(shù),常用方法是TreeStroe里配置proxy,這種方式的root成了一個(gè)不受控制的節(jié)點(diǎn)。

    TreeStroe的root實(shí)際是一個(gè)層疊json數(shù)據(jù),大部分情況是直接寫(xiě)一些簡(jiǎn)單數(shù)據(jù),但在實(shí)際應(yīng)用中必定是要從數(shù)據(jù)庫(kù)讀取的。我的方法是先用Ext.Ajax.request獲取root數(shù)據(jù)形成TreeStroe。定義一個(gè)全局的TreeStroe名字是mTreeStore,用Ext.Ajax.request獲得root數(shù)據(jù)。TreeStoreRefresh函數(shù)與此類似,將mTreeStore的root換為新值。TreePanel的rootVisible屬性必須為true,增加一個(gè)節(jié)點(diǎn)單擊事件顯示節(jié)點(diǎn)的信息。

    var mTreeStore = null;
    Ext.Ajax.request({
     async: false,
     url: '/api/BasicData_API/GetBasicTablesTreeSource',
     method: 'get',
     success: function (response, options)
     {
     var TreeRoot = Ext.decode(response.responseText);
     mTreeStore = Ext.create('Ext.data.TreeStore',
     {
     root: TreeRoot
     });
     },
     failure: function (response, options)
     {
     //var responseArray = Ext.decode(response.responseText);
     Ext.Msg.alert('服務(wù)器錯(cuò)誤', '數(shù)據(jù)處理錯(cuò)誤原因:\n\r' + response.responseText);
     }
    });
    
    function TreeStoreRefresh()
    {
     Ext.Ajax.request({
     async: false,
     url: '/api/BasicData_API/GetBasicTablesTreeSource',
     method: 'get',
     success: function (response, options)
     {
     var TreeRoot = Ext.decode(response.responseText);
     if (mTreeStore != null)
     {
     mTreeStore.setRoot(TreeRoot);
     }
     },
     failure: function (response, options)
     {
     //var responseArray = Ext.decode(response.responseText);
     Ext.Msg.alert('服務(wù)器錯(cuò)誤', '數(shù)據(jù)處理錯(cuò)誤原因:\n\r' + response.responseText);
     }
     });
    }
    
    Ext.define('TreeToolbarCls', {
     extend: 'Ext.toolbar.Toolbar',
     padding:'0 0 0 0',
     items: [{
     text: '刷新',
     iconCls: 'refresh',
     handler: TreeStoreRefresh,
     height: 30,
     width: 65
     }]
    });
    
    Ext.define('U1TreeCls',
    {
     extend: 'Ext.tree.Panel',
     xtype: 'U1Tree_xtype',
     //title: '基礎(chǔ)數(shù)據(jù)字典',
     rootVisible: true,
     width: 300,
     store: mTreeStore,
     scrollable: true,
     tbar:Ext.create('TreeToolbarCls'),
     listeners:
     {
     itemclick: NodeClick
     }
    });
    
    function NodeClick(node, record, item, index, e, eOpts)
    {
     if (typeof (record.data) == "undefined")
     {
     return;
     }
     var message = Ext.String.format('Level={0}<br/>state={1}', record.data.Level, record.data.state);
     Ext.Msg.alert("節(jié)點(diǎn)信息", message);
    }
    

    下面是后臺(tái)C#代碼

    定義一個(gè)TreeNode類,包含TreePanel節(jié)點(diǎn)固有的一些屬性,也可以任意擴(kuò)充,利用這個(gè)可以自定義許多附加數(shù)據(jù),如我在里面定義Level表示節(jié)點(diǎn)的級(jí)別。

     [Authorize]
     [RoutePrefix("api/BasicData_API")]
     public class BasicData_APIController : ApiController
     {
     [Route("GetBasicTablesTreeSource")]
     public HttpResponseMessage GetBasicTablesTreeSource(string condition = null)
     {
     List<TreeNode> lstF = new List<TreeNode>();
     ZydAdonet z = ZydAdonet.Instance();
     string s1 = "select TableName,title from BaseDataTables order by TableName";
     string sqltext = s1;
     DataTable dt1;
     string ErrMes;
     z.Sql2DTReadOnly(s1, out dt1, null, out ErrMes);
     TreeNode tnd;
     foreach (DataRow drx in dt1.Rows)
     {
     tnd = new TreeNode
     {
     id = drx["TableName"].ToString(),
     text = drx["title"].ToString(),
     Level = 1,
     iconCls = "table_6",
     state = drx["TableName"].ToString() + " OK",
     leaf = true
     };
     lstF.Add(tnd);
     }
     TreeNode root = new TreeNode
     {
     text = "基礎(chǔ)數(shù)據(jù)字典",
     expanded = false,
     iconCls = "folder_close",
     Level = 0,
     state = "RootOfTree",
     leaf = true
     };
     if (lstF.Count > 0)
     {
     root.expanded = true;
     root.leaf = false;
     root.iconCls = "folder_open";
     root.children = lstF;
     }
    
     string JsonStr;
     JsonStr = JsonConvert.SerializeObject(root);
     HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value");
     response.Content = new StringContent(JsonStr, Encoding.GetEncoding("UTF-8"), "application/json");
     response.Headers.CacheControl = new CacheControlHeaderValue()
     {
     MaxAge = TimeSpan.FromMinutes(10)
     };
     return response;
     }
     }
    
     internal class TreeNode
     {
     public string id { get; set; }
     public string text { get; set; }
     public string iconCls { get; set; }
     public string state { get; set; }
     public bool leaf { get; set; }
     public int Level { get; set; }
     public bool expanded { get; set; }
     public List<TreeNode> children { get; set; }
     }
    
    

    在NodeClick函數(shù)中斷可以監(jiān)視到更多的信息:

    最后的運(yùn)行效果:

    然后更改數(shù)據(jù)表里的數(shù)據(jù),點(diǎn)“刷新”就實(shí)現(xiàn)了TreePanel節(jié)點(diǎn)的刷新。

    聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore

    ASP.NET MVC異步獲取和刷新ExtJS6 TreeStore:從數(shù)據(jù)庫(kù)獲取構(gòu)造樹(shù)結(jié)構(gòu)是ExtJS TreePanel的核心技術(shù),常用方法是TreeStroe里配置proxy,這種方式的root成了一個(gè)不受控制的節(jié)點(diǎn)。 TreeStroe的root實(shí)際是一個(gè)層疊json數(shù)據(jù),大部分情況是直接寫(xiě)一些簡(jiǎn)單數(shù)據(jù),但在實(shí)際應(yīng)用中必定是要從數(shù)據(jù)庫(kù)讀取的。我的方法
    推薦度:
    標(biāo)簽: ASP.NET tree extjs
    • 熱門焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 精品综合久久久久久97超人| 免费人欧美日韩在线精品| 97热久久免费频精品99| 尤物国产在线精品福利一区| 综合国产精品第一页| 亚洲色精品vr一区二区三区| 久久99国产精品尤物| 高清在线亚洲精品国产二区| 亚洲愉拍99热成人精品热久久 | 国产精品人人做人人爽| 99在线精品视频| 九九精品成人免费国产片| 久久精品欧美日韩精品| 最新国产精品精品视频| 国产亚洲精品成人a v小说| 四虎精品成人免费视频| 久久国产精品99国产精| 欧美人与性动交α欧美精品| 国产精品99久久久久久猫咪| 国产精品一久久香蕉产线看| 九色精品视频在线观看| 国产精品186在线观看在线播放| 国产精品免费看久久久香蕉| 久久久久夜夜夜精品国产| 久夜色精品国产一区二区三区| 精品人无码一区二区三区| 国产精品免费久久久久影院| 久久r热这里有精品视频| 国产成人无码久久久精品一| 国产精品视频一区二区三区无码 | 无码精品久久久天天影视| 国产精品你懂的| 成人国内精品久久久久一区 | 少妇人妻精品一区二区三区| 综合国产精品第一页| 亚洲爆乳精品无码一区二区三区| 久久精品国产91久久麻豆自制| 69SEX久久精品国产麻豆| 国产精品日本欧美一区二区| 久久777国产线看观看精品| 欧美精品免费在线|