简体   繁体   English

Kendo Grid使用Ajax更新

[英]Kendo Grid Updating with Ajax

Problem is probably in success function RssCek Function in HomeController returns succesfully. 问题可能出在成功函数HomeController中的RssCek函数成功返回。 But i cant manage bind with grid HomeController RssCek function return part 但是我无法管理与网格HomeController RssCek函数返回部分的绑定

        return Json(feedler, JsonRequestBehavior.AllowGet);

JavaScript Script Function JavaScript脚本功能

<script>
    function select(e) {
        var value = $(e.item).find("> .k-link").text();

            $.ajax({
                url: '@Url.Action("RssCek", "Home")',
                type: 'GET',
                contentType: 'application/json; charset=utf-8',
                data: { value: value },
                success: function (feedler)
                {
                    var g = $("#grid").data("kendoGrid");

                    g.dataSource = new kendo.data.DataSource({ data: feedler });
                    g.dataSource.read();
                    g.refresh();
                },
                error: function (request, status, error)
                {document.write(request+"++"+ status+"++"+ error);}
                });
    }

</script>

you can set the datasource of the kendo grid like this , 您可以像这样设置剑道网格的数据源,

var dataSource = new kendo.data.DataSource({
  data:feedler 

});
var grid = $("#grid").data("kendoGrid");
grid.setDataSource(dataSource);

The best method you can do is to define the transport properties of the data source of the grid. 最好的方法是定义网格数据源的传输属性。 You don't have to create datasouces for each data read, you can specify read,create,update methods in the datasouce itself and then you can call , 您不必为每次读取的数据创建数据源,您可以在数据源本身中指定read,create,update方法 ,然后可以调用,

var g = $("#grid").data("kendoGrid");
 g.dataSource.read();

Whenever you need to refresh from server. 每当您需要从服务器刷新时。

Try this, 尝试这个,

<script>
    function select(e) {
        var value = $(e.item).find("> .k-link").text();

            $.ajax({
                url: '@Url.Action("RssCek", "Home")',
                type: 'GET',
                contentType: 'application/json; charset=utf-8',
                data: { value: value },
                success: function (feedler)
                {





 $("#grid1").html('');
                       $("#grid1").kendoGrid({
                       dataSource: feedler,
                       sortable: true,
                       pageable: {
                           refresh: true,
                              pageSizes: true
                              },
                            columns: [{
                                         field: "SampleDescription",
                                       width: 90,
                                     }, {
                            field: "SampleCode",
                              width: 90,
                               }, {
                                 width: 100,
                                field: "SampleItems"
                                  }
                                 ]
                                });;
                },
                error: function (request, status, error)
                {document.write(request+"++"+ status+"++"+ error);}
                });
    }

</script>

View 视图

<div id="grid1">
    </div>

OR with same grid 或具有相同网格

  <script>
        function select(e) {
            var value = $(e.item).find("> .k-link").text();

            $.ajax({
                url: '@Url.Action("RssCek", "Home")',
                type: 'GET',
                contentType: 'application/json; charset=utf-8',
                data: { value: value },
                success: function (feedler)
                {


                $('#grid').data("kendoGrid").dataSource = new kendo.data.DataSource({ data: result });
                    $('#grid').data("kendoGrid").dataSource.read();
                    $('#grid').data("kendoGrid").refresh();
}

</script>

Field Name is just for example. 字段名称仅作为示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM