2015-06-27 38 views
0
<div id="grid"></div> 
(document).ready(function() { 
    var dataSourceA = new kendo.data.DataSource({ 
     transport: { 
      read: "../Test/CourseRead", 
      dataType: "json" 
     } 
    }); 
    $("#grid").kendoGrid({ 
     dataSource: dataSourceA, 
     height: 550, 
     groupable: true, 
     sortable: true, 
     pageable: { 
      refresh: true, 
      pageSizes: true, 
      buttonCount: 5 
     }, 
     columns: [{ 
      field: "CourseName", 
      title: "Course Name", 
      width: 240 
     }] 
    }); 
}); 
public ActionResult CourseRead([DataSourceRequest]DataSourceRequest request) 
    { 
     IQueryable<CourseInformationMasterViewModel> course = (from m in db.CourseInformationMasters 
                   select new CourseInformationMasterViewModel{ 
                   CourseName=m.CourseName, 
                   CourseCode=m.CourseCode, 
                   CourseCredit=m.CourseCredit, 
                   MasterCourseId=m.MasterCourseId 
                   }); 
     DataSourceResult result = course.ToDataSourceResult(request); 
     return Json(result); 
    } 

我的行動methos的名字是CourseRead和控制器的名字是Test.action方法燒製,但顯示空grid.json結果返回值我chechk this.but網格是空的。劍道電網閱讀的操作方法不火

回答

0

我得到了我answer.i出錯在我的行動method.update操作方法是:

public JsonResult CourseRead() 
    { 
     var course = (from m in db.CourseInformationMasters 
         select new CourseInformationMasterViewModel 
         { 
          CourseName = m.CourseName, 
          CourseCode = m.CourseCode, 
          MasterCourseId = m.MasterCourseId 
         }); 
     return Json(course, JsonRequestBehavior.AllowGet); 
    } 
0

它看起來像你的決策GET請求,默認情況下jsonResult所行

當你需要allowget或使用得到的,我們必須使用JsonRequestBehavior.AllowGet。

public ActionResult CourseRead([DataSourceRequest]DataSourceRequest request) 
    { 
.. 
return Json(new Modle.JsonResponseData { result, JsonRequestBehavior.AllowGet); 
.. 
} 

確保read: "../Test/CourseRead"打電話給你的控制器動作否則你可以使用視圖引擎調用從視圖烏爾行動..