jQuery EasyUI使用教程之过滤ComboGrid

Combogrid组件和Combobox组件的共同点是,除了都具有下拉面板以外,它们都是基于数据网格的。Combogrid组件可以过滤、分页,并具有其他一些数据网格的功能。本教程向您展示如何在一个Combogrid组件中过滤数据记录。

创建树形下拉框
创建Combogrid
1
< input id = "cg" style = "width:150px" >
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$( '#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组件应该定义'idField'和'textField'属性。 'idField'属性存储组件值,'textField'属性在input文本框中显示文本消息。Combogrid组件可以以'local'或'remote'模式过滤记录。 在远程模式中,当用户输入字符到input文本框中,Combogrid将发送 'q' 参数到远程服务器。

服务器代码

form5_getdata.php

1
2
3
4
5
6
7
8
9
10
$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示例:easyui-form-demo.zip

有兴趣的朋友可以点击查看更多有关jQuery EasyUI的教程>>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值