将ItemFileReadStore与FilteringSelect链接

时间:2011-07-02 19:00:53

标签: dojo

dojo.addOnLoad(function(){
 var jsonStore = new dojo.data.ItemFileReadStore({"url":"http://localhost:8080/Sai/samu"}); 
});

<div dojoType="dijit.form.FilteringSelect" store="jsonStore"  required="true"   id="MyId" ></div>

我收到错误声明jsonStore未定义。

1 个答案:

答案 0 :(得分:0)

您正在混合使用programmatic and declarative Dojo方法。你应该使用其中一个。

<强>程序化:

dojo.addOnLoad(function(){
    var jsonStore = new dojo.data.ItemFileReadStore({
        url: "http://localhost:8080/Sai/samu"
    });
    var filtSel = new dijit.form.FilteringSelect(
        {
            id: "MyId",
            store: jsonStore,
            required: true
        },
        "MyId" // Id of div to turn into filteringSelect  
    );
});
...
<div id="MyId"></div>

<强>声明

<div dojoType="dojo.data.ItemFileReadStore" jsId="jsonStore" url="http://localhost:8080/Sai/samu"></div>
<div dojoType="dijit.form.FilteringSelect" store="jsonStore" required="true"   id="MyId" ></div>