1
votes

I want to load the combo box with XML, but I am not able to get any values in the combo box, Here it is what I have done so far

var getMessageDomain = function () {
    var store = new Ext.data.Store({
        url: 'zport/getDomainFilters',
        autoLoad: true,
        reader: new Ext.data.XmlReader({
            record: 'Domain'
        }, [{
            name: 'name',
            mapping: '@name'
        }, ])
    });
    var combo = new Ext.form.ComboBox({
        width: 250,
        xtype: 'combo',
        mode: 'local',
        allowBlank: false,
        triggerAction: 'all',
        forceSelection: true,
        editable: false,
        fieldLabel: 'Message Domain',
        name: 'titlez',
        hiddenName: 'titlez',
        displayField: 'name',
        valueField: 'name',
        editable: false,
        store: store
    });
    return combo;
};

and my xml is something like this:

<TDSmessagedomain xmlns="">
  <Domain name="AEPL" /> 
  <Domain name="APAP" /> 
  <Domain name="BCP" /> 
  <Domain name="BTCI" /> 
  <Domain name="BGSET" /> 
  <Domain name="COLLCLIENT" /> 
  <Domain name="COLLINT" /> 
  <Domain name="CPL" /> 
  <Domain name="DBWS" /> 
.........................
1

1 Answers

1
votes

1) I encourage you to use an XmlStore, which will automatically configure an XmlReader for you.

var store = new Ext.data.XmlStore({
    autoLoad: true,
    url: 'zport/getDomainFilters',
    fields: ['name'],
    record: 'Domain'
});

2) This is untested, but I think you'll need to modify your XML structure a little bit. I don't know if it'll look for attributes in the record identifier.

<TDSmessagedomain xmlns="">
  <Domain>
    <name>AEPL</name>
  </Domain>
  <Domain>
    <name>APAP</name>
  </Domain>
</TDSmessagedomain>