2013-10-10 79 views

回答

1
这里

如下图所示他们所提供的数据源的路径引导信息数据库部分,它将从数据库中的值,因此没有魔法的任何东西使用基本代码laungage

dataSource: { 
       type: "odata", 
       transport: { 
        read: "http://demos.kendoui.com/service/Northwind.svc/Categories" 
          } 
      } 

和MVC

var categories = dataContext.Categories 
         .Select(c => new ClientCategoryViewModel { 
          CategoryID = c.CategoryID, 
          CategoryName = c.CategoryName 
         }) 
         .OrderBy(e => e.CategoryName); 
      ViewData["categories"] = categories; 
      ViewData["defaultCategory"] = categories.First(); 

和MVC视图: -

.Model(model => 
     { 
      model.Id(p => p.ProductID); 
      model.Field(p => p.ProductID).Editable(false); 
      model.Field(p => p.Category).DefaultValue(
       ViewData["defaultCategory"] as Kendo.Mvc.Examples.Models.ClientCategoryViewModel); 
     }) 
+0

我说来看看ASP MVC样品,而不是在html样本 –

+0

更新了答案! – Neel

+0

是的,我知道类别分配给viewdata,但它从来没有在视图中使用。我不明白的部分是在视图中读取视图数据 –