Kendo ui MVC网格绑定与DataTable Ajax Call

时间:2015-06-19 08:18:26

标签: kendo-ui

我尝试在点击事件中将DataTable从我的控制器绑定到kendo UI网格。问题是我有问题将DataTable解析为View(通过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;
                    }
            }

查看(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,
                         }
                     });

             })

当我运行这个时,我在视图上得到了errorParse ......有什么更好的方法?用于绑定。

0 个答案:

没有答案