pageList: [10, 20, 30], //可以调整每页显示的数据,即调整pageSize每次向后台请求数据时的数据
//由于datagrid的属性过多,我就不每个都介绍了,如有需要,可以看它的API
sortName: “name”, //初始化表格时依据的排序 字段 必须和数据库中的字段名称相同
sortOrder: “asc”, //正序
columns: [[
{ field: ‘code’, title: ‘Code’, width: 100 },
{ field: ‘name’, title: ‘Name’, width: 100, sortable: true },//sortable:true点击该列的时候可以改变升降序
{ field: ‘addr’, title: ‘addr’, width: 100 }
]],//这里之所以有两个方括号,是因为可以做成水晶报表形式,具体可看demo
toolbar: [{//在dategrid表单的头部添加按钮
text: “添加”,
iconCls: “icon-add”,
handler: function () {
}
}, ‘-‘, {//’-‘就是在两个按钮的中间加一个竖线分割,看着舒服
text: “删除”,
iconCls: “icon-remove”,
handler: function () {
}
}, ‘-‘, {
text: “修改”,
iconCls: “icon-edit”,
handler: function () {
}
}, ‘-‘]
});
});
//点击查找按钮出发事件
function searchFunc() {
alert(“123”);
$(“#dg”).datagrid(“load”, sy.serializeObject($(“#searchForm”).form()));//将searchForm表单内的元素序列为对象传递到后台
}
//点击清空按钮出发事件
function clearSearch() {
$(“#dg”).datagrid(“load”, {});//重新加载数据,无填写数据,向后台传递值则为空
$(“#searchForm”).find(“input”).val(“”);//找到form表单下的所有input标签并清空
}
</script>
<div class=”easyui-tabs” fit=”true” border=”false”>
<div title=”数据展示表格” border=”false” fit=”true”>
<div class=”easyui-layout” fit=”true” border=”false”>
<!–由于查询需要输入条件,但是以toolbar的形式不好,所以我们在Layout框架的头部north中书写查询的相关信息–>
<!– 这里我们尽量使其展示的样式与toolbar的样式相似,所以我们先查找toolbar的样式,并复制过来–>
<div data-options=”region:’north’,title:’高级查询'” style=”height: 100px; background: #F4F4F4;”>
<form id=”searchForm”>
<table>
<tr>
<th>用户姓名:</th>
<td>
<input name=”name” /></td>
</tr>
<tr>
<th>创建开始时间</th>
<td>
<input class=”easyui-datetimebox” editable=”false” name=”subStartTime” /></td>










