menu
more_vert
快速查询 jsp页面 和 js方法

作者:dayu

304 + encodeURIComponent(sender.value)+"&CURPAGE="+pageIndex+"&pageIndex=" 305 +pageIndex+"&pageSize="+pageSize+"&PAGESIZE="+pageSize, 306 function(result) 307 { 308 ComboBox_EndWebRequest(sender, result); 309 },null,false); 310 comboxReqeust.Start(); 311 } 312 /** 313 * 显示值 314 * @param {Object} sender 315 * @param {Object} result 316 */ 317 function ComboBox_EndWebRequest(sender, result) 318 { 319 // 320 if (!sender.getAttribute("isFocus")) return; 321 var container = $get(sender.id + "Container"); 322 //创建标题行 323 var headerTable = container.childNodes[0].childNodes[0]; 324 if (!headerTable) 325 { 326 //创建标题行table 327 headerTable=document.createElement("table"); 328 headerTable.setAttribute("border", "0px"); 329 headerTable.cellPadding = "0px"; 330 headerTable.cellSpacing = "0px"; 331 headerTable.style.width="100%"; 332 container.childNodes[0].appendChild(headerTable); 333 //添加行 insertRow(-1) -1表示追加最后一行 334 var header=headerTable.insertRow(-1); 335 header.className="TableHeader"; 336 //给标题行header添加表格cell 337 var headerCell=header.insertCell(-1); 338 headerCell.className="TableHeaderCell"; 339 headerCell.noWrap=true; 340 headerCell.style.width="25px"; 341 headerCell.innerHTML="&nbsp;&nbsp;"; 342 //给表格填充值、设置相关属性 343 var columnNames=sender.getAttribute("columnName").split(","); 344 var columnWidths=sender.getAttribute("columnWidth").split(","); 345 for(var i=0;i<columnNames.length;i++) 346 { 347 var headerCell=header.insertCell(-1); 348 headerCell.className="TableHeaderCell"; 349 headerCell.noWrap=true; 350 headerCell.align="center"; 351 if (columnWidths[i]) 352 { 353 headerCell.style.width=columnWidths[i]; 354 } 355 headerCell.innerHTML=columnNames[i]; 356 } 357 } 358 //创建内容行 359 var table = container.childNodes[1].childNodes[0]; 360 if (!table) 361 { 362 var pageSize=sender.getAttribute("pageSize")?parseInt(sender.getAttribute("pageSize")):20; 363 var rowCount=result.totalCount?result.totalCount:result.totalCount; 364 var pageCount=Math.ceil(rowCount/pageSize)+1; 365 sender.setAttribute("pageCount",pageCount); 366 sender.setAttribute("rowCount",rowCount); 367 //创建内容table 368 table=document.createElement("table"); 369 table.setAttribute("border", "0px"); 370 table.cellPadding = "0px"; 371 table.cellSpacing = "0px"; 372 table.style.width="100%"; 373 table.style.display="none"; 374 container.childNodes[1].appendChild(table); 375 } 376 //获取lastIndex 377 var lastIndex=table.rows.length-1; 378 //在遍历result 379 if (sender.getAttribute("OnDataBind")) 380 { 381 eval(sender.getAttribute("OnDataBind"))(sender,result); 382 } 383 else 384 { 385 ComboBox_DataBind(sender,result); 386 } 387 388 table.style.display="block"; 389 var rows=result.data; 390 if (!rows) return; 391 if (rows.length>0) 392 { 393 table.setAttribute("rowIndex", lastIndex+1); 394 container.childNodes[1].scrollTop=table.rows[lastIndex+1].offsetTop; 395 } 396 } 397 function ComboBox_ItemSelected(item,e) 398 { 399 eval(selection.getAttribute("command"))(selection,item.object); 400 ComboBox_Hidden(selection); 401 } 402 function ComboBox_DataBind(sender,result) 403 { 404 if (!result) return; 405 var container = $get(sender.id + "Container"); 406 var headerTable = container.childNodes[0].childNodes[0]; 407 var table = container.childNodes[1].childNodes[0]; 408 409 var lastIndex=table.rows.length-1; 410 var rows=result.data; 411 if (!rows) return; 412 var fieldNames=sender.getAttribute("fieldName").split(","); 413 var aligns=new Array(); 414 if (sender.getAttribute("align")) 415 { 416 aligns=sender.getAttribute("align").split(","); 417 } 418 var dataTypes=new Array(); 419 if (sender.getAttribute("dataTypes")) 420 { 421 dataTypes=sender.getAttribute("dataTypes").split(","); 422 } 423 for (var i=0;i<rows.length;i++) 424 { 425 //table下创建row 426 var row=table.insertRow(-1); 427 row.className=(i==0?"TableRowOverSpeed":"TableRow"); 428 row.onmouseover=function (){if (this.className!=‘TableRowSelected‘) this.className=‘TableRowOverSpeed‘}; 429 row.onmouseout=function (){if (this.className!=‘TableRowSelected‘) this.className=‘TableRow‘}; 430 row.onmousedown=function (e){if (e){event=e};event.cancelBubble=true;ComboBox_ItemSelected(this,event);}; 431 //rwo select 单击方法 432 row.select=function (){ComboBox_ItemSelected(this,event);}; 433 row.object=rows[i]; 434 //创建 ”序列“ 列 435 var cell=row.insertCell(-1); 436 cell.className="TableCellIndex"; 437 cell.innerHTML=i+lastIndex+2; 438 cell.style.width="30px"; 439 cell.align="center"; 440 441 for (var j=0;j<fieldNames.length;j++) 442 { 443 //创建表格cell 444 var cell=row.insertCell(-1); 445 cell.className="TableCell"; 446 //创建表格cell宽 447 var width=headerTable.rows[0].cells[j+1].clientWidth; 448 cell.style.width=width+"px"; 449 //设置align 450 if (aligns[j]) 451 { 452 cell.align=aligns[j]; 453 } 454 //获取值 455 var value=rows[i][fieldNames[j]]; 456 cell.title = rows[i][fieldNames[j]]; 457 if (value) 458 { 459 if (dataTypes[j]=="float") value=parseFloat(value).toFixed(4); 460 } 461 //填充值 462 cell.innerHTML="<div style=‘overflow:hidden;width:"+width+"px;height:100%‘>"+(value?value:"&nbsp;")+"</div>"; 463 } 464 } 465 }

快速查询 jsp页面 和 js方法

原文地址:http://www.cnblogs.com/liujie-e2/p/7204738.html