文檔半島外圍網(wǎng)上直營(yíng)>>jQuery EasyUI使用教程>>jQuery EasyUI使用教程:過(guò)濾ComboGrid
jQuery EasyUI使用教程:過(guò)濾ComboGrid
Kendo UI for jQuery——?jiǎng)?chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫(kù)!查看詳情>>>
Combogrid組件和Combobox組件的共同點(diǎn)是,除了都具有下拉面板以外,它們都是基于數(shù)據(jù)網(wǎng)格的。Combogrid組件可以過(guò)濾、分頁(yè),并具有其他一些數(shù)據(jù)網(wǎng)格的功能。本教程向您展示如何在一個(gè)Combogrid組件中過(guò)濾數(shù)據(jù)記錄。

創(chuàng)建Combogrid
<input id="cg" style="width:150px">
$('#cg').combogrid({ panelWidth:500, url: 'form5_getdata.php', idField:'itemid', textField:'productid', mode:'remote', fitColumns:true, columns:[[ {field:'itemid',title:'Item ID',width:60}, {field:'productid',title:'Product ID',align:'right',width:80}, {field:'listprice',title:'List Price',align:'right',width:60}, {field:'unitcost',title:'Unit Cost',align:'right',width:60}, {field:'attr1',title:'Attribute',width:150}, {field:'status',title:'Stauts',align:'center',width:60} ]] });
Combogrid組件應(yīng)該定義'idField'和'textField'屬性。 'idField'屬性存儲(chǔ)組件值,'textField'屬性在input文本框中顯示文本消息。Combogrid組件可以以'local'或'remote'模式過(guò)濾記錄。 在遠(yuǎn)程模式中,當(dāng)用戶輸入字符到input文本框中,Combogrid將發(fā)送 'q' 參數(shù)到遠(yuǎn)程服務(wù)器。
服務(wù)器代碼
form5_getdata.php
$q = isset($_POST['q']) ? strval($_POST['q']) : ''; include 'conn.php'; $rs = mysql_query("select * from item where itemid like '%$q%' or productid like '%$q%'"); $rows = array(); while($row = mysql_fetch_assoc($rs)){ $rows[] = $row; } echo json_encode($rows);
下載EasyUI示例: