Object has no method 'query'

510
2
07-09-2012 10:42 AM
KeithSandell
New Contributor III
I'm extending the "Add Shapefile" example to allow the user to select a column from the shapefile by which to set the symbology of the layer added...

Taking a featureCollection, extracting field names to populate a dijit.form.ComboBox:

This part works:
function populateColumnDropDown(featureCollection){
 names = featureCollection.layers[0].layerDefinition.fields;
 var fieldNames = [];
 for(i = 0; i < names.length; i++){
  if(names.name != "FID"){
   fieldNames.push({name:names.name});
  }
 }
 var dataItems = {
         identifier: 'name',
         label: 'name',
         items: fieldNames
 };
 var store = new dojo.data.ItemFileReadStore({data:dataItems});
 dijit.byId("columnInput").store = store;
}

<select id="columnInput" dojotype="dijit.form.ComboBox" style="width:150px;" value="Select Column" title="Select Column To Symbolize" fetchProperties="{sort:[{attribute:'name', descending:false}]}" onChange="setSymbology();" disabled></select>


No errors are thrown until I click the comboBox to see the values. Then it throws a: Object has no method 'query' error.

Any thoughts?
0 Kudos
2 Replies
JeffPace
MVP Alum
I'm extending the "Add Shapefile" example to allow the user to select a column from the shapefile by which to set the symbology of the layer added...

Taking a featureCollection, extracting field names to populate a dijit.form.ComboBox:

This part works:
function populateColumnDropDown(featureCollection){
 names = featureCollection.layers[0].layerDefinition.fields;
 var fieldNames = [];
 for(i = 0; i < names.length; i++){
  if(names.name != "FID"){
   fieldNames.push({name:names.name});
  }
 }
 var dataItems = {
         identifier: 'name',
         label: 'name',
         items: fieldNames
 };
 var store = new dojo.data.ItemFileReadStore({data:dataItems});
 dijit.byId("columnInput").store = store;
}

<select id="columnInput" dojotype="dijit.form.ComboBox" style="width:150px;" value="Select Column" title="Select Column To Symbolize" fetchProperties="{sort:[{attribute:'name', descending:false}]}" onChange="setSymbology();" disabled></select>


No errors are thrown until I click the comboBox to see the values. Then it throws a: Object has no method 'query' error.

Any thoughts?


Clicking it fires the "setSymbology()" function, please post that code.
0 Kudos
KeithSandell
New Contributor III
Clicking it fires the "setSymbology()" function, please post that code.


"onChange" not "onClick" fires the setSymbology() function, as it has it that function has nothing in it.

The onChange event will not fire if the ComboBOx is not populated with the values from the datastore so that you can affect a change.
0 Kudos