日期:2014-05-16 浏览次数:20717 次
//表单配置
var searchform = new Ext.form.FormPanel({
defaultType: 'textfield',
labelAlign: 'right',
labelWidth: 50,
width: 700,
border:false,
buttonAlign: 'center',
items: [{
id:"keyword",
fieldLabel: '关键词',
anchor: '90%'
}],
buttons: [{
text: '检索',
handler:search
}]
});
//搜索函数
var store;
var cm;
function search(){
var keyword = Ext.getCmp("keyword").getValue();
if (keyword =="")
{
Ext.Msg.alert("提示","不能为空");
}else {
Ext.Ajax.request({
url:'disease.php',
params:{keyword:keyword},
success:function(response,config){
Ext.Msg.alert('提示','已提交');
json=Ext.JSON.decode(response.responseText);
var cm = new Ext.grid.ColumnModel(json.columModel);
store = new Ext.data.JsonStore({
data:json.data,
fields:json.fieldsNames});
store.load();},
failure:function(){
Ext.Msg.alert('提示','提交失败!');}
});
}
}
var grid = new Ext.grid.GridPanel({
store:store,
cm:cm,
autoHeight:true,
enableColumnMove:false,
enableColumnResize:false,
loadMask: true,
viewConfig:{
forceFit:true
},
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
})
});
<?php
header("Content-Type: text/html;charset=utf-8");
header("Cache-Control: no-cache");
session_start();
include 'conn_sql.php';
$conn = accessToDB();
$disease = $_REQUEST["keyword"];
$sql = "select DiseaseName,Category1ID,Category2ID from disease_category where DiseaseName like '%".$disease."%' limit 12";
$query = mysql_query($sql,$conn);
while($row = mysql_fetch_array($query))
{
$arr[]=$row;
}
echo json_encode($arr);
?>