jQuery MiniUI

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

关于动态列 [复制链接]

Rank: 3Rank: 3

跳转到指定楼层
楼主
发表于 2017-7-6 22:01:11 |只看该作者 |倒序浏览
$.ajax({
                        url: bootPATH +"../r.do",
                        type: "post",
                        success: function (text) {
                                var data = mini.decode(text);
                                var jsontext=data.fields;
                                var co=[jsontext]//jsontext是一个字符串
                                alert(co);
                                grid.set({ columns: co});
                                /* grid.set({
                                        columns: [
                                                { type: "indexcolumn" },
                                                { field: "age", width: 100, headerAlign: "center", allowSort: true, header: "年龄"},
                                                { field: "loginname", width: 120, headerAlign: "center", allowSort: true, header: "员工账号" }
                                        ]
                                });*/
                        }
                });

alert出来的信息和注释中直接写的信息一致,为什么动态列出不来,就显示一个空白的横条,用注释中的可以正常显示。
不知是什么原因?

Rank: 8Rank: 8

沙发
发表于 2017-7-7 09:07:43 |只看该作者
应该是你这co的数据格式不对,jsontext=data.fileds说明这个jsontext肯定不是几个对象,你又加了[],格式肯定和直接写出来的那个是不同的

Rank: 3Rank: 3

板凳
发表于 2017-7-7 09:56:35 |只看该作者
felt 发表于 2017-7-7 09:07
应该是你这co的数据格式不对,jsontext=data.fileds说明这个jsontext肯定不是几个对象,你又加了[],格式肯 ...

谢谢,搞定了。
需要将jsontext中的每个"{...},{...}"都做mini.decode然后放入[]中。

Archiver|普加软件

GMT+8, 2025-2-24 14:24 , Processed in 1.048459 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部