0

I have been trying this from two days but unable to found a solution for this. What i am tying to do is remotely loading the data into the store here is my code for that:

var ds = Ext.create('Ext.data.ArrayStore', {
        proxy: {
        type: 'ajax',
        url : './index.php/firewall/loadRules',
        },      
        fields: ['value','text'],           
        totalProperty: 'num',  
        sortInfo: {
                    field: 'value',
                    direction: 'ASC'
                  }     
    }); 

    ds.load();

After this assigning this store to multiselect component and the codes for that is here:

var form_number_list = Ext.create('Ext.form.Panel', {
        border: false,      
        bodyPadding: 5,
        id: 'form_number_list',
        width: '35%',
        height: '100%',
        flex: 3,
        items: [{
            anchor: '93%',
            xtype: 'multiselect',
            msgTarget: 'side',            
            name: 'multiselect',
            id: 'fire_select',
            allowBlank: false,
            minSelections: 1,
            maxSelections: 1,
            store: ds
        }]
    });

The ajax call is returning this value:

[['012345', '012345'], ['012346', '012346'], ['01234567', '01234567'], ['546747', '546747'], ['54663', '54663'], ['546638', '546638'], ['46767638', '46767638'], ['63568545868', '63568545868'], ['6368688', '6368688'], ['35468488', '35468488'], ['84584845', '84584845'], ['56345738', '56345738'], ['533478', '533478'], ['583477', '583477'], ['563457548', '563457548'], ['53755438', '53755438'], ['53657648', '53657648'], ['5367764', '5367764'], ['563673673', '563673673'], ['5436638', '5436638'], ['46363773', '46363773'],]

Now after this in the browser, the multiselect box is getting this many item loaded but their values are not getting displayed i mean all items are empty items. In firebug i can see empty "li" tags for all the items.

Rahul Kanodia
  • 105
  • 12
  • the multiselect xtype is an extended component ? because the api for extjs doesn't have it. – nscrob Sep 06 '11 at 06:39

2 Answers2

1

You either have to remove root: 'data', from store config or modify server response so that it would look like:

{data: [['012345', '012345'], ['012346', '012346'], /* ... */ ]}
Molecular Man
  • 22,277
  • 3
  • 72
  • 89
  • @ Molecule Man: I have solved the issue by using one of yours answer http://stackoverflow.com/q/6767744/896107 Thanks man :) – Rahul Kanodia Sep 06 '11 at 07:10
1

You have missed out the field mapping properties for your multiselect. You will have to add:

displayField: 'text',
valueField: 'value'

to your multiselect. Also, keep in mind that it is best to return a proper json rather than an array because, you seems to be making use of total property. You can use json as follows:

{"rows": [{"text" : "012345","value": "012345"},{"text": "012346","value": "012346"},{"text": "01234567","value": "01234567"},{"text": "546747","value": "546747"}],"num": 4}

To do so, you will have to go with a JsonStore rather than Array. Is there any particular reason you choose ArrayStore?

Abdel Raoof Olakara
  • 19,223
  • 11
  • 88
  • 133
  • Thanks buddy for the solution. I too have figured out the solution for this issue from Molecule Man's solution of different question. And there is no particular reason to choose ArrayStore i can even use JsonStore, but i this JsonStore will be much better to use. Thanks again :) – Rahul Kanodia Sep 06 '11 at 07:50
  • sorry about that.. i missed out the variable names while copy paste :) – Abdel Raoof Olakara Sep 06 '11 at 10:19