jQuery MiniUI

 找回密码
 立即注册
查看: 4319|回复: 8
打印 上一主题 下一主题

mini-tree动态设置Url [复制链接]

Rank: 3Rank: 3

跳转到指定楼层
楼主
发表于 2020-1-2 09:02:47 |只看该作者 |倒序浏览
mini-tree怎么动态设置URL并且传值,URL请求回的数据是下面那种格式的,
var list = [
                { id: "base", text: "Base" },            
                { id: "ajax", text: "Ajax", pid: "base" },
                { id: "json", text: "JSON", pid: "base" },
                { id: "date", text: "Date", pid: "base" },
                { id: "control", text: "Control", pid: "base" },
                { id: "forms", text: "Forms", pid: "base" },
                { id: "button", text: "Button", pid: "forms" },
                { id: "listbox", text: "ListBox", pid: "forms" },
                { id: "checkboxlist", text: "CheckBoxList", pid: "forms" },
            { id: "lists", text: "Lists" },
                { id: "datagrid", text: "DataGrid", pid: "lists" },
                { id: "tree", text: "Tree", pid: "lists" },
                { id: "treegrid", text: "TreeGrid ", pid: "lists" }
        ];

Rank: 8Rank: 8

沙发
发表于 2020-1-2 09:31:55 |只看该作者
tree.setUrl(url)
tree.setResutAsTree(false);

Rank: 3Rank: 3

板凳
发表于 2020-1-2 09:37:00 |只看该作者
本帖最后由 Aisin丿Gioro 于 2020-1-2 09:49 编辑
felt 发表于 2020-1-2 09:31
tree.setUrl(url)
tree.setResutAsTree(false);

好的谢谢

Rank: 3Rank: 3

地板
发表于 2020-1-2 09:56:25 |只看该作者
本帖最后由 Aisin丿Gioro 于 2020-1-2 10:08 编辑
felt 发表于 2020-1-2 09:31
tree.setUrl(url)
tree.setResutAsTree(false);

为什么我加载出来的树节点无限循环,点击一次树节点请求一次url
  tree.setAjaxOptions({
                type:'post',
                async: true,
                data: {
                    parentCode: moduleId
                },
                dataType: 'json',
                contentType: 'application/x-www-form-urlencoded;charset=utf-8'
            });
            tree.setResultAsTree(true);
            tree.setUrl("${pageContext.request.contextPath }/channel/selectChannelChildByCode");

Rank: 8Rank: 8

5#
发表于 2020-1-2 10:22:33 |只看该作者
Aisin丿Gioro 发表于 2020-1-2 09:56
为什么我加载出来的树节点无限循环,点击一次树节点请求一次url
  tree.setAjaxOptions({
                 ...

贴一下树的数据

Rank: 3Rank: 3

6#
发表于 2020-1-2 10:45:51 |只看该作者
felt 发表于 2020-1-2 10:22
贴一下树的数据

[{"isStatic":"off","code":"n2","flag":"","icon":"","description":"","pid":"c1","type":"1","isLeaf":"false","path":"","expanded":"false","pagesize":"20","alias":"简称","id":"2","RSiteId":"","sort":10,"url":"http://baidu.com","target":"open","createBy":"11","createTime":"","deleteTime":"","name":"栏目1","deleteBy":"","isDel":0,"onoff":"on"},{"isStatic":"off","code":"n3","flag":"","icon":"","description":"","pid":"c1","type":"1","isLeaf":"true","path":"","expanded":"false","pagesize":"20","alias":"简称","id":"3","RSiteId":"","sort":11,"url":"http://baidu.com","target":"open","createBy":"11","createTime":"","deleteTime":"","name":"栏目2","deleteBy":"","isDel":0,"onoff":"on"}]

Rank: 8Rank: 8

7#
发表于 2020-1-2 13:35:12 |只看该作者
Aisin丿Gioro 发表于 2020-1-2 10:45
[{"isStatic":"off","code":"n2","flag":"","icon":"","description":"","pid":"c1","type":"1","isLeaf" ...

isLeaf:false     那么强制这个节点是父节点,如果不需要懒加载,那么给这个节点设置asyncload:false

Rank: 3Rank: 3

8#
发表于 2020-1-2 14:23:43 |只看该作者
felt 发表于 2020-1-2 13:35
isLeaf:false     那么强制这个节点是父节点,如果不需要懒加载,那么给这个节点设置asyncload:false ...

我的就是懒加载的,而且还得点击有子节点的父节点,去请求接口每次点击都需要懒加载都得传不同的参数。

Rank: 8Rank: 8

9#
发表于 2020-1-2 14:47:37 |只看该作者
Aisin丿Gioro 发表于 2020-1-2 14:23
我的就是懒加载的,而且还得点击有子节点的父节点,去请求接口每次点击都需要懒加载都得传不同的参数。 ...

懒加载的我们传递了当前节点的id到后台,请后台按节点id进行处理

Archiver|普加软件

GMT+8, 2024-11-27 12:58 , Processed in 1.058210 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部