我正在尝试将数据库中的数据绑定到 KendoUI Grid,但数据未显示...我正在从数据库中获取数据成功转换为序列化代码,但数据未显示在 Kendo Grid 中。请帮助我...
<div id="example" class="k-content">
<div id="grid"></div>
<script type="text/javascript">
$(document).ready(function(){
$("#grid").kendoGrid({
dataSource:
{
type:"odata",
serverPaging: true,
serverSorting:true,
pageSize:100,
transport:
{
read:
{
url:"Fetchdata.aspx",
contentType: "application/json;charset=utf-8",
dataType: "odata",
jsonReader:
{
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false
}
}
}
},
height:100,
scrollable:
{
virtual: true
},
sortable: true,
columns: [
"dptId",
{ title: "Name", field: "dptName" },
{ title: "Description", field: "dptdescription" }
]
});
});
</script>
</div>
protected void Page_Load(object sender, EventArgs e) {
Response.Write(GetData());
Response.End();
}
protected string GetData()
{
EmployeeBM empbm = new EmployeeBM();
List < Departement> list= new List<Departement>();
list = empbm.BindDepartment();
return GridData(1, 1,list.Count, list);
}
public string GridData(int noOfPages, int startPage, int noOfRecords, List<Departement> list)
{
var gridData = new
{
total = noOfPages,
page = startPage,
records = noOfRecords,
rows = list,
};
var jsonSerializer = new JavaScriptSerializer();
return jsonSerializer.Serialize(gridData);
}