jsTree,JSON和MVC3对象。如何构建数据 [英] jsTree, JSON and MVC3 objects. How to structure data

查看:284
本文介绍了jsTree,JSON和MVC3对象。如何构建数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩JsTree一点,MVC3。我可以成功调用MVC3方法,并取回JSON加载基本JsTree这样我就可以做的很基础知识。我不明白的是更复杂的数据结构来使用主要是为了等待做额外的数据,我需要的节点,也越来越树上作用于一些数据。

I have been playing with JsTree a little and MVC3. I can successfully call MVC3 methods and get back JSON to load a basic JsTree so i can do the very basics. What i don't understand is the more complicated data structure to use mostly to do wait extra data i need on nodes and also getting the tree to act on some of that data.

我的数据是
NodeText(字符串) - 要显示的文字

My data is NodeText (string) - text to display

ItemStatus(枚举) - 用于设置树的颜色等。

ItemStatus (enum) - Used to set colors etc on tree

的ItemType(枚举) - 控制什么可以拖放和到什么

ItemType (enum) - controls what can be dragged and dropped and onto what

RelatedIDs(列表ID是一个结构如下所述) - 当一个项目被删除使用

RelatedIDs (List ID is a struct described below) - used when an item is dropped

PrimaryItemID(ID,是一个结构) - 用于右键菜单和DB物品识别和离队项目RelatedIDs应用信息

PrimaryItemID (ID and is a struct) - used for right click menu and DB item identification and applying info for RelatedIDs from dropped item.

SecondaryItemID(ID,是一个结构) - 用于右键菜单和DB物品识别和离队项目RelatedIDs应用信息

SecondaryItemID (ID and is a struct) - used for right click menu and DB item identification and applying info for RelatedIDs from dropped item.

ID struct is
ID (long) 
IDType (enum)

这是我的阅读我所理解的JSON数据布局可能已经改变,以及出现过的属性数据和元数据,但我不是我应该去的地方,我应该创造什么MVC3模型对象序列化此数据成JSON很清楚树能理解。我真的想要得到的基础数据结构在第一时间,所以我不必重写code一堆。

From my reading i understand the JSON data layout may have changed as well as there been attribute data and meta data but i am not very clear on what should go where and what MVC3 model object i should create to serialize this data into JSON the tree can understand. I really want to get the base data structure right the first time so i don't have to rewrite a heap of code.

如果我走了所有必需的信息出来让我知道。

If i have left any required info out let me know.

推荐答案

这是我一直在使用JSTree的数据模型。你将不得不把它放在JSON形式。

This is the data model I have been using for JSTree. You will have to put it in json form.

node.data.attr.href          <a> tag within <li> href
              .other-a-attr  any other attribute you want on the <a>
         .title              visible title of node  
         .icon               optional image_file for icon
    .state                   controls icon, "open", "closed" or "" = default
    .arrt.id                 node id on the <li>
         .nType              type_attr for UI and types plug ins - MUST SET using type_attr in Types plugin default is ref
         .title              node title (not visible)
         .other-li-attr      any other attritubes you want on the <li> 

我不得不同意JSTree有一个非常陡峭的学习曲线,并得到了这一点的文档是很不容易的为我们newbees。

I have to agree JSTree has a very steep learning curve and getting this out of the documentation is not at all easy for us newbees.

我现在还不能确定是什么node.arrt.title的。这是不是你在树中看到标题。 node.data.title是一个显示在树中。

I am still not sure what node.arrt.title is for. It is not the title you see in the tree. node.data.title is the one that shows in the tree.

有可能是别人,我还没有想出呢。让我知道如果你的数字出来。

There may be others that I have not figured out yet. Let me know if you figure them out.

这篇关于jsTree,JSON和MVC3对象。如何构建数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