首页 > 代码库 > eayui datagrid模仿浏览器CTRL+F搜索定位
eayui datagrid模仿浏览器CTRL+F搜索定位
用于存储匹配成功的记录行数,连续点击查询按钮跳过这些行
var tempIndex=[];
查询函数
function searchText(dg,t){ //参数:$("#datagrid"),$(”#text“)
dg.datagrid("unselectAll");var rows = dg.datagrid("getData").rows;
var columns = dg.datagrid(‘getColumnFields‘);
var searchVal = t.val();
for(var i=0;i<rows.length;i++){
for(var j=1;j<columns.length;j++){
if(rows[i][columns[j]].indexOf(searchVal)>=0){
if(!tempIndex.contains(i)){
dg.datagrid("selectRow",i);
tempIndex.push(i);
return;
}
}
}
if(i==(rows.length-1)){
tempIndex=[];
}
}
}
datagrid设置
$("#cargoAgentTable").datagrid({
url: "../webresources/login/sql/getCargoAgentCod",
method: ‘GET‘,
fit:false,
pagination: false,
width:486,
height:448,
singleSelect: false,
checkOnSelect: false,
onClickRow:function(index,row){
$(this).datagrid("unselectAll");
$(this).datagrid("selectRow",index);
},
onCheck:function(index,row){
$(this).datagrid("unselectAll");
$(this).datagrid("selectRow",index);
},
columns: [[{
field: "ck",
checkbox: true
}, {
field: ‘CLIENT_COD‘,
title: ‘货代理编码‘,
sortable: true,
width: 80
}, {
field: ‘USER_CODE‘,
title: ‘代码‘,
sortable: true,
width: 60
}, {
field: ‘CLIENT_NAM‘,
title: ‘货代名称‘,
sortable: true,
width: 180
}, {
field: ‘SHOT_NAM‘,
title: ‘简称‘,
sortable: true,
width: 80
}
]]
});
弹出框设置
$("#businessCargoKindNam_SCFQ").on("dblclick", function() {
tempIndex=[];
$("#businessCargoKindTable").datagrid("uncheckAll");
$("#businessCargoKindDialog").css(‘display‘, ‘block‘).dialog({
title: "货类列表",
closed: false,
width:300,
toolbar:"#businessCargoKindDialogToolbar",
height:450,
resizable: true,
cache: false,
modal: true,
buttons: [{
text: ‘保存‘,
iconCls: ‘icon-save‘,
handler: function() {
var nam = "";
var cod = "";
var rows = $("#businessCargoKindTable").datagrid("getChecked");
$.each(rows, function(i, v) {
nam += v.SYS_NAM + ",";
cod += v.SYS_COD + ",";
});
if (nam) {
nam = nam.substr(0, nam.length - 1);
}
if (cod) {
cod = cod.substr(0, cod.length - 1);
}
$("#businessCargoKindNam_SCFQ").val(nam);
$("#businessCargoKind_SCFQ").val(cod);
$("#businessCargoKindDialog").dialog(‘close‘);
}
}, {
text: ‘取消‘,
iconCls: ‘icon-cancel‘,
handler: function() {
$("#businessCargoKindDialog").dialog(‘close‘);
}
}]
});
});
大概写了写,存稿以后使用。
eayui datagrid模仿浏览器CTRL+F搜索定位