2012-12-13 44 views
1

我有一个网格,我想过滤一些结果。为了过滤结果,打开一个弹出窗口,用户可以选择搜索条件并过滤结果。 PHP文件被执行以及结果返回到弹出窗口,但它不显示在主网格中。这是我的代码。 这个代码显示网格和当用户选择用于滤波目的的单选按钮被显示结果:extjs 3.4数据不能从弹出网格显示到主网格

var checkModel = new xg.CheckboxSelectionModel(); 

var orderGridPanel = { 
    id: 'orderGridPanel', 
    xtype: 'editorgrid', 
    title: 'Orders', 
    height:350, 
    clicksToEdit: 2, 
    frame: true, 
    viewConfig: { 
     forceFit:true 
    }, 
    cm: new xg.ColumnModel({ 
      defaults: { 
       width: 120, 
       sortable: true 
      }, 
    columns: [ 
     {header:"nr",dataIndex:'nr',hidden:true} 
     ,checkModel 
     ,{header:"Order Id",dataIndex:'order'} 
     ,{header:"Order Date",dataIndex:'date', renderer:Ext.util.Format.dateRenderer('m/d/Y')} 
     ,{id:'created_by',header:"Order By",dataIndex:'created',align:'left'} 
     ,{id:'order_type',header:"Order Source",dataIndex:'order',align:'left'} 
     ,{header:"Order Type", dataIndex:'category'} 
     ,{header:"Sub Category",dataIndex:'sub_cate_nm'} 
     ,{header:"Item",dataIndex:'item'} 
     ,{header:"Properties",dataIndex:'order'} 
     ,{header:"Status",dataIndex:'order'} 
     ,{header:"Action",renderer: renderViewResults} 


    ] 
    }), 
    sm: checkModel, 
    store: new Ext.data.Store({ 
     root: 'results', 
     method: 'POST', 
     autoSave: false, 
     batch: true, 
     proxy: new Ext.data.HttpProxy({ 
     api: { 
      read: 'results.php?task=LISTING', 
      create: 'results.php?task=CREATE', 
      update:'results.php?task=UPDATE', 
      destroy: 'results.php?task=DELETE' 
     } 
     }), 
     writer: new Ext.data.JsonWriter({ 
      encode: true, 
      writeAllFields: true, 
      batch: true 
     }), 
     reader: new Ext.data.JsonReader({ 
      totalProperty: 'total', 
      successProperty: 'success', 
      idProperty: 'nr', 
      root: 'results', 
      fields: ['nr','order','date', 'created', 'type', 'category', 'sub_category_nm', 'item', 'properties', 'status'] 
     }), 
     baseParams: ahist_order_params 
    }),  
    bbar:[ 
    '-',{ 
     text: 'Add', 
     iconCls: 'icon-add', 
     handler: function(){ 
      editMoreData(0); 
     } 
    }, 
    '-', { 
     text: 'Search', 
     iconCls: 'icon-search', 
     handler: function(){ 
      displaySearchFilter(origid); 
     } 
    }, 

    '-',{ 
     text: 'Sign Orders', 
     iconCls: 'icon-warning', 
     handler: function(){ 
      displaySearchFilter(); 
     } 
    }, 
    '-',{ 
     text: 'Cancel', 
     iconCls: 'icon-delete', 
     handler: function(){ 
      displaySearchFilter(); 
     } 
    }, 

    '-', { 
     text: 'Refresh', 
     iconCls: 'icon-table_refresh', 
     handler: function(){ 
      Ext.getCmp('orderGridPanel').stopEditing(false); 
      var rs = orderGridPanel.store.getModifiedRecords(); 
      if (rs.length > 0) { 
       var status = window.confirm("Some data modified on grid, do you want to save grid data before loading latest data ?"); 
       if (status){     
        orderGridPanel.store.save(); 
       } 
      } 
      orderGridPanel.store.load(); 
     } 
    }, 
    '-', { 
     text: 'Print', 
     iconCls: 'icon-print', 
     handler: function(){ 
      statusStr = getHistGridSelection(); 

     } 
    } 
    ,'->' 
    ,'Display:','-', 
    { 
     xtype: 'radio', 
     name: 'search_filter', 
     id:'search_filter_1', 
     inputValue: 1, 
     boxLabel: 'Open Orders', 
     handler: onChangeLoadFilter , 
     checked : true 
    },'-',{ 
     xtype: 'radio', 
     name: 'search_filter', 
     id:'search_filter_2', 
     inputValue: 2, 
     boxLabel: 'All Orders', 
     handler: onChangeLoadFilter 
    },'-',{ 
     xtype: 'radio', 
     name: 'search_filter', 
     id:'search_filter_3', 
     inputValue: 3, 
     boxLabel: 'Orders 5 days back', 
     handler: onChangeLoadFilter 
    } 
    ,'-',{ 
     xtype: 'radio', 
     name: 'search_filter', 
     id:'search_filter_4', 
     inputValue: 4, 
     boxLabel: 'Cancelled Orders', 
     handler: onChangeLoadFilter 
    } 



] 
}; 

现在,当我点击搜索按钮代码执行:

