简体   繁体   English

填充dojo dijit组合框

[英]populating a dojo dijit combo box

I have dijit combo box that is decalared in the cust.Html page as follows: 我在cust.Html页面中声明了dijit组合框,如下所示:

<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. 现在,这个html页面被创建为js代码中的小部件,如下所示...在这里我要填充组合框。 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. 我已经创建了用于组合框的功能,但是由于我是dojotoolkit和dijits的新手,因此时间比较短。.有人可以指导我,因为我在下面的代码中做错了什么。

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 先感谢您

From what I can see, you never define self=this in your postCreate function. 据我所知,您永远不会在postCreate函数中定义self = this。 Did you define self somewhere else in the widget instantiation phase? 您是否在小部件实例化阶段的其他地方定义了self?

I also noticed you named your template, 'custTemplate', and used 'searchTemplate' to define your templateString instead. 我还注意到您将模板命名为“ custTemplate”,并使用“ searchTemplate”来定义您的templateString。

I've made a stripped down version of your code work at this fiddle: http://jsfiddle.net/n4jF7/ 在这个小提琴中,我已经简化了代码的工作: http : //jsfiddle.net/n4jF7/

The only thing I can think of is if you didn't set parseOnLoad to be true: 我唯一能想到的就是您是否未将parseOnLoad设置为true:

parseOnLoad: true

or if you didn't call parser.parse to parse the template. 或者您没有调用parser.parse来解析模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM