fuelux.tree-sampledata.js 915 B

12345678910111213141516171819202122232425262728
  1. var DataSourceTree = function(options) {
  2. this._data = options.data;
  3. this._delay = options.delay;
  4. }
  5. DataSourceTree.prototype.data = function(options, callback) {
  6. var self = this;
  7. var $data = null;
  8. if(!("name" in options) && !("type" in options)){
  9. $data = this._data;//the root tree
  10. callback({ data: $data });
  11. return;
  12. }
  13. else if("type" in options && options.type == "folder") {
  14. if("additionalParameters" in options && "children" in options.additionalParameters)
  15. $data = options.additionalParameters.children;
  16. else $data = {}//no data
  17. }
  18. if($data != null)//this setTimeout is only for mimicking some random delay
  19. setTimeout(function(){callback({ data: $data });} , parseInt(Math.random() * 500) + 200);
  20. //we have used static data here
  21. //but you can retrieve your data dynamically from a server using ajax call
  22. //checkout examples/treeview.html and examples/treeview.js for more info
  23. };