Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#3907 closed defect (fixed)

fetch with initial query in ComboBox stopped working

Reported by: haysmark Owned by: haysmark
Priority: high Milestone: 0.9
Component: Dijit - Form Version: 0.9
Keywords: Cc:
Blocked By: Blocking:


In, test_ComboBox, the "ComboBox? with an initial query" is not opening the menu. Last rev I tried this was [9870], but I can't say it was related to that rev. I debugged the code and it appears that the fetch (in ComboBox? _startSearch) is not returning any results to the callback, even though the browser reports that the XHR succeeds. This only affects that particular ComboBox?. I do not know what is going on inside fetch, but it is strange.

Change History (6)

comment:1 Changed 14 years ago by Jared Jurkiewicz

The problem isn't with The problem is you're not passing the query option:


To the search in a dataset that is very hierarchical. See your dataset (which is not a flat list, it has structure): { identifier: 'name',

items: [

{ name:'Africa', type:'continent', children:[

{ name:'Egypt', type:'country' }, { name:'Kenya', type:'country', children:[

{ name:'Nairobi', type:'city' }, { name:'Mombasa', type:'city' } ]

}, { name:'Sudan', type:'country', children:

{ name:'Khartoum', type:'city' }

} ]

}, { name:'Asia', type:'continent', children:[

{ name:'China', type:'country' }, { name:'India', type:'country' }, { name:'Russia', type:'country' }, { name:'Mongolia', type:'country' } ]

}, { name:'Australia', type:'continent', population:'21 million', children:

{ name:'Commonwealth of Australia', type:'country', population:'21 million'}

}, { name:'Europe', type:'continent', children:[

{ name:'Germany', type:'country' }, { name:'France', type:'country' }, { name:'Spain', type:'country' }, { name:'Italy', type:'country' } ]

}, { name:'North America', type:'continent', children:[

{ name:'Mexico', type:'country', population:'108 million', area:'1,972,550 sq km', children:[

{ name:'Mexico City', type:'city', population:'19 million', timezone:'-6 UTC'}, { name:'Guadalajara', type:'city', population:'4 million', timezone:'-6 UTC' } ]

}, { name:'Canada', type:'country', population:'33 million', area:'9,984,670 sq km', children:[

{ name:'Ottawa', type:'city', population:'0.9 million', timezone:'-5 UTC'}, { name:'Toronto', type:'city', population:'2.5 million', timezone:'-5 UTC' }]

}, { name:'United States of America', type:'country' } ]

}, { name:'South America', type:'continent', children:[

{ name:'Brazil', type:'country', population:'186 million' }, { name:'Argentina', type:'country', population:'40 million' } ]

} ]


All your 'country' items are not top-level items. Since they are not top-level, they are not searched by default (Brian Skinner's original pass on doing a hierarchical structured store had a bug in how it was storing and searching hierarchy that was actually fixed in #3862. Basically, it was searching all the items when it wasn't supposed to (it wasn't honoring the setting of deep).

There are two ways to deal with this with ComboBox?.

1.) comboBox should pass a query option of deep:true to the store. or: 2.) The dataset should use the reference way of building a hierarchy so that all the items are effectively top-level items.

The simpler solution, since ComboBox? probably doesn't care about hierarchical structure, is to set deep:true in the query options, like how you set it to ignoreCase.

As an aside: Doing deep versus shallow searching is necessary for things such as a Tree widget (or any widget that displays data in a hierarchical format). You certainly do not generally want to return a flattened list for a tree (hence why it has shallow and deep search modes).

You would effectively just need to change:{queryOptions:{ignoreCase:this.ignoreCase, deep:true}, query: query, onComplete:dojo.hitch(this, "_openResultList"), count:this.searchLimit});

To add that deep option to line 419. Since your dataset isn't a flat list. Or, you can convert your dataset to be a flat list with references. Your choice.

comment:2 Changed 14 years ago by Jared Jurkiewicz

Component: DataDijit
Owner: changed from Jared Jurkiewicz to haysmark

comment:3 Changed 14 years ago by Jared Jurkiewicz

As an aside, from the API docs in

The *queryOptions* parameter The queryOptions parameter is an optional parameter used to specify optiosn that may modify the query in some fashion, such as doing a case insensitive search, or doing a deep search where all items in a hierarchical representation of data are scanned instead of just the root items. It currently defines two options that all datastores should attempt to honor if possible: { ignoreCase: boolean, Whether or not the query should match case sensitively or not. Default behaviour is false. deep: boolean Whether or not a fetch should do a deep search of items and all child items instead of just root-level items in a datastore. Default is false. }

comment:4 Changed 14 years ago by haysmark

Pending #3169.

comment:5 Changed 14 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [9925]) Fixes #3907. Proxy commit for haysmark. Updated fetch signature in ComboBox? and FilteringSelect? to support "deep" data. Added a deep data test to test_FilteringSelect.

comment:6 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.