默认加载数据及分页加载
$("#about_box").datagrid({
url : '',
fitColumns : true,
nowrap : true,
striped : true,
border : false,
loadMsg : "正在加载中...",
pagination : true,// 自动分页功能 会自己传递 page rows 参数 后台接口 需要返回toal 及数据rows源
rownumbers : true,
singleSelect : true,
queryParams : {// 额外参数
vdnId : vdnId,
// cid : cid,
custName : custname,
phone : tel
},
toolbar : '#about_search',
columns : [ [ {
field : 'ck',
title : '',
width : 50,
align : 'center',
checkbox : true
}, {
field : 'custName',
title : '姓名',
width : 150,
align : 'center'
}, {
field : 'phone',
title : '手机号',
width : 150,
align : 'center'
}, {
field : 'qq',
title : 'QQ号',
width : 150,
align : 'center'
}, {
field : 'wechatNum',
title : '微信号',
width : 150,
align : 'center'
}, {
field : 'flymeAccount',
title : 'flyme账号',
width : 150,
align : 'center'
}, {
field : 'sex',
title : '性别',
width : 150,
align : 'center',
hidden : true
}, {
field : 'custLevel',
title : 'VIP客户',
width : 150,
align : 'center',
hidden : true
}, {
field : 'cid',
title : '客户编号',
width : 150,
align : 'center',
hidden : true
}, {
field : 'fixedPhone',
title : '固定电话',
width : 150,
align : 'center',
hidden : true
}, {
field : 'job',
title : '职业',
width : 150,
align : 'center',
hidden : true
}, {
field : 'email',
title : '邮箱',
width : 150,
align : 'center',
hidden : true
}, {
field : 'country',
title : '国家',
width : 150,
align : 'center',
hidden : true
}, {
field : 'province',
title : '省份',
width : 150,
align : 'center',
hidden : true
}, {
field : 'city',
title : '市级',
width : 150,
align : 'center',
hidden : true
}, {
field : 'area',
title : '区级',
width : 150,
align : 'center',
hidden : true
}, {
field : 'street',
title : '街道',
width : 150,
align : 'center',
hidden : true
}, {
field : 'address',
title : '详细地址',
width : 150,
align : 'center',
hidden : true
}, ] ]
});
有时候希望每次进来都希望数据是空的。可以这样做:
$("#guanlian").unbind('click').click(function() {// 点击关联客户
$('#about_customer').dialog('open');
_this.getAboutInfo();
$('#search_phone').val('');
//先获取数据
var item = $('#about_box').datagrid('getRows');
console.log(item);
if (item) { //有数据再进行重置
for (var i = item.length - 1; i >= 0; i--) {
var index = $('#about_box').datagrid('getRowIndex', item[i]);
$('#about_box').datagrid('deleteRow', index);
}
}
});
$('#about_search button').unbind('click').click(function() {// 关联客户搜索
var search_name = $('#search_name').val();
var search_phone = $('#search_phone').val();
var search_cid = $('#info_number').val();
newCustomerInfo.getAboutInfo(search_cid, search_name, search_phone);
//默认进来没有数据,点击搜索才有数据 $("#about_box").datagrid({'url':'api/customer/getAllCustomer'});
});