easyui是一种基于jQuery、Angular.、Vue和React的用户界面插件集合。
easyui为建立现代化,互动,JavaScript应用程序,提供必要的功能。
使用easyui你不须要写不少代码,你只须要经过编写一些简单HTML标记,就能够定义用户界面。
easyui是个完美支持HTML5网页的完整框架。
easyui节省您网页开发的时间和规模。
easyui很简单但功能强大的。html
因为项目须要,主要利用easyUI的数据表格datagrid作后台系统前端部分
使用EasyUI for JQuery前端
<table id="dg"></table>
$('#dg').datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',width:100}, {field:'name',title:'Name',width:100}, {field:'price',title:'Price',width:100,align:'right'} ]] });
$('#dg').datagrid('load', { name: 'easyui', address: 'ho' });
$('#dg').datagrid('reload');
官方网址:http://www.jeasyui.net/
下载路径:http://www.jeasyui.net/download
官方中文文档:http://www.jeasyui.net/plugins
datagrid数据网格详细介绍:http://www.jeasyui.net/plugin...ajax
需求:页面首次加载,datagrid不加载页面数据,点击查询按钮再进行数据渲染json
//onBeforeLoad发送加载数据的请求前触发,若是返回 false 加载动做就会取消。 //首次不加载页面数据 onBeforeLoad: function (param) { var firstLoad = $(this).attr("firstLoad"); if (firstLoad == "false" || typeof (firstLoad) == "undefined") { $(this).attr("firstLoad","true"); return false; } return true; }
没法修改content-Type
能够改用loader自定义获取数据
loader:定义如何从远程服务器加载数据。返回 false 则取消该动做。该函数有下列参数:
param:要传递到远程服务器的参数对象。
success(data):当检索数据成功时调用的回调函数。
error():当检索数据失败时调用的回调函数。服务器
loader: function (param, success, error) { //console.log(param, success, error); $.ajax({ type: "POST", url : '请求接口', contentType: "application/json", dataType: "json", data: JSON.stringify(param)//数据转换成JSON格式 }).done(function (data) { if (data.total!=0) { success(data); } else { $.messager.alert(''); error(); } }).fail(function () { }); },
后台返回json数据格式app
{ total:总共有多少条数据, rows:[{,},{,}]//请求页数的结果数据 }
//从新制定请求参数名称 onBeforeLoad : function(param){ var page = param.page; //保存下默认请求参数page值 delete param.page; //删掉默认请求参数page param.PageIndex = page; //将默认请求参数名称page换为PageIndex }
$.messager.show({}) 默认宽250 高100
利用style属性,重新定位消息框位置框架
style:{ left:document.body.clientWidth/2-125, // 与左边界的距离 top:document.body.clientHeight/2-50 // 与顶部的距离 }
$('#tableData).datagrid('loadData', { total: 0, rows: [] });//清空表格数据