首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么jquery-easyui网格不显示列数据?

为什么jquery-easyui网格不显示列数据?
EN

Stack Overflow用户
提问于 2013-03-12 11:31:31
回答 2查看 3.8K关注 0票数 0

我一直在尝试使用http://www.jeasyui.com/documentation/index.phpjquery-easyui datagrid。文档声明网格将接受json数据,我已经尝试实现了这一点,但是列从未在网格中呈现。

网格显示了适当的行数,每行都有一个行id,但是所有其他数据都被省略了。不知何故,网格正在读取json数据,并知道适当的行数,但不会呈现列数据。

我的json看起来像这样...

代码语言:javascript
复制
{"total":2,
 "rows":[
     {"id":"1",
      "name":"Employee One",
      "number":"1",
      "description":"This is the first Employee"
     },
     {"id":"2",
      "name":"Employee Two",
      "number":"2",
      "description":"This is the Second Employee"
     }
     ]
}

我的html是这样的.

代码语言:javascript
复制
 <table id="dg" title="Surveys" class="easyui-datagrid" style="width:550px;height:250px"  
    url="listJson2"  
    toolbar="#toolbar"  
    rownumbers="true" fitColumns="true" singleSelect="true">  
  <thead>  
    <tr>  
        <th field="id" width="20">Id</th>  
        <th field="name" width="50">Name</th>  
        <th field="number" width="50">Number</th>  
        <th field="description" width="50">Description</th>  
    </tr>  
  </thead>  
 </table>

我相信所有对js和css文件的引用都是正确的。网格在浏览器中渲染得很好。所有的按钮都在那里,我甚至有了正确的rows....just数,单元格中没有数据。

EN

回答 2

Stack Overflow用户

发布于 2013-07-21 20:49:01

我也遇到了同样的问题,我发现如果通过css将表格的宽度默认设置为100%,那么它将不起作用。

我知道这个问题有点老生常谈,但可能会对其他人有所帮助。

票数 3
EN

Stack Overflow用户

发布于 2013-03-12 23:19:45

试试loadData,

代码语言:javascript
复制
var list=[
            {"id":"1",
                "name":"Employee One",
                "number":"1",
                "description":"This is the first Employee"
               },
               {"id":"2",
                "name":"Employee Two",
                "number":"2",
                "description":"This is the Second Employee"
               }
               ];

$('#dg').datagrid('loadData', list); 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15352801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档