2014-04-24 2 views
1

다음과 같이 나는 cust.Html 페이지에 decalared있다는 Dijit 콤보 상자가 있습니다 도장는 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> 
지금이 HTML 페이지가에 위젯으로 생성되는 js 코드를 아래에 표시된대로 ... 여기에 내가 콤보 상자를 채우고 싶습니다. 나는 콤보 박스를 생성하기 위해 함수를 만들었지 만, 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; 
    }); 

는 postCreate 함수 = 당신은 스스로를 정의하지, 사전

내가 무엇을 볼 수에서

답변

0

이 감사합니다. 위젯 인스턴스화 단계에서 다른 곳에서 자신을 정의 했습니까?

또한 템플릿 이름을 'custTemplate'로 지정하고 'searchTemplate'을 사용하여 templateString을 정의하는 것으로 나타났습니다.

I했습니다 만든이 바이올린의 코드 작업의 버전을 박탈 : 당신이 사실로 parseOnLoad를 설정하지 않은 경우 http://jsfiddle.net/n4jF7/

내가 생각할 수있는 유일한 방법은 다음과 같습니다

parseOnLoad: true 

또는 parser.parse를 호출하여 템플릿을 구문 분석하지 않은 경우

+0

응답을 주셔서 감사합니다 ... 내 코드를 약간 변경했지만 여전히 콤보 상자를 채우는 데 어려움이 있습니다. 원래 질문을 수정했습니다. 확인하십시오. – user3567026

+0

내 대답을 편집하여 다른 문제를 강조 표시했습니다. 또한 오류를 게시 할 수 있습니까? – Richard

+0

Richard 죄송합니다. 위의 코드에서 변경하는 것을 잊어 버렸습니다. 방금 지적한 문제는 저에게 오래 전에 해결되었습니다. 오류가 없습니다. 콤보 상자가 오염되지 않았다는 것입니다. populateResultsIntoComboBox 함수가이를 수행하지 않습니다. – user3567026

관련 문제