jquery easyUI 中动态 改变 Datagrid中数据的方法
2013-07-16 21:48
176 查看
在jquery easyui中,一般在表格中显示数据的方法是在页面加载中指定数据URL,如下:
<table class="easyui-datagrid" style="width:400px;height:250px"
data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100">Name</th>
<th data-options="field:'price',width:100,align:'right'">Price</th>
</tr>
</thead>
</table>
但是在互联网级别的编程中,为了性能,一般不在页面加载中直接查询数据,而是用户输入查询条件后,点击查询条件才显示数据
点击查询后
该如何编码呢?查询文献实践后如下:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色管理</title>
<link rel="stylesheet" type="text/css" href="../../themes/pepper-grinder/easyui.css"
id="swicth-style" />
<link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
<script type="text/javascript">
var url;
function search() {
var name = $('#name').val();
var handler = "Ajax/GetRoleListHandler.ashx?name=" + name;
$('#tableRole').datagrid('options').url = handler;
$('#tableRole').datagrid('reload');
}
</script>
</head>
<body>
<h2> 角色管理</h2>
<div id="divSearch" class="easyui-panel" style="width: 1000px; height: 100px; padding: 10px;"
data-options="title:'查询条件',iconCls:'icon-save',
collapsible:true,minimizable:true,maximizable:true,closable:true">
<table>
<tr>
<td>
角色名
</td>
<td>
<input type="text" id="name" data-options="required:true"></input>
</td>
</tr>
<tr>
<td>
<input type="submit" value="查询" onclick="search()">
</td>
</tr>
</table>
</div>
<div id="divGrid" class="easyui-panel" style="width: 1000px; height: 400px; padding: 10px;"
data-options="title:'查询结果',iconCls:'icon-save',
collapsible:true,minimizable:true,maximizable:true,closable:true">
<table id="tableRole" title="角色列表" class="easyui-datagrid" style="width: 950px; height: 250px"
toolbar="#toolbar" pagination="true" rownumbers="true" fitcolumns="true" singleselect="true">
<thead>
<tr>
<th field="RoleID" width="20">
角色ID
</th>
<th field="Name" width="50">
角色名
</th>
<th field="Description" width="50">
描述
</th>
<th field="Note" width="50">
备注
</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addRole()">
添加角色</a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editRole()">
编辑角色</a> <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true"
onclick="removeRole()">删除角色</a>
</div>
<table class="easyui-datagrid" style="width:400px;height:250px"
data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100">Name</th>
<th data-options="field:'price',width:100,align:'right'">Price</th>
</tr>
</thead>
</table>
但是在互联网级别的编程中,为了性能,一般不在页面加载中直接查询数据,而是用户输入查询条件后,点击查询条件才显示数据
点击查询后
该如何编码呢?查询文献实践后如下:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色管理</title>
<link rel="stylesheet" type="text/css" href="../../themes/pepper-grinder/easyui.css"
id="swicth-style" />
<link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
<script type="text/javascript">
var url;
function search() {
var name = $('#name').val();
var handler = "Ajax/GetRoleListHandler.ashx?name=" + name;
$('#tableRole').datagrid('options').url = handler;
$('#tableRole').datagrid('reload');
}
</script>
</head>
<body>
<h2> 角色管理</h2>
<div id="divSearch" class="easyui-panel" style="width: 1000px; height: 100px; padding: 10px;"
data-options="title:'查询条件',iconCls:'icon-save',
collapsible:true,minimizable:true,maximizable:true,closable:true">
<table>
<tr>
<td>
角色名
</td>
<td>
<input type="text" id="name" data-options="required:true"></input>
</td>
</tr>
<tr>
<td>
<input type="submit" value="查询" onclick="search()">
</td>
</tr>
</table>
</div>
<div id="divGrid" class="easyui-panel" style="width: 1000px; height: 400px; padding: 10px;"
data-options="title:'查询结果',iconCls:'icon-save',
collapsible:true,minimizable:true,maximizable:true,closable:true">
<table id="tableRole" title="角色列表" class="easyui-datagrid" style="width: 950px; height: 250px"
toolbar="#toolbar" pagination="true" rownumbers="true" fitcolumns="true" singleselect="true">
<thead>
<tr>
<th field="RoleID" width="20">
角色ID
</th>
<th field="Name" width="50">
角色名
</th>
<th field="Description" width="50">
描述
</th>
<th field="Note" width="50">
备注
</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addRole()">
添加角色</a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editRole()">
编辑角色</a> <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true"
onclick="removeRole()">删除角色</a>
</div>
相关文章推荐
- jquery easyUI 中动态 改变 Datagrid中数据的方法
- easyui中根据后台数据动态改变datagrid的列
- 关于easyUI datagrid、layout动态改变大小使用的方法
- jquery easyui datagrid 动态改变url地址中的参数值
- 【项目实战】---为EasyUI DataGrid的某一动态加载数据列添加超链接,点击超链接触发Onclick方法
- 扩展jquery easyui datagrid 之动态绑定列和数据
- jquery easyui中datagrid 中的动态接受后台传的数据
- jquery easyui datagrid加载数据不符合datagrid能够解析的格式处理方法
- [VB.NET]vb.net 根据数据情况动态改变datagrid样式(急)
- JQuery EasyUI 根据数据动态生成datagrid,统计常用
- jQuery easyui dataGrid 动态改变排序字段名,一般情况下,在使用的时候,我们会点击相应字段进行排序,这里以JAVA为例,后端的实体类字段有可能和数据库的字段不一致; 如:实体类中的
- jquery easyui中datagrid 中的动态接受后台传的数据
- Android中string.xml,动态改变数据方法
- JQuery EasyUI 根据数据动态生成datagrid,统计常用
- 获取Jquery EasyUI Datagrid中所有数据的方法
- jquery easyui-datagrid动态改变标题
- Jquery EasyUI动态改变值(及输入框携带按钮的使用方法)
- jQuery easyui datagrid动态查询数据
- Jquery easyUI datagrid加载复杂JSON数据方法
- (转)扩展jquery easyui datagrid 之动态绑定列和数据