1
我接收該數據並轉化爲json
格式後,如下所示:爲什麼treeview控件不能正確加載數據?
[{"id":"2","text":"ALCOHOL CONSUMPTION","parent":"1"},{"id":"9","text":"MARITAL STATUS","parent":"1"},{"id":"13","text":"Recreational drug use","parent":"1"},{"id":"14","text":"OCCUPATION","parent":"1"},{"id":"16","text":" 1 child","parent":"1"},{"id":"17","text":" 2/3/4/5/6 children","parent":"1"},{"id":"18","text":"Activities","parent":"1"},{"id":"27","text":"Tobacco Use","parent":"1"},{"id":"37","text":"SocHx Template","parent":"1"}]
目前上述json
數據是在視圖
@{
var j2 = JsonConvert.SerializeObject(allparents);
}
和j2
具有上述json
。 json
數據可以作爲expected.When我想未來的數據綁定到jstree
控制它不會添加節點正確
這裏是我的jQuery代碼綁定數據
@section Scripts{
<script src="Scripts/jstree.min.js"></script>
<script>
$(document).ready(function() {
$('#Div_jstree').jstree(
{
"json_data": { "data": '@j2' },
"plugins": ["themes", "json_data"]
}
);
});
</script>
}
//the below is the generated HTML copied from chrome elements option
<table>
<tbody><tr>
<td>
<div id="Div_jstree" class="jstree jstree-1 jstree-default jstree-leaf" role="tree" aria-multiselectable="true" tabindex="0" aria-activedescendant="j1_loading" aria-busy="false"><ul class="jstree-container-ul jstree-children" role="group"></ul></div>
</td>
<td>
<div id="Div_txta"></div>
</td>
<td>
<label id="utctime"></label>
</td>
</tr>
</tbody></table>
,你只能看到一些地方jstree
控件已加載,但我的數據在哪裏?
這是什麼網頁的HTML源代碼渲染後?有沒有可能剃刀分析器不夠聰明,以攔截你所擁有的「@ j2」,並且保持原樣? –