EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: saurabh on January 17, 2017, 03:10:35 AM



Title: Get JSON data for currently loaded tree grid
Post by: saurabh on January 17, 2017, 03:10:35 AM
Hello, I want to get currently loaded json data from tree grid(Don't want to call again same servlet to get data.). I tried to do like this as shown below but it doesn't work for me.
json data that i am loading is dynamic....!!

script
var allData=$('#tg').treegrid('getData');
alert("All data length: "+allData.length);
var jsonData=JSON.parse(allData);
alert("jsonData "+jsonData);



tree grid html
 <table id="tg" title="NCM-SCAR Creation Application" style="height:600px;width:100%;"
                data-options="
                    iconCls: 'icon-ok',
                    rownumbers: true,
                    animate: true,
                    collapsible: false,
                    fitColumns: true,
                    url: 'getNCMdataServlet',
                    method: 'get',
                    idField: 'id',
                    treeField: 'name',
                    pagination: true,
                    onExpand:function(row)
                    {
                       collpaseTillItemLevel(row,<%=expandRows %>);
                   
                    },
                   
                    checkbox:function (row)
                    {
                       if(row.chbx==1)
                       {
                       return true;
                       }
                       
                    },
                    onCheckNode:function(row,checked){
                   
                    verifyCheck(row,checked);
                       
                 
                   
                     },
                     onLoadSuccess:function()
                   {
                   collapseAllChilds()
                   },
                    pageSize: 10,
                    pageList: [10,20,50]
                ">
            <thead>







Title: Re: Get JSON data for currently loaded tree grid
Post by: stworthy on January 17, 2017, 08:17:51 AM
The 'getData' method does returns the loaded data.
Code:
var allData=$('#tg').treegrid('getData');
console.log(allData);