View Full Version : Issue with MemoryProxy and Jsonreader
Harsha
7 Sep 2007, 12:35 AM
I am using the following code to load a combobox. But the combo box is not getting load.
Any help on this is appreaciated
Thanks
var j = {"totalCount":"3","customGroups":[{ "FId": "13438", "FName": "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },{ "FId": "13435", "FName": "Satya" },{ "FId": "13437", "FName": "Satya2" }]};
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(j),
reader: new Ext.data.JsonReader({
root: 'customGroups',
totalProperty: 'totalCount',
id: 'FId'
}, [
{name: 'FName', mapping: 'FName'}
])
});
var search = new Ext.form.ComboBox({
store: ds,
displayField:'FName',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Hai',
selectOnFocus:true
});
// apply it to the exsting input element
search.applyTo('Keyword');
MaximGB
7 Sep 2007, 12:52 AM
1. Use code tags next time.
2. mode: 'local', local means get data from select options, if you have data in memory this is actualy not local ;) it's remote.
Harsha
7 Sep 2007, 1:14 AM
Thanks Maxim, Now I can see the data in the combo dropdown. However once I start typing the text in the text area of the combo, filter is not happening. I want to implement a functionality similar to the "State" combo box given in the examples.
How can I achieve this?
Animal
7 Sep 2007, 1:51 AM
I think you need http://extjs.com/deploy/ext-1.1.1/docs/output/Ext.form.ComboBox.html#config-forceSelection
Harsha
7 Sep 2007, 7:12 AM
Hi Animal,
Sorry for not being clear. I do not want to implement "force selection".
Once I start typing in the combo box, filtering of the drop down values is not happening.
It is working like this
1. With out typing if I press the drop down, I am seeing all the three values
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Satya
Satya2
This is fine
2. Issue is when I start typing "S" in the text area, I want to dropdown to show up with the following two values. In my case dropdown shows up only sometimes and with all the three values.
Satya
Satya2.
Appreciate if you could let me know what I am doing wrong.
Thanks in Advance
Harsha
Animal
7 Sep 2007, 10:37 AM
This works perfectly for me:
Ext.onReady(function() {
var j = {
"totalCount":"3",
"customGroups":[
{ "FId": "13438", "FName": "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
{ "FId": "13435", "FName": "Satya" },
{ "FId": "13437", "FName": "Satya2" }
]};
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(j),
reader: new Ext.data.JsonReader({
root: 'customGroups',
totalProperty: 'totalCount',
id: 'FId'
}, [{name:'FName', mapping:'FName'}])
});
ds.load();
var search = new Ext.form.ComboBox({
store: ds,
displayField:'FName',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Hai',
selectOnFocus:true
});
// apply it to the exsting input element
search.applyTo('Keyword');
});
Harsha
10 Sep 2007, 7:04 AM
Once I again thanks animal. You are savior.
I see that you have used ds.load() statement before defining the combobox.
The following alternative also worked. I am mentioning this here for beginners like me.
<code>
var ds2 = new Ext.data.JsonStore({
fields: ['FId', 'FName'],
data : eval(j.customGroups)
});
var search2 = new Ext.form.ComboBox({
store: ds2,
displayField:'FName',
typeAhead: true,
triggerAction: 'all',
emptyText:'',
mode: 'local',
selectOnFocus:true,
resizable:true
});
// apply it to the exsting input element
search2.applyTo('Keyword2');
</code>
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.