I'm trying to bind a DataTable from my controller to a kendo UI grid on a click event. Problem is I'm having a problem to parse the DataTable to the View(via Ajax).
// myController.cs to return the DataTable Object.
public DataTable myMethod(string source)
{
string connection = "myConnectionString"
using (var dataAdapter = new OracleDataAdapter("SELECT * from myTable", connection))
{
var dataTable = new DataTable();
dataAdapter.Fill(dataTable);
dataAdapter.FillSchema(dataTable,SchemaType.Source);
return dataTable;
}
}
View (cshtml)
function Btn_click(e) {
$.ajax({
url: '/myController/myMethod',
contentType: "application/json; charset=utf-8",
},
type: 'GET',
})
.success(function (data) {
var grid = $("#myGrid").data("kendoGrid");
// destroy it
grid.destroy();
$("#myGrid")
.empty() // clear the old HTML
.kendoGrid({
dataSource: {
data: data,
}
});
})
I'm getting errorParse on the view when I run this ...what is the better way? for binding.