PDA

View Full Version : Add item to combobox takes two calls to "insert" ...



milanz
7 Sep 2007, 6:33 AM
I'm using extjx-1.1. I'm simply trying to add combobox items on the fly after a user clicks a "Filter Data" button. This way users have a history of the parameters they entered. However, my code below does not seem to work. It takes two clicks to "btnFilter_onClick" inorder for the item to be added and mozilla throws an error. Seems to be consistent in all browsers. Mozilla throws the following error:

Error: [Exception... "'Permission denied to get property HTMLDivElement.nodeType' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]



init : function() {
...

this.lastName = new Ext.form.ComboBox({
transform: 'lastName',
typeAhead: true,
triggerAction: 'all',
emptyText: '%',
width:130,
mode: 'local',
displayField: 'text',
valueField: 'text',
store: new Ext.data.SimpleStore({
fields: ['text'],
data : [
['Test1'],
['Test2']
]
})
});

...
}

btnFilter_onClick : function(e) {
...

var it = Simple.lastName.getRawValue();
Simple.lastName.store.insert(0, new Ext.data.Record({text: it}));
}



Thanks for the help. Starting to pull my hair on this one :D

milanz
8 Sep 2007, 8:18 PM
bump. anyone?

Animal
8 Sep 2007, 9:40 PM
Have you stepped through your code in Firebug?

milanz
11 Sep 2007, 10:55 AM
[Correction]
The data store actually contained all the items but was not rendering them to the combobox.

Here is a link to the sample code. The combobox I am refering to is the lastname field:
http://192.139.190.53:7010/project2/interface.html

Thanks again.

Harsha
11 Sep 2007, 12:38 PM
I had similar issue. Calling clearFilter() method on datastore fixed my problem. I am not sure whether it will fix your issue or not. Try "Simple.lastName.store.clearFilter();" statement before "Simple.lastName.store.insert(0, new Ext.data.Record({text: it}));".

Please post the outcome.

milanz
11 Sep 2007, 1:08 PM
I would have never thought to try calling that in a million years! It worked!

Now interestingly enough though Firefox still throws an exception (but it still adds the item):
Error: [Exception... "'Permission denied to get property HTMLDivElement.nodeType' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

I stepped through it repeatedly, but cannot find where the exception is coming from. It only seems to happen when I'm not stepping through the code and Mozilla doesn't seem to give a line number.

Throwing a try block around the insert does the trick, but of course it's not a good idea.