Pergunta

I have dijit combo box that is decalared in the cust.Html page as follows:

<div class="CustDijit">
<div class="formContainer">
    <div data-dojo-type="dijit.form.Form" data-dojo-attach-point="searchFormDijit">
        <table cellspacing="5" style="width:100%; height: 49px;">
            <tr>
                <td>


                    <select data-dojo-type="dijit.form.ComboBox" name="state"  data-dojo-id="comboBoxID2"  id="stateInput" data-dojo-attach-point="idResultItemsCB"/>                       
                    <br />
                    Enter Attribute Value:<input id="searchText" type="text" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props="name:'searchText',trim:true,required:true,style:'width:100%;'"
                    />
                </td>
            </tr>
        </table>
    </div>
</div>


</div>

`

Now this html page is being created as a widget in the js code as shown below...Its here i want to populate the combobox. I have function created to pupulate the combo box but as i am very new to The dojotoolkit and dijits hence having a tuff time..Can some one please guide me as what i am doing wrong in the code below.

define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dijit/_WidgetsInTemplateMixin',
"dijit/registry",
'dijit/form/Form',
'dijit/form/FilteringSelect',
'dijit/form/ValidationTextBox',
'dijit/form/Button',   
"dijit/layout/ContentPane",
"dojo/store/Memory",
"dojo/data/ItemFileReadStore",
'dojox/grid/DataGrid',
'dijit/TooltipDialog',
'esri/tasks/query',
'esri/tasks/QueryTask',
'esri/config',
'dojo/store/Memory',
'dojo/_base/lang',
'dojo/_base/array',
'dojo/text!./Cust/templates/cust.html',
"dojo/parser",
'dijit/form/ComboBox',
"dijit/form/FilteringSelect",
 "dojo/domReady!"

 ], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, registry,   Form, FilteringSelect, ValidationTextBox, Button, ContentPane, Memory, ItemFileReadStore, DataGrid, TooltipDialog, query, QueryTask, esriConfig, Memory, lang, array, custTemplate, parser, ComboBox, FilteringSelect,dom) {

//anonymous function to load CSS files required for this module
(function () {
    var css = [require.toUrl("gis/dijit//css/cust.css")];
    var head = document.getElementsByTagName("head").item(0),
        link;
    for (var i = 0, il = css.length; i < il; i++) {
        link = document.createElement("link");
        link.type = "text/css";
        link.rel = "stylesheet";
        link.href = css[i].toString();
        head.appendChild(link);
    }
    parser.parse();
} ());

// Main cust dijit
var  Cust = declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], 
{
    widgetsInTemplate: true,
    templateString: custTemplate,
    map: null,
    defaultTitle: null,
    queryTask: null,
    query: null,
    map: null,
    self: null,
    _store1: null,
   _selectorOne: null,
    postCreate: function () {
        this.inherited(arguments);
        this.queryTask = new esri.tasks.QueryTask(this.queryTaskURL);
        this.query = new esri.tasks.Query();
        this.query.outSpatialReference = this.map.spatialReference;
        this.query.returnGeometry = true;
        this.query.outFields = ["id", "Custname", "Status"];
        self.cmboxlayer();

                    this.populateResultsIntoComboBox(Memory);

    },

    populateResultsIntoComboBox: function (Memory) {
        var stateStore = new Memory({
            data: [
                { name: "Alabama", id: "AL" },
                { name: "Alaska", id: "AK" },
                { name: "Arizona", id: "AZ" },
                { name: "Arkansas", id: "AR" },
                { name: "California", id: "CA" },
                { name: "Colorado", id: "CO" },
                { name: "Connecticut", id: "CT" },
                { name: "Delaware", id: "DE" }
            ]
        });

        var comboBoxDigit = registry.byId("stateInput");           
        //on(comboBoxDigit, "change", lang.hitch(this, 'comboBoxSelectionChangedEventHandler'));
        comboBoxDigit.store = stateStore;
        comboBoxDigit.searchAttr = "title";
        comboBoxDigit.set('value', stateStore.data[0].title);
    }

});
return Search;
    });

Thank you in advance

Foi útil?

Solução

From what I can see, you never define self=this in your postCreate function. Did you define self somewhere else in the widget instantiation phase?

I also noticed you named your template, 'custTemplate', and used 'searchTemplate' to define your templateString instead.

I've made a stripped down version of your code work at this fiddle: http://jsfiddle.net/n4jF7/

The only thing I can think of is if you didn't set parseOnLoad to be true:

parseOnLoad: true

or if you didn't call parser.parse to parse the template.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top