网上找了好多人的方法发现都有问题发一个可用方便的

主要分三种情况 加载
1,loaddata 加载
2,datagrid 加载
3, url 加载

第一部分,datagrid加载

第二部分,点击 datagrid里面的跳转

第三部分,弹窗显示

首先MVC控制器初始数据

    public JsonResult Data()
{
var product = new[]
{
new { productid="FI-SW-01",unitcost=,status="P",listprice=,attr1="Large",itemid="EST-1"},
new { productid="K9-DL-01",unitcost=,status="P",listprice=,attr1="Spotted Adult Female",itemid="EST-10"},
new { productid="RP-SN-01",unitcost=,status="P",listprice=,attr1="Venomless",itemid="EST-11"},
new { productid="RP-SN-01",unitcost=,status="P",listprice=,attr1="Rattleless",itemid="EST-12"},
new { productid="RP-LI-02",unitcost=,status="P",listprice=,attr1="Green Adult",itemid="EST-13"},
new { productid="FL-DSH-01",unitcost=,status="P",listprice=,attr1="Tailless",itemid="EST-14"},
new { productid="FL-DSH-01",unitcost=,status="P",listprice=,attr1="With tail",itemid="EST-15"},
new { productid="FL-DLH-02",unitcost=,status="P",listprice=,attr1="Adult Female",itemid="EST-16"},
new { productid="FL-DLH-02",unitcost=,status="P",listprice=,attr1="Adult Male",itemid="EST-17"},
new { productid="AV-CB-01",unitcost=,status="P",listprice=,attr1="Adult Male",itemid="EST-18"}
}; return Json(new { total = product.Count(), rows = product }, JsonRequestBehavior.AllowGet);
}

第一部分,1 loaddata 需要先预加载表格格式,在填充数据

  <table id="tt" title="Load Data" class="easyui-datagrid" style="width:700px;height:250px"
iconCls="icon-save" pagination="true">
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="120">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right">Unit Cost</th>
<th field="attr1" width="250">Attribute</th>
<th field="status" width="60" align="center">Stauts</th>
</tr>
</thead>
</table>
    function dd()
{
$.ajax(
{
type: 'post',
url: '@Url.Action("data","home")',
data: {
url: 'hello',
},
dataType: 'json',
success: function (data, stutas, xhr) {
$('#tt').datagrid("loadData", data)
},
error: function (xhr, textStatus, data) {
alert(data);
}
});
};

2 datagrid 加载

 <table id="Cse_Bespeak_Log" class="easyui-datagrid" style="width: auto; height: 350px;"></table>
 $("#Cse_Bespeak_Log").datagrid({
url: "@Url.Action("data", "home")",
iconCls: "icon-add",
fitColumns: false,
loadMsg: "数据加载中......",
pagination: true,
rownumbers: true,
nowrap: false,
showFooter: true,
singleSelect: true,
pageList: [100, 50, 20, 10], columns: [[
{
field: 'itemid', title: '编号', width: 50, align: 'center',
formatter: function (value, row, index) { return " <a href='javascript:void(0)' onclick='return LoadUserInfo()'>" + value + "</a>";
}
},
{
field: 'productid', title: '用户名', width: 150, align: 'center',
},
{
field: 'listprice', title: '姓名', width: 150, align: 'center',
},
{
field: 'unitcost', title: '操作', width: 100, align: 'center',
},
{
field: 'attr1', title: '操作', width: 100, align: 'center',
},
{
field: 'status', title: '操作', width: 100, align: 'center',
}]] })

3.url加载

 <table id="tt" title="Load Data" class="easyui-datagrid" style="width:700px;height:250px"
url="@Url.Action("data","home")"
iconCls="icon-save" pagination="true">
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th data-options="field:'productid',width:180,formatter: rowformater" field="productid" width="120">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right">Unit Cost</th>
<th field="attr1" width="250">Attribute</th>
<th field="status" width="60" align="center">Stauts</th>
</tr>
</thead>
</table>
     var pager = $('#tt').datagrid('getPager');    // get the pager of datagrid
pager.pagination({
showPageList: false,
buttons: [{
iconCls: 'icon-search',
handler: function () {
alert('search');
}
}, {
iconCls: 'icon-add',
handler: function () {
alert('add');
}
}, {
iconCls: 'icon-edit',
handler: function () {
alert('edit');
}
}],
onBeforeRefresh: function () {
alert('before refresh');
return true;
}
}); });

第二部分datagird里面加跳转

1.

   <th  data-options="field:'productid',width:180,formatter:  rowformater" field="productid" width="120">Product ID</th>
   function rowformater(value, row, index) {
return "<a href='" + row.id + "' target='_blank'>操作</a>";
};

2已经在上第一部分2中

第三部分,弹窗显示 预制一个table 加载数据在open

 <div id="dlg" class="easyui-dialog" style="width: 1000px; height: 350px;"
data-options="closed:true,buttons:'#dlg-buttons'">
<table id="datagrid" class="easyui-datagrid" style="width:600px;height:350px"> </table>
</div>
  function LoadUserInfo() {

         /*获取选中行*/
//var row = $('#Cse_Bespeak_Log').datagrid('getSelected'); //获取选中行 $("#datagrid").datagrid({
url: "@Url.Action("data1", "home")",
iconCls: "icon-add",
fitColumns: false,
loadMsg: "数据加载中......",
pagination: true,
rownumbers: true,
nowrap: false,
showFooter: true,
singleSelect: true,
pageList: [100, 50, 20, 10], columns: [[
{
field: 'itemid', title: '编号', width: 50, align: 'center',
formatter: function (value, row, index) { return " <a href='javascript:void(0)' onclick='return LoadUserInfo()'>"+ value +"</a>";
}
},
{
field: 'productid', title: '用户名', width: 150, align: 'center',
},
{
field: 'listprice', title: '姓名', width: 150, align: 'center',
},
{
field: 'unitcost', title: '操作', width: 100, align: 'center',
},
{
field: 'attr1', title: '操作', width: 100, align: 'center',
},
{
field: 'status', title: '操作', width: 100, align: 'center',
}]] }) $('#dlg').window('open'); //弹出这个dialog框
};

