jQuery MiniUI

标题: 表格的数据绑定 [打印本页]

作者: 沧海V蓝田    时间: 2016-11-14 17:55:49     标题: 表格的数据绑定

请求我是利用ajax进行的,然后设置咱们表格的data属性,

这是定义的table
<div id='datagrid1' class='mini-datagrid' style='width:100%;height:280px;margin:auto;'>
  <div property='columns'>
                         <div type='indexcolumn' ></div>
                         <div field='doctoraddress' width='120' headerAlign='center' allowSort='true'>员工帐号</div>   
                         <div field='doctorage' width='120' headerAlign='center' allowSort='true'>姓名</div>                           
                         <div field='doctorgender' width='100'  align='center' headerAlign='center'>性别</div>
                  <div field='doctorname' width='100' allowSort='true'>薪资</div>                                    
                     <div field='doctorphone' width='100' allowSort='true'>年龄</div>
                 <div field='doctorphoto' width='100' headerAlign='center' allowSort='true'>创建日期</div>               
         </div>
</div>



这是ajax请求:
$.ajax({
        url : "paitentAction/findmyappointment.do",
                type : "post",
                dataType:"json",
                success:function(data){
                        alert(data.jsonarray);
                         $("#datagrid1").arrt(data,data.jsonarray);
                                        mini.parse();
                                var grid = mini.get("datagrid1");
                                grid.load();
                                }
                 });

这是ajax请求返回的data:
{"total":2,
"jsonarray":[{"doctorname":"李华","doctorage":31,"doctorgender":"男","doctorphone":"15534874562","doctoraddress":"洛阳市涧西区联盟路联盟小区"},
                   {"doctorname":"张忠","doctorage":32,"doctorgender":"男","doctorphone":"143514589563","doctoraddress":"洛阳市涧西区联盟路龙鳞小区"}]}



数据加载不出来,请问这样写不对吗?数据已经利用ajax返回呀,但是为什么是加载不上呢?我看咱们的api说data属性值为array类型的,我的数据也是对的额,但是为什么加载不出来呢?还有没有别的方式进行加载呢?

作者: 沧海V蓝田    时间: 2016-11-14 17:57:40

真是抱歉,研究了一天,真的不知道该怎么绑定了,麻烦版主了,谢谢
作者: 沧海V蓝田    时间: 2016-11-15 09:59:12

沧海V蓝田 发表于 2016-11-14 17:57
真是抱歉,研究了一天,真的不知道该怎么绑定了,麻烦版主了,谢谢

重新利用了url属性进行解析,已经解决问题,在服务器返回的数据一定要注意格式。文档真的是重要。可能是自己昨天没有找到正确的打开方式,嘻嘻,继续研究,谢谢亲们提供了一个很好的前端框架。
作者: felt    时间: 2016-11-15 10:05:40

沧海V蓝田 发表于 2016-11-15 09:59
重新利用了url属性进行解析,已经解决问题,在服务器返回的数据一定要注意格式。文档真的是重要。可能是 ...

grid.load只对url绑定的数据有效
如果你是自己ajax获取数据的话,只能grid.setData(data)加载静态数据,而且这样的话,刷新,排序之类的都要另外注意。




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2