0

我正在使用 EJ2 网格,并且有一个编辑和删除选项。随着 EJ 网格通过 Id 字段,onClick 没有问题。同样的事情不适用于 EJ2 Grid。

        var grid = new ej.grids.Grid({
        dataSource: @Html.Raw(JsonConvert.SerializeObject((Model), new JavaScriptDateTimeConverter())),
        allowExcelExport: true,
        allowPdfExport: true,
        toolbar: ['ExcelExport', 'PdfExport', 'CsvExport'],
        allowSelection: true,
        allowFiltering: true,
        allowSorting: true,
        //allowPaging: true,
        allowNumberFormatting: true,
        enableVirtualization: true,
        filterSettings: { type: 'Excel' },
        selectionSettings: { persistSelection: true, type: "Multiple", checkboxOnly: true },
        enableHover: false,
        enableHeaderFocus: true,
        height: 600,
        rowHeight: 38,
        columns: [
            { field: "Id", visible: false, allowEditing: false },
            { field: "Name",                  headerText: "Name",               width: 100 },
            { field: "ElectionDate",          headerText: "ElectionDate",       width: 80, format: "MM/dd/yyyy"},
            { field: "RegistrationClose",     headerText: "Registration Close", width: 80, format: "MM/dd/yyyy", },
            { field: "RegularAbsenteeStart",  headerText: "Absentee Start",     width: 80, format: "MM/dd/yyyy"},
            { field: "EarlyVotingStart",      headerText: "Early Voting Start", width: 80, format: "MM/dd/yyyy"},
            { field: "GraceVotingStart",      headerText: "Grace Voting Start", width: 80, format: "MM/dd/yyyy",},
            { field: "ElectionTypeName",      headerText: "ElectionType",       width: 110, },
            { field: "Active",                headerText: "Active",             width: 70 },
            {
                headerText: "",
                template: '<a href="#" onclick="Edit({{:Id}})">Edit</a>',
                width: 40,
                textAlign: "center"
            },
            {
                headerText: "",
                template: '<a href="#" data-url="@Url.Action("Delete")/{{:Id}}" data-name="{{:Name}}" data-toggle="modal" data-target="#confirmModal">Delete</a>',
                width: 40,
                textAlign: "center"
            },
        ],
        //pageSettings: { pageSizes: true, pageSize: 8 }
    });

    grid.appendTo("#dataGrid_EJ2");
4

1 回答 1

0

EJ2 中的模板已更改。EJ 它是 {{:Id}} EJ2 它更改为 ${Id}

于 2022-02-17T01:48:10.790 回答