简体   繁体   English

Telerik网格显示不存在的列ASP.NET MVC

[英]Telerik grid showing non-existent columns ASP.NET MVC

i am prepairing sample report screen, user will choose report from dropdownBox and fill some special options. 我正在对样品报告屏幕进行预配对,用户将从下拉框中选择报告并填写一些特殊选项。 after it click search Button (Sorgula) it hits Read action from ReportController. 单击搜索按钮(Sorgula)后,它单击ReportController中的“读取”操作。

this Controller Returns List (whatever you whish) as Json 此Controller返回列表(无论您希望如何)为Json

now this is working. 现在这正在工作。 But Telerik Grid adding different columns which i have never added to result. 但是Telerik Grid添加了我从未添加过的不同列。

There are no columns on grid defined by me. 我定义的网格上没有列。 because columns Must occur according to json result 因为列必须根据json结果出现

Now My Grid Create Query 现在我的网格创建查询

$("#ReportResult").kendoGrid({
        selectable: "multiple cell",
        allowCopy: true,
        height: 550,
        groupable: true,
        pageable: true,
        sortable: true,

        pageable: {
             input: true,
            numeric: false
        },

        dataSource: new kendo.data.GanttDataSource({
            pageSize: 20,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,
             transport: {
            read: {
                url: '<%= Url.Action("Read", "Report") %>',
                dataType: "json",
                type: "POST",
                data: {
                    ReportID: 1,
                    OrganizationID: 2,
                    StartDate: "22",
                    EndDate: "11",
                    UserName:"dds",
                },
            },
        },

        }),


    });

Read action 阅读动作

public ActionResult Read([DataSourceRequest] DataSourceRequest request, int ReportID,int OrganizationID,string StartDate,string EndDate,string UserName)
    {

        List<COnsumersReport> lis = new List<COnsumersReport>();
        for (int i = 0; i < 99; i++)
        {
            COnsumersReport cc = new COnsumersReport();
            cc.ID = i;
            cc.name = "semih";
            cc.sirname = "Yıldız";
            cc.Borc =i*20.5;
            lis.Add(cc);
        }


        return Json(lis);
    }

And the result. 结果。 As you see id,parentId,orderId,Title vs has not defined by me. 如您所见,id,parentId,orderId,Title vs尚未由我定义。

在此处输入图片说明

    public class COnsumersReport
    {
        public int ID { get; set; }
        public string  name { get; set; }
        public string sirname { get; set; }
        public double Borc { get; set; }
    }

The reason was grid datasource . 原因是网格数据源。 i have used to kendo.data.GanttDataSource grand datasource adding auto columns. 我曾经为kendo.data.GanttDataSource大数据源添加了自动列。

when i try to use kendo.data.DataSource problem is fixed. 当我尝试使用kendo.data.DataSource时,问题已修复。

 dataSource: new kendo.data.DataSource({
        pageSize: 100,
        serverPaging: true,
            transport: {
                read:  {
                    url: '<%= Url.Action("Read", "Report") %>',
                    dataType: "json", 
                    type: "GET",
                    data: {
                        ReportID: $('#Rapor').val(),
                        OrganizationID: $('#Organizations').val(),
                        StartDate: $('#datepicker').val(),
                        EndDate: $('#datepickerEndDate').val(),
                        UserName: $('#userName').val(),
                    },                        
                },                    
            },
        error: function (req, textStatus, errorThrown) {
            console.log("Error Verdi" + textStatus + ' ' + errorThrown);
        },
        schema: {
            total: function (response) {
            return ResultCount;
            } 
        }
       }), 

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

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