我需要使用開源的KendoUI Grid來顯示我的模式列表。但這不是成功。我連接數據庫並將數據作爲控制器類中的列表。我需要從數據庫中獲取數據來完成這個網格。如何使用開源Kendo Grid顯示數據庫表格的網格?
$("#gridd").kendoGrid({
dataSource: {
transport: {
read: {
url: "report/GetData",
type:"json"
}
},
sortable: true,
pageable: {
input: true,
numeric: false
}, height: 430,
selectable: "multiple",
columns: [
{ field: "Users.uName", title: "Kullanıcı", width: "80px" },
{ field: "Locations.locName", title: "Oda", width: "80px" },
{ field: "Devices.devName", title: "Cihaz", width: "80px" },
{ field: "Commands.cName", title: "Komut", width: "80px" },
{ field: "gasValue", title: "Gaz", width: "80px" },
{ field: "tempValue", title: "Sıcaklık", width: "130px" },
{ field: "humValue", title: "Nem", width: "80px" },
{ field: "AlarmCodes.aName", title: "Alarm", width: "80px" },
{ field: "ReasonCodes.rName", title: "Nedeni", width: "80px" }]
}
});
我的控制器類
public JsonResult GetData()
{
var reports = db.ActivityLog.OrderBy(c => c.dateTime).ToList();
return Json(reports, JsonRequestBehavior.AllowGet);
}
編輯我目前的代碼。現在我看到了網格,但我看不到裏面的數據。他們將如何顯示?
它不工作.. –
我必須做的JavaScript命令。是可能的模型連接到JavaScript?因爲我不能使用Html.Kendo(),所以會出現語法錯誤。 –
如果您使用的是Kendo引擎,您是否在「Kendo」之前寫過「@」,如果您使用ASP編碼,是否寫過「%=」......請記住,服務器代碼以此字符開頭。此外,您必須解決位於模型中的類「位置」中的所有邏輯。 –