//=================================================================初始化
$(function() {
//获取乙方 下拉
$("#companyname").combobox({
url : sunny.contextPath + "/company/getByType.do?typeid=2",
valueField : 'id',
textField : 'companyname',
filter: function(q, row){
var opts = $(this).combobox('options');
return row[opts.textField].indexOf(q) > -1;
}
});
//全选
$("#chkAllId").click(function () {
//alert('al');
if($('#chkAllId').is(':checked')){
$("input[name='chkName']").prop("checked", true);
} else {
$("input[name='chkName']").prop("checked", false);
}
});
//
$("input[readOnly]").keydown(function(e) {
e.preventDefault();
});
//默认查询
queryData('',1,10);//查询框的值-第几页-每页多少条
//
//获取页面分页对象
var p = $('#grid').datagrid('getPager');
if (p){
$(p).pagination({
beforePageText: '第',
afterPageText: '页 共 {pages}页',
displayMsg: '显示 {from}到{to} ,共 {total}条记录',
onSelectPage:function (page,pageSize) {
queryData('',page,pageSize);
}
});
}
//
});
//=================================================================
//根据条件进行查询
var queryByCondition=function(){
//获取显示的文本属性:$("#companyname").textbox('getText')
//获取未显示的值:$("#companyname").textbox('getText')
//获取grid的当前分页信息
var pageopt = $('#grid').datagrid('getPager').data("pagination").options;
// alert('size:'+pageopt.pageSize+',pageNumber:'+pageopt.pageNumber);
queryData($("#companyname").textbox('getText'),pageopt.pageNumber,pageopt.pageSize);
}
//=================================================================
function queryData(companyname,pageNumberV,pageSizeV){
//grid
grid = $('#grid').datagrid({
//title:'单位信息列表',
loading:false,
url : sunny.contextPath + '/company/list.do',
queryParams:{
pageNumber:pageNumberV,
pageSize:pageSizeV,
companyname:companyname
},
striped : true,
rownumbers : true,
pagination : true,
singleSelect: false,
selectOnCheck: true,
checkOnSelect: true,
fitColumns : true,
fit:true,
idField : 'id',
sortName : 'id',
sortOrder : 'desc',
pageNumber:pageNumberV,
pageSize:pageSizeV,
pageList : [ 5,10, 20, 30, 40, 50, 100, 200, 300, 400, 500,1000,10000,20000],
columns : [ [
{
title : '主键',
field : 'id',
hidden : true
},
{
width : '40',
title: '<input id=\"chkAllId\" type=\"checkbox\" >',
field : 'codeChk',
formatter: function (value, rec, rowIndex) {
return "<input type=\"checkbox\" name=\"chkName\" value=\"" + rec.id + "\" >";
}
},
{
title : '单位名称',
field : 'companyname',
width: 200
}, {
title : '单位类型',
field : 'companytype',
width: 60,
formatter:function(value,row){
if(value=='2')
return "乙方";
if(value=='1')
return "甲方";
}
}
, {
title : '单位负责人',
field : 'companyresponsible',
width: 70
}, {
title : '联系电话',
field : 'telphone',
width: 120
}, {
title : '单位地址',
field : 'address',
width: 180
},{
title : '操作',
field : 'action',
formatter : function(value, row, index) {
var str = '';
str += sunny.formatString('<img class="iconImg ext-icon-note" title="查看" οnclick="viewCompanyInfo(\'{0}\');"/>', row.id);
//if (securityUtil.havePermission("/security/user!update")) {%>
str += sunny.formatString('<img class="iconImg ext-icon-note_edit" title="编辑" οnclick="editFun(\'{0}\');"/>', row.id);
//}%>
//if (securityUtil.havePermission("/security/user!grantRole")) {%>
//}%>
//if (securityUtil.havePermission("/security/user!grantOrganization")) {%>
//}%>
//if (securityUtil.havePermission("/security/user!delete")) {%>
str += sunny.formatString('<img class="iconImg ext-icon-note_delete" title="删除" οnclick="deleteFun(\'{0}\');"/>', row.id);
//}%>
return str;
}
} ] ],
toolbar : '#toolbar',
loadMsg:'数据加载中....',
onBeforeLoad : function(param) {
//parent.$.messager.progress({
// text : '数据加载中....'
//});
},
onLoadSuccess : function(data) {
isDatagridEmpty();
//$('#grid').datagrid('loadData', jQuery.parseJSON(data));
//var pager = $('#grid').datagrid('getPager');
//pager.pagination({
//更新pagination的导航列表各参数
// total:total,//总数
// pageSize: pageSize,//行数
// pageNumber: pageNumber//页数
// });
//$('.iconImg').attr('src', sunny.pixel_0);
//parent.$.messager.progress('close');
},
onDblClickRow: function (rowIndex, rowData) {
viewCompanyInfo(rowData.id);
}
});
}
//=================================================================数据库无记录
function isDatagridEmpty(){
var len=$('#grid').datagrid('getRows').length;
if(len==0){
$.messager.alert('系统提示','<font size=\"2\" color=\"#666666\"><strong>数据库暂无记录!</strong></font>','infoSunnyIcon');
}
}
easyui datagrid pagination 自定义分页
最新推荐文章于 2023-04-29 08:13:56 发布