0

如果选择了 3 个组合框,我会搜索它们,选择的 valueid 通过 $POST 发送它们,然后通过 AJAX 发送到 PHP。

PHP 正在从组合框 id 的 mysql 查询中构建,并将其作为 JSON 发送回来。(JSON 已验证)

但是我的网格没有填满!我如何将过滤后的 id 数据放入我的网格中?

我的按钮

buttons:[
            {
                text:'Search',
                loadingText:'lädt',
                handler:function () {
                    var form = Ext.getCmp('searchPanel').getForm();
                    form.submit(
                        {url: 'php/search.php'}

               )

我经过验证的 JSON

"getRoutedata": [
    {
        "RouteID": "3",
        "Loadingpoint": "Hafencity",
        "Postalcode": "20457",
        "Containercity": "Uhlenhorst",
        "Carrier": "Bre SO",
        "Transportmodel": "Truck",
        "Containersize": "40",
        "Containertype": "Horizontal",
        "Harbor": "Antwerpen",
        "Price": "1000.00",
        "Year": "2012",
        "Misc": "test"
    }
]

我的商店

    storePPT = new Ext.data.JsonStore({
    url:'php/search.php',
    storeId:'myStore',
    root:'getRoutedata',
    stateful:true,
    idProperty:'RouteID',
    fields:[
        {name:'Carrier', type:'string', mapping:'Carrier'},
        {name:'Containercity', type:'string', mapping:'Containercity'},
        {name:'Containersize', type:'string', mapping:'Containersize'},
        {name:'Containertype', type:'string', mapping:'Containertype'},
        {name:'Harbor', type:'string', mapping:'Harbor'},
        {name:'Loadingpoint', type:'string', mapping:'Loadingpoint'},
        {name:'Misc', type:'string', mapping:'Misc'},
        {name:'Postalcode', type:'string', mapping:'Postalcode'},
        {name:'Price', type:'decimal', mapping:'Price'},
        {name:'Transportmodel', type:'string', mapping:'Transportmodel'},
        {name:'Year', type:'year', mapping:'Year'},
        {name:'RouteID', type:'int', mapping:'RouteID'}
    ]
});

非常感谢您的帮助!

4

1 回答 1

0

您需要有一个存储来保存来自您的 JSON 响应的解析数据和一个将显示来自该存储的数据的网格。喜欢:


//call this function in ajax success
function loadJsonData() {
   var myStore = Ext.create('Ext.data.JSONStore', {
                 fields: [
                         {name1: 'field_name1'},
                         {name2: 'field_name2'},
                         {name3: 'field_name3'}
                 ],
                 data: jsonData
    });
    // create the Grid
    var grid = Ext.create('Ext.grid.Panel', {
               store: myStore,
               stateful: true,
               stateId: 'stateGrid',
               columns: [ {
                       text : 'field_name1',
                       sortable : false,
                       dataIndex: 'field_name1' // add fields you want to display
               }, ... ]               
               renderTo: 'table' // add other params as you want
    });
};

希望能帮助到你

于 2012-04-27T07:24:56.457 回答