EasyUI Forum
May 14, 2024, 07:11:58 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tree component problem  (Read 3519 times)
mapner
Jr. Member
**
Posts: 63


View Profile
« on: July 05, 2017, 02:01:14 PM »

Hello,

Please, I need help. I'm testing the Tree component but nothing is showing

Code:
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" type="text/css" href="http://localhost:8080/rest-jui/static/js/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/rest-jui/static/js/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/rest-jui/static/js/themes/color.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/rest-jui/static/js/themes/mp.css">

<script type="text/javascript"  src="http://localhost:8080/rest-jui/static/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/locale/easyui-lang-es.js"></script>
<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/jquery.maskedinput-1.4.1.min.js"></script>

<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/mpjs.js"></script>
<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/plugins/DateFormatter/dateformatter.js"></script>
<script type="text/javascript" src="http://localhost:8080/rest-jui/static/js/jquery.blockUI.js"></script>

<script type="text/javascript">

$(function(){

$('#tt2').tree({
url: 'http://localhost:8080/rest-jui/rest/systree/todos',
method: 'GET'
});

});
</script>

</head>
<body >
<ul id="tt2"></ul>
</body>
</html>    



These data are returned from the server when I invoke it from the url  directly http://localhost:8080/rest-jui/rest/systree/todos

[{id: 1,text:'Node 1',state: 'closed',children:[{id: 11,text: 'Node 11'},{id: 12,text: 'Node 12'}]},{id: 2,text: 'Node 2', state: 'closed'}]

Thank for advance!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 07, 2017, 05:57:58 AM »

You may return a string instead of the JSON object. Please try to use the 'loadFilter' function to convert it to a JSON array before loading it.
Code:
$('#tt').tree({
loadFilter: function(data){
return eval(data)
}
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!