Asp.net mvc 使用MVVM将kendo.data.DataSource绑定到combo

Asp.net mvc 使用MVVM将kendo.data.DataSource绑定到combo,asp.net-mvc,asp.net-mvc-4,mvvm,kendo-asp.net-mvc,kendo-mvvm,Asp.net Mvc,Asp.net Mvc 4,Mvvm,Kendo Asp.net Mvc,Kendo Mvvm,下一个问题,这次是个棘手的问题 数据源: var dsCountryList = new kendo.data.DataSource({ transport: { read: { dataType: "jsonp", url: "/Masters/GetCountries" } },

下一个问题,这次是个棘手的问题

数据源:

var dsCountryList =
       new kendo.data.DataSource({
           transport: {
               read: {
                   dataType: "jsonp",
                   url: "/Masters/GetCountries"
               }
           },
           schema: {
               model: {
                   id: "CountryID",
                   fields: {
                       "CountryDesc": {

                       }
                   }
               }
           }
       });
可观测物体

function Set_MVVMSupplier() {
    vmSupplier = kendo.observable({
        SupplierID: 0,
        SupplierName: "",
        AccountNo: "",
        CountryList: dsCountryList,
});

    kendo.bind($("#supplierForm"), vmSupplier);
}
这是绑定到observable对象的html,但我没有填充combobox,而且每次单击combo请求都会转到服务器,并将countryID、CountryDesc的json格式的数据带到服务器

 <div class="span6">
                <div class="control-group">
                    <label class="control-label" for="txtCountryId">Country</label>
                    <div class="row-fluid  controls">
                        @*<input class="input-large" type="text" id="txtCountryId" placeholder="CountryId" data-bind="value: CountryId">*@
                        <select  id="txtCountryId" data-role="dropdownlist"
                             data-text-field="CountryDesc" data-value-field="CountryID" , data-skip="true"
                             data-bind="source: CountryList, value: CountryDesc">
                        </select>
                    </div>
                </div>
            </div>

国家
@**@

我没有得到答案,所以我找到了另一个工作代码。看一看,如果有帮助,请投票

在js文件中创建ddl模型

 ddl = kendo.data.Model.define({
    fields: {
        CountryId: { type: "int" },
        ConfigurationID: { type: "int" }
    }
});
将var ddl添加到MVVM js文件

 vmSupplier = kendo.observable({
    CountryId: new ddl({ CountryId: 0 }),
    ConfigurationID: new ddl({ ConfigurationID: 0 }),});
在控制器中添加了代码

 using (CountriesManager objCountriesManager = new CountriesManager())
        {
            ViewBag.Countries = new SelectList(
                objCountriesManager.GetCountries().Select(p => new { p.CountryID, p.CountryDesc })
                , "CountryID", "CountryDesc"); ;
        }
在cshtml中添加了代码

      <div class="span4">
                        <label class="control-label" for="txtCountryId">Country</label>
                        @Html.DropDownList("Countries", null,
                      new System.Collections.Generic.Dictionary<string, object> {
                      {"id", "txtCountryId" },
                      { "data-bind","value: CountryId"} })

                    </div>

国家
@Html.DropDownList(“国家”),空,
新System.Collections.Generic.Dictionary{
{“id”,“txtCountryId”},
{“数据绑定”,“值:CountryId”})

这样我就解决了这个问题

这种感冒也被称为SPA,单页应用。