日期:2014-05-16  浏览次数:20661 次

求助 extjs grid表的显示问题
我想通过表单传给后台一个参数 然后后台从数据库中返回一个数组给我 然后根据参数的不同 grid显示的也不同,但是总是不显示第二次的数据 求大神帮忙~贴码如下
//表单配置
 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);
?>

------解决方案--------------------
你的版本应该不是ext4+以上的,自己找对应的api来看看参数是什么,ext4+以上这个方法是这样重新配置cm的