1

下面是我美丽的剑道网格。如果您注意到 PersonId、NameId 和 AwardTitleId 列,它们是 HIDDEN 列。

当用户单击编辑按钮以内联编辑记录时,我需要能够从该行中捕获 PersonId、NameId 和 AwardTitleId。问题是,这些列需要隐藏。

如何在内联编辑模式下为这 3 列选择隐藏值?

function directorsOrRecipients(e)
{
    awardTitleId = e.data.AwardTitleId;

    var detailRow = e.detailRow;

    detailRow.find(".childTabstrip").kendoTabStrip({
        animation: {
            open: { effects: "fadeIn" }
        }
    });

    detailRow.find(".directorsOrRecipients").kendoGrid({
        reorderable: true,
        resizable: true,
        dataSource: {
            transport: {
                read: {
                    url: "http://lh/x/api/Awards/directors/" + awardTitleId,
                    type: "GET"
                },
                parameterMap: function (model, operation) {
                    if (operation !== "read" && model) {
                        return kendo.stringify(model);
                    }
                }

            },
            schema: {
                model: {
                    id: "AwardTitleId",
                    fields: {
                        "AwardTitleId": { editable: false, type: "number", nullable: false },
                        "PersonId": { editable: false, type: "number", nullable: false },
                        "NameId": { editable: false, type: "number", nullable: false },
                        "NameFirstLast": { editable: true, type: "string" },
                        "DirectorSequence": { editable: true, type: "number", validation: { min: 1 } },
                        "IsOnBallot": { editable: true, type: "boolean" },
                        "Concatenation": { editable: true, type: "string" },
                        "MoreNames": { editable: true, type: "number", validation: { min: 0 } },
                    }
                }
            }
        },
        columns: [
            { field: "AwardTitleId", title: "Award Title Id", hidden: true },
            { field: "PersonId", title: "Person Id", hidden: true },
            { field: "NameId", title: "Name Id", hidden: true },
            { field: "NameFirstLast", title: "Name", editor: namesAutoComplete },
            { field: "DirectorSequence", title: "Director Sequence", format: "{0:n0}" },
            { field: "IsOnBallot", title: "On ballot?", editor: onBallotDropDownEditor },
            { field: "Concatenation", title: "Concatenation" },
            { field: "MoreNames", title: "More names?", format: "{0:n0}" },
            { command: ["edit"], title: " ", width: 100 }],
        sortable: true,
        sort: { field: "NameFirstLast", dir: "desc" },
        editable: "inline",
        toolbar: [{ name: "create", text: "Add New Director/Recipient" }],
        save: function(a)
        {
            if (a.model.IsOnBallot == true)
            {
                ballot = 1;
            }

            if (a.model.IsOnBallot == false)
            {
                ballot = 0;
            }

            directorData["DirectorSequence"] = a.model.DirectorSequence;
            directorData["IsOnBallot"] = ballot;
            directorData["Concatenation"] = a.model.Concatenation;
            directorData["Operation"] = "I";
            //directorData["moreNames"] = e.model.MoreNames;

            $.ajax({
                url: "http://lh/x/api/awards/directors",
                type: "POST",
                dataType: "json",
                data: directorData 
            }).done(function()
            {
                detailRow.find(".directorsOrRecipients").data("kendoGrid").refresh();
            });
        }
    });

    function onBallotDropDownEditor(container, options)
    {
        var data = [
            { "IsOnBallot": "true" },
            { "IsOnBallot": "false" }];

        $('<input required data-text-field="IsOnBallot" data-value-field="IsOnBallot" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: data
            });
    } 
}
4

1 回答 1

1

我想通了。即使你隐藏它,你仍然可以通过这样做来获得价值:

var hiddenValue = a.model.X;
于 2013-09-12T00:17:57.217 回答