title: Kendo UI Treeview and JSON
body: <p>So I want to create a Tree with kendo UI treeview item and bind it to a remote Hierarchical Data Source being a JSON file.</p>
  
  <p>I want the resulting tree to be something like:</p>
  
  <p>(Vehicles)</p>
  
  <p>--(Cars)</p>
  
  <p>----FM-1100</p>
  
  <p>----FM-4200</p>
  
  <p>--(Bikes)</p>
  
  <p>----FM-3100</p>
  
  <p>(Personnel)</p>
  
  <p>--(Clients)</p>
  
  <p>----GH-3000</p>
  
  <p>--(VIPs)</p>
  
  <p>----GH-3100</p>
  
  <p>PS. Names in () are supposed to be something like folders containing their "children"</p>
  
  <p>I've checked the documentation about all the above in the kendo ui website but I'm a bit confused with the whole callback function the treeview uses to load the deeper stages everytime you expand an item in the tree..</p>
  
  <p>Let's take the example in kendo documentation for instance:</p>
  
  <pre><code>var homogeneous = new kendo.data.HierarchicalDataSource({
  transport: {
      read: {
          url: "http://demos.kendoui.com/service/Employees",
          dataType: "json"
      }
  },
  schema: {
      model: {
          id: "EmployeeId",
          hasChildren: "HasEmployees"
      }
  }
  });
  
  $("#treeview").kendoTreeView({dataSource: homogeneous});
  </code></pre>
  
  <p>JSON sample data:</p>
  
  <pre><code>    {
  "employees": [
  {"EmployeeId":2,"FullName":"Andrew Fuller","HasEmployees":true,"ReportsTo":null},
  {"EmployeeId":3,"FullName":"Carl Jenkins","HasEmployees":true,"ReportsTo":null},
  {"EmployeeId":4,"FullName":"Aston Miller","HasEmployees":false,"ReportsTo":2},
  {"EmployeeId":5,"FullName":"Damon Sherbands","HasEmployees":false,"ReportsTo":2},
  {"EmployeeId":6,"FullName":"Dariel Hanks","HasEmployees":true,"ReportsTo":null},
  {"EmployeeId":7,"FullName":"Jason Jackson","HasEmployees":false,"ReportsTo":3},
  {"EmployeeId":8,"FullName":"Reylen Scribbs","HasEmployees":false,"ReportsTo":6}
  ]
  }
  </code></pre>
  
  <p>So,I have to setup a rest server on "http://demos.kendoui.com/service/Employees" that accepts a GET from the tree which provides the "EmployeeId" and then does a search inside the file and returns those who "ReportTo" the "EmployeeId" recieved...??
  And what happens the firt time the tree wants to show the initial nodes?</p>
  
  <p>Something like:</p>
  
  <pre><code>@Path("/Employees")
  @GET
  @Produces(MediaType.TEXT_HTML)
  public String returnEmployees(@QueryParam("EmployeeId") int accID) {
      //search the employees.json
      return "&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;pre&gt;" + searchResultsString + "&lt;/pre&gt;&lt;/body&gt;";
  }
  </code></pre>
  
  <p>How do I search efficiently a JSON file and return all the results in a String?
  Or if all these are wrong can someone help me understanding all the GET and the callback stuff?Maybe it does have to do with jsonp I've heard about?A bit lost here..</p>
  
  <p>Thanks in advance</p>