Currently i am using Kendo grids on my application, But now i got one requirement that different datasouces need to bind to a single KendoGrid by just passing datasource with data.
Currently having individual grids for individual DataSources with predefine Headers. HTML code:
<div id="divShowAllReports">
</div>
AJAX call to get Data from DB
<script>
$(function () {
$.ajax({
url: '@Url.Action("GetAndShowAdhocReports", "AdhocReport")',
type: "POST",
success: function (result) {
debugger;`enter code here`
BindGrid(result.lstAdhocReports);
//BindAdhocReport(result.lstAdhocReports);
},
error: function (error) {
alert("Failed");
}
})
})
</script>
on Success Binding Data to grid:
function BindGrid(data) {
if (data != "" || data != undefined) {
$("#divShowAllReports").kendoGrid({
dataSource: {
data: data,
schema: {
model: {
fields: {
ReportID: { type: "string" },
ReportName: { type: "string" },
ReportQuery: { type: "string" },
IsAccessToAll: { type: "string" },
CustomerID: { type: "string" },
CustUserID: { type: "string" }
}
}
},
pageSize: 10,
},
sortable: true,
filterable: true,
columnMenu: true,
pageable: true,
columns: [{
field: "ReportName", title: "Report Name",
template: "<a value='#=ReportQuery#' href='javascript:void(0)' onclick=ShowAdhocGrid(this)>#=ReportName#</a>"
},
{ field: "ReportID", title: "ReportID", hidden: true },
{ field: "ReportQuery", title: "Report Query" },
{ field: "IsAccessToAll", title: "Is Access to All" },
{ field: "CustUserID", title: "CustUserID", hidden: true },
{ field: "CustomerID", title: "CustomerID", hidden: true },
]
});
}
else {
$("#divShowAllReports").html("<h4>No data Available</h4>")
}
}
But now the problem iam facing is unable to bind another data to this grid(data not similar to old one). I want to use only one grid instead of different grids.
Please help me,
Thank you guyss...