Home  >  Article  >  Web Front-end  >  Solution to the problem of dynamically loading data in EasyUI's treegrid component_jquery

Solution to the problem of dynamically loading data in EasyUI's treegrid component_jquery

WBOY
WBOYOriginal
2016-05-16 17:58:35935browse

After searching the treegrid source code and documents, I found that treegrid is extended from datagrid and tree. However, in the past, the reload method of datagrid was used to load query result data by adding parameters. However, treegrid only executed reload and could not load query results with parameters. It may be that Due to the restriction, the following code cannot load query results:

Copy code The code is as follows:

< table id='treegrid' class='easyui-treegrid' url='/User/List'>
$('#treegrid').treegrid('reload',{'name': 'mikel'});

So I went to the official forum to search for related issues and found a valuable post. I suddenly understood why we should rely on the treegrid component to query data asynchronously. Why not asynchronously first, and then What about loading the returned json data? The code is as follows:
Copy code The code is as follows:

function loadData()
{
$.post('/User/List',{name:'mikel'},function(data){
$('#treegrid').treegrid('loadData',data);
} ,'json');
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn