3

隣接モデルからデータを読み取るために、一般的な JavaScript ツリー ビュー (jstree、dynatree...) を設定できますか? classId、ClassName、ClassType、ParentClassId を持つテーブルがあるとします。ダイナツリーなどのデータを取得するにはどうすればよいですか? dyna ツリーが期待する json を考慮すると、以下のようになるはずです

        {title: "Class1"},
        {title: "Class2", isFolder: true,
            children: [
                {title: "Class4"},
                {title: "Class5"}
            ]
        },
        {title: "Class3"}

バックエンドでlinq to sqlを使用してasp.net asmx Webサービスを使用しています

4

1 に答える 1

2

ノードをオンデマンドでロードするために必要な唯一のことは、子ノードがオンデマンドでロードされるノードに "state" : "closed" を追加することです。

必要なすべての属性classId, ClassName,ClassType,ParentClassIdをノードにアタッチして、ajax 経由で渡すことができます。あなたのコード

"json_data": {
      //elements to be displayed on the first load
      //everything with state = closed will be populated via ajax. 
      //         Note the ajax arguments

    "data": [{"data":'Class 1',
              "attr":{"id":'kit1',
                      "ClassName":"ClassName",
                      "classId":"classId"},
              "state" : "closed"},
             {"data":'Class 2',
              "attr":{"id":'kit2',
                      "ClassName":"ClassName",
                      "classId":"classId"},
              "state" : "closed"}
            ],
    "ajax" : {
        url : "http://localhost/introspection/introspection/product",
        data : function(n) {
                 return {
                   "classId":$.trim(n.attr('classId')),
                   "ClassName":$.trim(n.attr('ClassName')),
                 }
               }
    }
 }
于 2012-01-26T22:14:03.060 に答える