0
我想獲得一個telerik網格來顯示從控制器操作返回的json數據,但只有它顯示瀏覽器窗口中的實際json數據。MVC Telerik網格不綁定只在瀏覽器中顯示json數據
- 我應該打電話.BindTo後讀?
- 我在做什麼錯在我的行動?
我對這一切都錯了嗎?
[HttpGet] public ActionResult ReadLeads([DataSourceRequest]DataSourceRequest request) { var model = new RecordLookupViewModel(); using (var db = new RGI_MasterEntities()) { db.Configuration.ProxyCreationEnabled = false; var results = db.tblMasterLeads .Where( x => (model.FirstName == null || x.FirstName.Equals("Eric")) && (model.RecordType == null || x.MasterLeadType.Equals("Responder")) ) .Select(s => new LookupGridResults { FirstName = s.FirstName, LastName = s.LastName, City = s.city, State = s.state, County = s.county, Zip = s.zip }).Take(10); var result = results.ToDataSourceResult(request); return Json(result, JsonRequestBehavior.AllowGet); } }
她的是我的網格視圖代碼。
@(Html.Kendo().Grid<LookupGridResults>()
.Name("grid")
.AutoBind(false)
.Columns(columns =>
{
columns.Bound(p => p.FirstName).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))).Width(225);
columns.Bound(p => p.LastName).Width(225).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.City).Width(225).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.County).Width(225).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.State).Width(225).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.Zip).Width(225).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(true)
.Read(read => read.Action("ReadLeads", "LeadsManagement").Type(HttpVerbs.Get))
)
)
這是我的結果btw。
{"Data":[{"LastName":"COFFEY","FirstName":"EDWARD","City":"FRANKFORT","County":"FRANKLIN","State":"KY","Zip":"40601-2304"},{"LastName":"DESPAIN","FirstName":"TONY","City":"CAMPBELLSVILLE","County":"TAYLOR","State":"KY","Zip":"42718-9397"},{"LastName":"HALBIG","FirstName":"RONALD","City":"CAMPBELLSVILLE","County":"TAYLOR","State":"KY","Zip":"42718-1556"},{"LastName":"KRAUS","FirstName":"REBECCA","City":"FRANKFORT","County":"FRANKLIN","State":"KY","Zip":"40601-2714"},{"LastName":"LAWLESS","FirstName":"MEREDITH","City":"CAMPBELLSVILLE","County":"TAYLOR","State":"KY","Zip":"42718-1556"},{"LastName":"RANKIN","FirstName":"PAULINE","City":"LAWRENCEBURG","County":"ANDERSON","State":"KY","Zip":"40342-1374"},{"LastName":"SHIRLEY","FirstName":"LORRAINE","City":"CAMPBELLSVLLE","County":"TAYLOR","State":"KY","Zip":"42718-1557"},{"LastName":"STAPLES","FirstName":"DAMON","City":"HODGENVILLE","County":"LARUE","State":"KY","Zip":"42748-1208"},{"LastName":"WILLIAMS","FirstName":"LUCY","City":"FRANKFORT","County":"FRANKLIN","State":"KY","Zip":"40601-2308"},{"LastName":"WILSON","FirstName":"BELIDA","City":"FRANKFORT","County":"FRANKLIN","State":"KY","Zip":"40601-1321"}],"Total":10,"AggregateResults":null,"Errors":null}
你顯示的代碼的兩部分看起來很好......不知道你需要'.AutoBind(false)'聽起來像你可能會缺少一個JavaScript庫參考 – JamieD77
這沒有做到這一點。我覺得我想失去一些東西。還不確定。 – jeffkenn
你有這個問題:http://stackoverflow.com/questions/16143886/kendo-ui-grid-shows-json-instead-of-grid-asp-net-razor –