jQuery MiniUI

 找回密码
 立即注册
查看: 3108|回复: 5

关于mini-outlooktree加载服务返回json数据的问题 [复制链接]

Rank: 6Rank: 6

发表于 2020-3-15 21:57:10 |显示全部楼层
服务器返回的JSON数据是:
{
code:200,
msg:"OK",
data:[
        {id: "user", text: "用户管理"},
               
        {id: "lists", text: "Lists", pid: "user" },
                       
        {id: "datagrid", text: "DataGrid", pid: "lists"},                       
        {id: "tree", text: "Tree" , pid: "lists"},
        {id: "treegrid", text: "TreeGrid " , pid: "lists"},
               
        {id: "layouts", text: "Layouts", pid: "user"},
               
        {id: "panel", text: "Panel", pid: "layouts"},
        {id: "splitter", text: "Splitter", pid: "layouts"},
        {id: "layout", text: "Layout ", pid: "layouts"},
               
        { id: "right", text: "权限管理"},
               
        {id: "base", text: "Base",  pid: "right" },
                               
        {id: "ajax", text: "Ajax", pid: "base"},
        {id: "json", text: "JSON", pid: "base"},
        {id: "date", text: "Date", pid: "base"},
               
        {id: "forms", text: "Forms", pid: "right"},
                               
        {id: "button", text: "Button", pid: "forms"},
        {id: "listbox", text: "ListBox", pid: "forms"},
        {id: "checkboxlist", text: "CheckBoxList", pid: "forms"},
        {id: "radiolist", text: "RadioList", pid: "forms"},
        {id: "calendar", text: "Calendar", pid: "forms"}                               
]
}
真正的菜单数据是在data下,请教一下,在客户端的mini-outlooktree下应该怎么设置,才能正常加载菜单数据啊?

  1. <div id="leftTree" class="mini-outlooktree" url="../data/outlooktree.txt" onnodeclick="onNodeSelect"
  2.                     textField="text" idField="id" parentField="pid"            
  3.                 >
  4.                 </div>
复制代码


Rank: 8Rank: 8

发表于 2020-3-16 10:13:41 |显示全部楼层
本帖最后由 felt 于 2020-3-16 10:15 编辑

dataField="data"默认就是data字段,如果不是data字段要设置成你的字段。

Rank: 6Rank: 6

发表于 2020-3-17 15:26:50 |显示全部楼层
felt 发表于 2020-3-16 10:13
dataField="data"默认就是data字段,如果不是data字段要设置成你的字段。

当outlooktree向服务器发起ajax请求时,设置响应的请求头啊?,能不能直接在html加入beforeSend事件,然后把请求参数Bareer token写入到请求头啊,还是有别的请求事件?

Rank: 6Rank: 6

发表于 2020-3-17 15:29:44 |显示全部楼层
felt 发表于 2020-3-16 10:13
dataField="data"默认就是data字段,如果不是data字段要设置成你的字段。

或者设置统一的响应请求头,只要是向服务器请求数据,都可以自定义请求前的请求头,可以这样实现不?

Rank: 6Rank: 6

发表于 2020-3-17 16:26:43 |显示全部楼层
felt 发表于 2020-3-16 10:13
dataField="data"默认就是data字段,如果不是data字段要设置成你的字段。
  1. jQuery.ajax({
  2.             type: 'GET',
  3.             beforeSend: dudu.headToken,
  4.             url: _url,
  5.             data: null,
  6.             async: _async,
  7.             success: function (r) {
  8.                 if (r.code == dudu.code.authError) {
  9.                     alert(r.msg);
  10.                     window.top.location.href = "login";
  11.                 } else {
  12.                     succ_callback(r)
  13.                 }
  14.             },
  15.             error: function (html) {
  16.                 var flag = (typeof console != 'undefined');
  17.                 if (flag) console.log("服务器忙,提交数据失败,代码:" + html.status + ",请联系管理员!");
  18.                 alert("服务器忙,提交数据失败,代码:" + html.status + ",请联系管理员!");
  19.             }
  20.         });
复制代码
然后在
  1. tree.set({
  2. beforeSend:function(xhr){
  3. return xhr.setRequestHeader("Authorization", "Bearer " + window.localStorage.getItem("token"));
  4. }
  5. 这样的方案,好像还不支持呢!求教!
  6. })
复制代码
这样设置好像不能用唉!

Rank: 8Rank: 8

发表于 2020-3-17 17:25:34 |显示全部楼层
joyoes 发表于 2020-3-17 16:26
然后在这样设置好像不能用唉!

http://miniui.com/forum/forum.ph ... &extra=page%3D1

Archiver|普加软件

GMT+8, 2024-3-29 05:27 , Processed in 1.030959 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部