function displaySearchFilter(id){  

    var formPanel = new Ext.FormPanel({ 
     frame: true, 
     labelWidth:150, 
     bodyStyle: 'padding:5px 5px 0', 
     items: [{ 
      xtype: 'fieldset', 
      defaultType: 'textfield', 
      items: [ 
      { 
      xtype  : 'container', 
      border  : false, 
      layout  : 'column', 
      anchor  : '100%', 
      style  : 'margin-top:8px;margin-bottom:8px;', 
      defaultType : 'field',items :[ 
      { 
       xtype: 'label', 
       style: 'float: left; margin-left:3px;margin-top:3px;', 
       text: 'From' 

      }, 
      { 
       fieldLabel: 'From Date', 
       xtype: 'datefield', 
       id: 'from_date', 
       style: "float: left; margin-left:3px;", 
       width:70 
      }, 
      { 
       xtype: 'label', 
       style: 'float: left; margin-left:5px;margin-top:3px;', 
       text: 'To' 

      }, 
      { 
       fieldLabel: 'To Date', 
       xtype: 'datefield', 
       id: 'to_date', 
       style: 'float: left; margin-left:5px;', 
       width:70 


      }, 
      { 
       xtype: 'label', 
       style: 'float: left; margin-left:5px;margin-top:3px;', 
       text: 'Patient' 

      }, 
      { 
       fieldLabel: 'Patient ID', 
       id:'patient',  
       xtype: 'textfield', 
       style: 'float: left; margin-left:5px;', 
       value: btpacs.data.Origid, 
       mode:'local' 




      }, 

      { 
       xtype:'label', 
       style:'float:left;margin-left:5px;margin-top:3px;', 
       text:'Display' 
      }, 



      { 
       xtype:'combo', 
       id:'search_filter', 
       store:btpacs.data.searchFilter, 
       typeAhead: true, 
       mode: 'local', 
       triggerAction: 'all', 
       selectOnFocus: true, 
       lastQuery: '',   
       emptyText:'Select an option...', 
       width : 120 
      } 
      ]}, 
      { 
       xtype: 'combo', 
       fieldLabel: 'Order Type', 
       name: 'category', 
       id:'cat', 
       store: btpacs.data.CpoeCategory, 
       hiddenName: 'category', 
       triggerAction: 'all', 
       emptyText:'Select an option...', 
       width : 300, 
       mode: 'local', 
       lastQuery: '', 
       listeners : { 
       select : function (f, e){ 
        //params: { cat_id: Ext.getCmp('cat').getValue()} 
        //subCategoryStore.load(); 
        var category_id = Ext.getCmp('cat').getValue(); 
        subCategoryStore.reload({ 
           params: { cat_id: category_id} 
          }); 
       } 
      } 
      }, 
      { 
       xtype: 'multiselect', 
       fieldLabel: 'Sub Category', 
       name: 'sub_category', 
       id:'sub_cat', 
       displayField: 'sub_cat_name', 
       valueField: 'sub_cat_id', 
       store: subCategoryStore, 
       hiddenName: 'sub_category', 
       emptyText:'Select Order Type First...', 
       triggerAction: 'all', 
       width : 300, 
       mode: 'local', 
       listeners : { 
       click : function (f, e){ 

        var sub_cat_id = Ext.getCmp('sub_cat').getValue(); 
        itemStore.reload({ 
           params: { sub_cat_ids: sub_cat_id} 
          }); 
       } 
      } 
      }, 
      { 
       xtype: 'multiselect', 
       fieldLabel: 'Items', 
       name: 'items', 
       displayField: 'item_name', 
       valueField: 'item_id', 
       store:itemStore, 
       hiddenName: 'items', 
       triggerAction: 'all', 
       width : 300, 
       mode: 'local' 
      }, 
      {     
       xtype : "multiselect", 
       fieldLabel : "Doctor List", 
       id: 'placed_doctor_name', 
       displayField: 'name', 
       valueField: 'name', 
       typeAhead: true, 
       mode: 'local', 
       triggerAction: 'all', 
       selectOnFocus: true, 
       lastQuery: '',      
       store:doctorStore, 
       width : 300 
      }] 
     }], 
     buttons: [{ 
      text: 'Search',handler: function() { 
      formPanel.getForm().submit({ 
       method: 'POST', 
       url: 'ajax/results.php?task=SEARCH', // when this file is executed the result is return properly as I want 
       root: 'results', 
       params : {'origid': origid}, 
        success: function(f, a) { 
        // after the result is successfully returned I cannot display it here.I am not sure what I am missing.Here I want to assign all the result to orderGridPanel 
        win.close(); 
        }, 
        failure: function(f, a) { 
         alert("Request failed"); 
         f.markInvalid(a.result.errors); 

        } 
       }); 
      } 
     }, 
     { 
      text: 'Cancel', 
      handler: function() { 
       win.close(); 
      } 
     }] 
    }); 

    win = new Ext.Window({ 
     layout: 'fit', 
     width: 650, 
     height: 520, 
     defaults: { 
      autoScroll: true 
     }, 
     closeAction: 'close', 
     title: 'Search Orders', 
     plain: true, 
     items: [formPanel] 
    }); 

    win.show(); 


} 

由于在提前。

+0

origid正在哪里设置? – Maggie

回答

0

如果您希望网格显示数据,则需要将数据加载到网格的商店中。

+0

你能告诉我如何将数据分配给网格 – user1901688