1. #1
    Ext User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    inel0910 is on a distinguished road

      0  

    Default Dynamic loading combobox with different http request address.

    Dynamic loading combobox with different http request address.


    I'm using two combobox in row editor.
    If user select 1st combobox's specific item,
    2nd combobox's has to be a dynamic loading(different data store or http request address).

    Code below
    PHP Code:
    var sapStore = new Ext.data.Store({ // Use in editor
        
    proxy: new Ext.data.HttpProxy({
            
    url'/' ses.config.contextUrl '/ws/admin/sap/selectServiceList?_type=json',
            
    method:'GET'
        
    }),
        
    reader: new Ext.data.JsonReader({
            
    root'sapservice',
            
    fields: [{name'serviceId'}]
        })
    });
     
    var 
    boeStore = new Ext.data.Store({ // Use in editor
        
    proxy: new Ext.data.HttpProxy({
            
    url'/' ses.config.contextUrl '/ws/admin/boe/selectServiceList?_type=json',
            
    method:'GET'
        
    }),
        
    reader: new Ext.data.JsonReader({
            
    root'boeservice',
            
    fields: [{name'serviceId'}]
        })
    });
     
    var 
    sapServiceIdEditor = new Ext.form.ComboBox({
        
    typeAheadtrue,
        
    triggerAction'all',
        
    lazyRender:true,
        
    mode'remote',
        
    editablefalse,
        
    autoSelecttrue,
        
    valueField'serviceId',
        
    displayField'serviceId',
        
    storesapStore
    });
     
     
    var 
    colModel = new Ext.grid.ColumnModel([
        new 
    Ext.grid.RowNumberer(),
        {
    header'Report ID'dataIndex'reportId'width150sortabletrue,
            
    editor: {xtype'textfield'allowBlankfalse}},
        {
    header'Report Name'dataIndex'reportName'width170sortabletrue,
            
    editor: {xtype'textfield'allowBlankfalse}},
        {
    header'Status'dataIndex'status'width80sortabletrue,
            
    renderer: function(valuemetaDatarecordrowIndexcolIndexstore) {
                if(
    value == 1)
                    return 
    'Active';
                else if(
    value == 0)
                    return 
    'Inactive';
            },
            
    editor: new Ext.form.ComboBox({
                
    typeAheadtrue,
                
    triggerAction'all',
                
    lazyRender:true,
                
    mode'local',
                
    editablefalse,
                
    autoSelecttrue,
                
    store: [[1'Active'], [0'Inactive']]
            })
        },
        {
    header'Service Type'dataIndex'serviceType'width100sortabletrue,
            
    editor: new Ext.form.ComboBox({
                
    typeAheadtrue,
                
    triggerAction'all',
                
    lazyRender:true,
                
    mode'local',
                
    editablefalse,
                
    autoSelecttrue,
                
    store: [['boequery''boequery'], ['sap''sap']],
                
    listeners: {
                    
    'select': function(comboridx) {
                        
    //serviceIdEditor.destroy();
                        
    serviceIdEditor.clearValue();
                        var 
    temp Ext.getDom('serviceIdEditor');
                        
    //var temp = serviceIdEditor.getEl();
                        //serviceIdEditor.store.load({});
                        
    if(combo.getValue() == 'sap') {
                            
    //serviceIdEditor.store.removeAll();
                            //serviceIdEditor.reset();
                            
    serviceIdEditor.store.destroy();
                            
    serviceIdEditor.store sapStore;
                            
    serviceIdEditor.store.load();
                            
    //serviceIdEditor.store.reload({});
                        
    }
                        else if(
    combo.getValue() == 'boequery') {
                            
    //serviceIdEditor.store.removeAll();
                            //serviceIdEditor.reset();
                            
    serviceIdEditor.store.destroy();
                            
    serviceIdEditor.store boeStore;
                            
    serviceIdEditor.store.load();
                            
    //serviceIdEditor.store.reload({});
                        
    }
                    }
                }
            })
        },
        {
    header'Service ID'dataIndex'serviceId'width150sortabletrue,
            
    //editor: {xtype: 'textfield', allowBlank: false}},
            
    editorserviceIdEditor},
        {
    header'Report Type'dataIndex'reportType'width90sortabletrue,
             
    editor: {xtype'textfield'allowBlankfalse}},
        {
    header'Description'dataIndex'description'width240sortabletrueid'description',
            
    editor: {xtype'textfield'allowBlanktrue}},
        {
    header'Layout File'dataIndex'layoutFile'width400sortabletrue,
            
    renderer: function(valuemetaDatarecordrowIndexcolIndexstore) {
                if((
    value != "") && (value != null)) {
                    
    //var fileId = Ext.util.Format.substr(value, 32, value.length);
                    
    return '<a href="/' ses.config.contextUrl '/ws/attach/getAttachment/'+value+'">'+value+'</a>';
                }
                else
                    return 
    "";
            },
            
    editor: {disabledtrue}},
        {
    header'Created'dataIndex'created'width120sortabletrue,
            
    renderer: function(valuemetaDatarecordrowIndexcolIndexstore) {
     
                if((
    value == "") || (value == null)) {
                    return;
                }
                
    value Ext.util.Format.substr(value019);
                var 
    dt Date.parseDate(value'Y-m-d\\TH:i:s');
                return 
    dt.format('Y-m-d H:i:s');
            },
            
    editor: {disabledtrue}}
    ]); 
    See a 'Service Type' & 'Service ID' in column model

    Thanks in advance &
    Sorry for bad English.

  2. #2
    Sencha User laurentParis's Avatar
    Join Date
    Aug 2010
    Location
    paris
    Posts
    246
    Vote Rating
    2
    laurentParis is on a distinguished road

      0  

    Default


    May be, you can config your combobox with an ArrayStore and use different Ext.Ajax request to loading your combobox manualy
    or if you need more dynamism, use beforeload store event for switch proxy URL.

  3. #3
    Ext User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    inel0910 is on a distinguished road

      0  

    Default


    Already I'm using different Ext.Ajax.requet method.
    But it looks dirty and not good for logical flow.

    Also, Using beforeload is impossible.
    Because changing address of request is fire when select event in 1st combobox.

    Do anyone can help?

  4. #4
    Sencha User laurentParis's Avatar
    Join Date
    Aug 2010
    Location
    paris
    Posts
    246
    Vote Rating
    2
    laurentParis is on a distinguished road

      0  

    Default


    use beforeload event on second combobox

  5. #5
    Ext User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    inel0910 is on a distinguished road

      0  

    Default


    Thank you for your reply.
    I try to handle a 'beforeload' event on 2nd combobox.
    But, it can't catch a event.
    I think it's more complex problem.

    Already I tried several event like 'beforeload'(store event), 'beforequery', 'beforerender' and so on.
    Some event could catch a event, but some event could not catch a event.
    Most important things is not work at all.

    Do you have any idea?
    Plz help me somebody else!
    Thanks.

  6. #6
    Sencha User laurentParis's Avatar
    Join Date
    Aug 2010
    Location
    paris
    Posts
    246
    Vote Rating
    2
    laurentParis is on a distinguished road

      0  

    Default


    don't pass params with string url
    PHP Code:
    var sapStore = new Ext.data.Store({ // Use in editor
        
    baseParams: {_type'json'},
        
    proxy: new Ext.data.HttpProxy({
            
    url'/' ses.config.contextUrl '/ws/admin/sap/selectServiceList',
            
    method:'GET'
        
    }),
    ... 
    modify your listeners
    PHP Code:
                        listeners: {
                            
    'select': function(comboridx) {
                                var 
    otherComboStore Ext.getCmp('otherCombo').getStore(), url '';
                                switch(
    r.data.field1) {
                                    case 
    'boequery':
                                        
    url 'http:url1';
                                        break;
                                    default:
                                        
    url 'http:url2';
                                }
                                
    otherComboStore.proxy.setUrl(urltrue);
                                
    otherComboStore.load();
                            }
                        } 

  7. #7
    Ext User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    inel0910 is on a distinguished road

      0  

    Default


    Really thank you for your concern.
    I tried your code, but it didn't work.
    Result is 2nd combo box did not change.
    It keep a first loaded value list.

    I think problem is render or request.
    Switching proxy url is ok. But,
    if code request and received value, finally rendered,
    it does not send a switched address request or not work expand.
    Maybe combobox has a 'rendered' tag or like responded option.
    Remove combobox's loaded value is possible, but request new data or render is not work.
    (Maybe user click a arrow to expand, combobox does not send a request)
    so, I can't see a switched data.

    Do you have any idea?

    Really thank you &
    Sorry for bad English.

  8. #8
    Sencha User laurentParis's Avatar
    Join Date
    Aug 2010
    Location
    paris
    Posts
    246
    Vote Rating
    2
    laurentParis is on a distinguished road

      0  

    Default


    modify this line please
    Code:
    otherComboStore.proxy.setUrl(url, true);
    I apply this fix on my first code !

Similar Threads

  1. How to use 1 http request with multiple combobox
    By metfan in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 7 Dec 2009, 8:39 AM
  2. Dynamic ComboBox loading
    By getsudhagar in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 13 Nov 2009, 11:16 AM
  3. HTTP Request
    By waltub in forum Ext GWT: Help & Discussion (1.x)
    Replies: 3
    Last Post: 11 Aug 2008, 1:20 PM
  4. ComboBox in Editable Grid Not Loading Dynamic XML
    By dschneider in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 21 Feb 2008, 6:42 AM
  5. Loading combo data with dynamic Server request
    By dende1979 in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 18 Sep 2007, 11:07 PM

Thread Participants: 1

Tags for this Thread