easyui可以直接在html页面通过url获取后台数据,官网上的介绍是以json文件为例子的。一开始做测试的时候在项目中导入json文件,发现页面找不到,于是直接改成了从controller层获取数据。
html代码:
<table id="dg" class="easyui-datagrid" title="权限系统管理" style="width:auto;height:auto"
data-options="iconCls:'icon-edit',singleSelect:true,toolbar:'#tb',url:'JsonTest',method:'get'">
<thead>
<tr>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'productid',width:100">Product</th>
<th data-options="field:'listprice',width:80">List Price</th>
<th data-options="field:'unitcost',width:80">Unit Cost</th>
<th data-options="field:'attr1',width:250">Attribute</th>
</tr>
</thead>
</table>这里的url写的是cshtml页面所对应的controller

本文探讨了在使用easyui从C#后台获取数据时遇到的'Cannot read property 'length' of undefined'问题。原因可能包括未将JSON字符串转换为对象及datagrid要求的JSON格式缺少'total'和'rows'字段。解决方案是确保返回的JSON数据格式正确,包含必要的属性。
最低0.47元/天 解锁文章
464

被折叠的 条评论
为什么被折叠?