https://www.cnblogs.com/baiyangyuanzi/p/6702742.html?utm_source=itdadao&utm_medium=referral

EasyUI datagrid 数据加载的更多相关文章

  1. easyui datagrid 异步加载数据时滚动条有时会自动滚到最底部的问题

    在使用easyui 的datagrid异步加载数据时发现滚动条有时会自动滚到最底部.经测试发现,如果加载数据前没有选中行则不会出现这个问题.这样我们可以在重新异步加载数据前取消选中行就可以避免这个问题 ...

  2. easyui datagrid 动态加载数据 渲染问题,表格错位问题

    $('#dg').datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',width:100}, {fie ...

  3. jquery easyui datagrid 远程加载数据----把主键渲染为值遇到的问题及解决方案

    起因:数据库中一些字段存的是代表具体值的数字,需要渲染为具体值 monggodb中的字典 mysql中存放的值为:expertin代表教练擅长的搏击技能 jquery easyui中的相关代码如下:用 ...

  4. jquery easyui datagrid 远程加载数据----javascript法

    jquery easyui有三种办法生成datagrid(数据网格),本篇专门讨论javascript借助jquey easy ui实现的方式 html部分 <main role="m ...

  5. EasyUI datagrid easyui datagrid +dialog 加载 可直接运行 七

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta ht ...

  6. easyui datagrid onLoadSuccess加载两次。。

    今天使用EasyUI的datagrid时发现首次打开页面时onLoadSuccess方法执行了两次.后来发现主要问题是datagrid被初始化了两次.主要原因是一开始html中声明了dg为easyui ...

  7. EasyUI datagrid动态加载json数据

    最近做一个项目,要求是两张张表可能查找出10多种不同的结果集. 如果想只用一个表格就把全部的结果不同的显示出来那么就肯定不同使用固定的字段名字,要通过动态加载后台返回来的数据把它显示出来就必须动态加载 ...

  8. EasyUI datagrid 动态加载表头和数据

    首先返回到页面的需要是JSON数据: 第一步: 遍历表头,插入到array中 for (var i = 0; i < jsonObj.title.length; i++) { //把返回的数据封 ...

  9. 【第一篇】说说MVC+EF easyui dataGrid 动态加载分页表格

    首先上javascript的代码 <script type="text/javascript"> $(function () { LoadGrid(); }) //加载 ...

随机推荐

  1. LY.JAVA.DAY12.String类

    2018-07-24 14:06:03 String类概述 字符串是由多个字符组成一串数据(字符序列) 字符串可以看成字符数组 一旦被赋值就不能被改变    值不能变 1.过程概述: 方法区---字符 ...

  2. day 69 权限的设置

    1.权限控制 1). 表结构的设置 2). 流程 1.登录 get: 通过中间件的白名单 re 获取到登录页面 post: 通过中间件的白名单,认证成功,保存权限信息, --ORM 去空的权限 去重 ...

  3. SpringWeb项目常用注解简单介绍

    注解分为两类: 一类是使用Bean,即是把已经在xml文件中配置好的Bean拿来用,完成属性.方法的组装:比如@Autowired , @Resource,可以通过byTYPE(@Autowired) ...

  4. ios 设置本地化显示的app名称

    内容的本地化这里不做介绍! 名称的本地化: 1.新建一个 Strings File文件,命名为InfoPlist,注意这里一定要命名为InfoPlist! 2.设置本地化信息:选择需要的语言! 3.填 ...

  5. 第一篇 入门必备 (Android学习笔记)

    第一篇 入门必备 第1章 初识Android 第2章 搭建你的开发环境 第3章 创建第一个程序--HelloWorld 第4章 使用Android工具   ●Android之父 Android安迪·罗 ...

  6. jmeter源码导入eclipse并执行

    由于JMeter纯Java开发,界面也是基于Swing或AWT搞出来的,所以想更深层次的去了解这款工具或对于想了解JMeter插件开发或二次开发的童鞋们来说,读读JMeter的源码估计是必不可少的,所 ...

  7. 区分舍入函数fix/round/ceil/floor

    1)fix(n)的意义是取小于n的整数(是向零点舍入的意思是往零的方向上靠),这是一类应用在整数取值上的函数,就如同以前我们所研究的求整问题: 例如:fix(pi)=3 ; fix(3.5)=3;  ...

  8. Unicode与中文转换工具类方法(转)

    /* * 中文转unicode编码 */ public static String gbEncoding(final String gbString) { char[] utfBytes = gbSt ...

  9. 安装连接mysql8时候遇到的问题以及解决(转)

    官网下载mysql8的安装包: https://dev.mysql.com/downloads/ 下一步安装即可. mysql8增加了传说中的安全性校验 遇到的几个问题: 1.natcat连接不上.参 ...

  10. Codeforces Round #485 (Div. 2) C题求三元组(思维)

    C. Three displays time limit per test 1 second memory limit per test 256 megabytes input standard in ...