Tree 如何在qooxdoo中将树绑定到模型?它应该有什么格式?

Tree 如何在qooxdoo中将树绑定到模型?它应该有什么格式?,tree,qooxdoo,Tree,Qooxdoo,我一直在谷歌上搜索,但没有任何帮助 我想知道如何将树与模型或商店绑定,我甚至不知道哪一个更合适(http://manual.qooxdoo.org/1.6.x/pages/data_binding/data_binding.html) 我有一个服务,它从数据库中获取数据并将数据保存在它的存储中 this.__store = new qx.data.store.Json(url, delegate); this.__store.bind("model", this, "testData"); 服

我一直在谷歌上搜索,但没有任何帮助

我想知道如何将树与模型或商店绑定,我甚至不知道哪一个更合适(http://manual.qooxdoo.org/1.6.x/pages/data_binding/data_binding.html)

我有一个服务,它从数据库中获取数据并将数据保存在它的存储

this.__store = new qx.data.store.Json(url, delegate);
this.__store.bind("model", this, "testData");
服务更新后,将发送一个事件,我正在收听:

  service.addListener("changeTestData", function(e) {
    this.debug(qx.dev.Debug.debugProperties(e.getData()));
    var tree = main.tree;
  }, this);
我不知道这样做是否正确。我想不会,但我不知道如何将模型/服务/存储绑定到树上才能工作

我的树:

    var tree = this.tree = new qx.ui.tree.Tree().set({
      width : 200,
      height : 400
    });
谢谢

更新: 还是不行。。它只显示一个项目,下面没有标签,我无法打开它查看其子项。错误:“Uncaught qx.core.AssertionError:错误” 我的数据格式:

[{_id:3423, title:"asdad", kids: []}] and so on...
-index(0): 
-- title: abc
-- _id: 4f4cea3e4b58dffc04000001
-- kids: 

-index(1): 
-- title: abc
-- _id: 4f4cea3e4b58dffc04000002
-- kids: ---index(0): 
---- title: abc
---- _id: 4f4cea3e4b58dffc04000001
---- kids: 
这是我的代码:

  var url = "http://127.0.0.1:8000/";
  var delegate = { 
    configureRequest : function(request) { 
      request.set({ 
        "method"      : "POST", 
        "requestData" : { 
          "serviceToUseOnServer" : "articles"
        } 
      }); 
    }, 
  };

  var status = new qx.ui.basic.Label("Loading...");
  var store = new qx.data.store.Json(url, delegate);
  store.bind("state", status, "value");

  var tree = new qx.ui.tree.Tree().set({
    width : 200,
    height : 400
  });
  var controller = new qx.data.controller.Tree(null, tree, "kids", "title");
  store.bind("model", controller, "model");

  main.add(tree, {top: 50, left: 200});
  main.add(status, {top: 50, right: 200});

  store.addListener("loaded", function(e) {
    // now I can't even reach this point. the error spawns and this is not called..
    debugger;
    var root = tree.getRoot();
    // tree.getRoot().setOpen(true);
    // gives me an error because root is null
    this.debug(qx.dev.Debug.debugProperties(e.getData()));
  }, this);

交叉发布到qooxdoo用户列表

我为你的问题找到了一个很好的例子:

在这里,您可以看到如何将JSON存储绑定到TreeController

在演示浏览器中,您将发现更多示例


编辑:请检查事实,您的JSON文件中有一个根节点。我们示例的JSON文件包含一个根节点。这将解释在代码片段中根节点为空的原因。

谢谢(:但我无法让它工作..我已更新了我的问题。请检查您的JSON文件中是否有根节点。我们示例中的JSON文件包含根节点。这将解释为什么在您的代码段中根节点为空。是的,现在我认为我的数据格式不正确:我有一个数组而不是根项。但我不知道如何获取使用node.js、mongodb和mongooseNow,我明白了:我只查询根项目和它已经在其中的其他项目。谢谢你可能会从中得到一些启发