1

我正在使用带有服务器端过滤和服务器端排序的剑道网格。在我的数据源传输读取方法中,该字段始终为空。有什么建议么?

这是我初始化网格的代码:

var gridDataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: '@Url.Action("Read", "GridModule")',
                    type: 'POST',
                    contentType: 'application/json'
                },
                parameterMap: function (options) {
                    options.assignmentFilters = assignmentFilters;
                    return JSON.stringify(options);
                }
            },
            pageSize: 20,
            serverPaging: true,
            serverSorting: true,
            serverFiltering: true,
            schema: {
                model: {
                    fields: {
                        LastSurveyDate: { type: "date" },
                        LastNoteDate: { type: "date" }
                    }
                },
                data: "data",
                total: "totalRows"
            }
        });

        var $grid = $('#gridAssignments');

        if (e.firstLoad) {
            $grid.kendoGrid({
                scrollable: true,

                pageable: {
                    refresh: true,
                    pageSizes: [20, 50, 100, 500, 1000],
                    buttonCount: 12,
                    messages: {
                        display: "Showing {0}-{1} from {2} Provider Contacts",
                        empty: "No Contacts Match the Filter Criteria",
                        itemsPerPage: "Contacts per page"
                    }
                },
                reorderable: true,
                navigatable: true,
                change: gridOnChange,
                dataBound: gridOnDataBound,
                dataSource: gridDataSource,
                columnReorder: gridColumnReorder, 
                columnHide: gridColumnHide,
                columnResize: gridColumnResize,
                columnShow: gridColumnShow,
                columnMenu: {
                    sortable: false,
                    messages: {
                        columns: "Choose columns",
                        filter: "Filter",
                       }
                },
                resizable: true,
                height: '720px',
                filterable: {
                    extra: false,
                    operators: {
                        string: {
                            contains: "Contains",
                        },
                        date: {
                            lt: "Is before", 
                            gt: "Is after",
                            equal: "On"
                        }
                    }
                },
                selectable: "row",
                sortable: {
                    mode: "single",
                    allowUnsort: true
                },
                columns: [ @Html.Raw(Model.GridColumns.Columns) ]
        });
        } else {
            $grid.data('kendoGrid').setDataSource(gridDataSource);
        }
4

1 回答 1

3

对于遇到同样问题的任何人...

在我的情况下,我的代码运行良好,直到我向 Schema.Model.Fields 添加了两个字段。然后由于某种原因,我的网格模块的读取方法中的字段为 NULL。默认情况下,所有字段都被视为字符串,但是当我添加两个新属性时,没有使用默认值。

我必须添加我所有的网格字段

            schema: {
                model: {
                    fields: {
                        LastSurveyDate: { type: "date" },
                        LastNoteDate: { type: "date" },
                        FirstName: { type: "string" },
                        LastName: { type: "string" },
                        HasNewEval: { },
                        HasCommitmentsToGet: { },
                        OnPriorityList: { type: "string" },
                        HasProductsBelowMinimum: { type: "HasProductsBelowMinimum" },
                        Points: {},
                        Title: { type: "string" },
                        Provider: { type: "string" },
                        Phone: { type: "string" },
                        TimeZone: { type: "string" },
                        Touches: { type: "string" },
                        LastNoteText: { type: "string" },
                        VerbalAging: { type: "string" }
                    }
                },

这对我有用。

于 2013-09-24T22:52:26.077 回答