Note that there are some explanatory texts on larger screens.

plurals
  1. POComboBox.store.loadData can't load single-item array
    primarykey
    data
    text
    <p>I am using ExtJS 3.4 . I have a structure with data for combobox like this:</p> <pre><code>var a = [[1,"text1"],[2,"text2"]] </code></pre> <p>I load it like this:</p> <pre><code>ComboBox.store.loadData(a); </code></pre> <p>But when I have only 1 item in the array</p> <pre><code>var a = [[1,"text1"]] </code></pre> <p>then it doesn't load at all. I've read that:</p> <blockquote> <p>an Array : Arrays will be converted to a Ext.data.ArrayStore internally, automatically generating field names to work with all data components. 1-dimensional array : (e.g., ['Foo','Bar']) A 1-dimensional array will automatically be expanded (each array item will be used for both the combo valueField and displayField) 2-dimensional array : (e.g., [['f','Foo'],['b','Bar']]) For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo valueField, while the value at index 1 is assumed to be the combo displayField.</p> </blockquote> <p>But that doesn't explain how do I load an array with one element. Or whatever, it shouldn't be necessary an array, the point is to load only one item. I've tried loading this: Code:</p> <pre><code>[{id:1,text:"text1"}] [[{id:1,text:"text1"}]] {id:1,text:"text1"} </code></pre> <p>Even creating a custom ArrayStore:</p> <pre><code>Code: var store = new Ext.data.ArrayStore({ autoDestroy: true, storeId: 'Store1', idProperty:"id", fields: ["id","text"]); ComboBox.store = store; ComobBox.store.loadData([{id:1,text:"text1"}]); </code></pre> <p>But everything loads incorrectly . Either the combobox is empty, or it displays id instead of text.</p> <p>I can see that if I lazily init the combo: Code:</p> <pre><code>{"xtype":"combo","width":250,"fieldLabel":"my combo","value":31029,"forceSelection":true,"hiddenName":"ComboHiddenName","minChars":1,"triggerAction":"all","store":[[31029,"gdfs"]]} </code></pre> <p>then the array with one item will load successfully. At which properties of ComboBox.store should I look to configure them properly for a single-item array to be loaded correctly using loadData method?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload