加载cshtml文件时出现Kendo Grid MVC编译错误

时间:2018-05-09 12:36:06

标签: asp.net-mvc model-view-controller kendo-ui kendo-grid datasource

尝试加载.cshtml文件时出现以下错误:

  

编译器错误消息:CS1026 :)预期

源错误(第81行):

  

第79行:.AutoBind(true)

     

第80行:

     

第81行:.DataSource(dat asource => datasource

     

第82行:.Ajax()

     

第83行:.Model(model =>

我尝试刷新缓存并从网格中删除元素,但它仍无效。

cshtml页面代码:

@{
    var guid = Guid.NewGuid();
    var layoutId = guid + "page-layout";
    var partialModel = new Kendo_UI_Bootstrap_Integration.ViewModels.ReportLayoutViewModel();
    partialModel.Title = "Report";
    partialModel.ReportHeaderData = string.Format("<span id='{0}-start-date'>Start Date:</span><br/><span id='{0}-end-date'>End Date</span>", guid);
    partialModel.Id = layoutId;
}
@Html.Partial(MVC.Reports.Views.ViewNames._ReportLayout, partialModel)

<input id="GuidInput" type="hidden" value="@guid" />
<table>
    <tbody>
        <tr>
            <td>
                <span>Start Date: </span>
                @(Html.Kendo().DatePicker().Name(guid + "StartDate").Footer(false))
            </td>
            <td style="padding-left: 10px;">
                <span>End Date: </span>
                @(Html.Kendo().DatePicker().Name(guid + "EndDate").Footer(false))
            </td>
            @if (User.IsInRole("RearingUnitRearingManager") || User.IsInRole("BackOfficeSuperUser"))
            {
                <td style="padding-left: 10px;">
                    @(Html.Kendo().DropDownListFor(m => m)
                        .Name("dropdown")
                        .DataTextField("name")
                        .DataValueField("nameguid")
                        .DataSource(dataSource =>
                        {
                            dataSource.Read(read => read.Action(MVC.ControllerName.ActionNames.Action, MVC.Controller.Name))
                            .ServerFiltering(true);
                        })

                        .HtmlAttributes(new { style = "width: 306px;" })
                    )
                </td>
            }
            <td style="padding-left: 10px;">
                @(Html.Kendo().Button().Name("Submit").Content("Submit").Events(events => events.Click("submitbutton")))
            </td>
        </tr>
    </tbody>
</table>
<br />


    @(Html.Kendo().Grid<Kendo_UI_Bootstrap_Integration.Models.DTO.dto>()
        .Name("gridname")
        .ToolBar(tools => { tools.Pdf(); tools.Excel(); })
           .Pdf(pdf => pdf
                .AllPages()
                .AvoidLinks()
                .Landscape()
                .TemplateId(layoutId)
                .PaperSize("A4")
                .Scale(0.6)
                .RepeatHeaders()
                .Margin("7cm", "1cm", "3cm", "1cm")
                .FileName("pdf.pdf")
            )
        .Excel(excel => excel
                .AllPages(true)
                .FileName("excel.xlsx"))
        .EnableCustomBinding(true)
        .Columns(
        columns =>
        {
            columns.Bound(c => c.item1).Hidden();
            columns.Bound(c => c.item2);
            columns.Bound(c => c.item3);
            columns.Bound(c => c.item4);
            columns.Bound(c => c.item5);
            columns.Bound(c => c.item6);
        }
        )
        .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
        .AutoBind(true)

        .DataSource(dat​asource => datasource
        .Ajax()
        .Model(model =>
        {
            model.Field(m => m.item1).Editable(false);
            model.Field(m => m.item2).Editable(false);
            model.Field(m => m.item3).Editable(false);
            model.Field(m => m.item4).Editable(false);
            model.Field(m => m.item5).Editable(false);
            model.Field(m => m.item6).Editable(false);
        })
        .Group(group => group.Add(w => w.item1))
        .Read(read => read.Action(MVC.Controller.ActionNames.Actionname_Read, MVC.Controller.Name).Data("function"))
        .PageSize(100)
        .Batch(true)
        )
        .Events(ev => ev.PdfExport("ProcessPdf").ExcelExport("SetExcelFileName"))
        .HtmlAttributes(new { style = "z-index: 1000; position: relative;", @class = "report-grid", report_guid = guid })
    )

1 个答案:

答案 0 :(得分:0)

当我尝试双击“数据源”字样时它只突出显示了一半的单词,所以我重新输入了它并添加了一个模型。对于模型定义并且它有效。

我不知道这里发生了什么。