1 Array.prototype.contains = function(obj) { 2 var i = this.length; 3 while (i--) { 4 if (this[i] === obj) { 5 return true; 6 } 7 } 8 return false; 9 }; 10 // 查询函数 11 var tempIndex=[]; 12 function searchText(dg,t){ //参数:$("#datagrid"),$(”#text“) 13 var dg = objs.addFoodsListGrid; 14 var t = $(‘#searchFoodsList‘); 15 16 dg.datagrid("unselectAll"); 17 var rows = dg.datagrid("getData").rows; 18 console.log(rows); 19 var columns = dg.datagrid(‘getColumnFields‘); 20 console.log(columns); 21 var searchVal = t.val(); 22 for(var i=0;i<rows.length;i++){ 23 for(var j=1;j<columns.length;j++){ 24 if(rows[i][columns[j]].indexOf(searchVal)>=0){ 25 if(!tempIndex.contains(i)){ 26 dg.datagrid("selectRow",i); 27 tempIndex.push(i); 28 return; 29 } 30 } 31 } 32 if(i==(rows.length-1)){ 33 tempIndex=[]; 34 } 35 } 36 }
时间: 2024-10-06 01:41:42