0

我需要捕获用户在以下字段中输入的值:

  • isOnBallot
  • 连接字符串

下面代码中的注释显示了我想在哪里使用这些变量。

我这里唯一不知道怎么做的是如何在这两个字段中引用VALUE。我不知道是否有一种特定的方式我应该用 Kendo 或尝试使用 jquery 来做到这一点。

例如,如果我检查元素 concatenationString,这就是我所看到的:

<input type="text" class="k-input k-textbox" name="concatenation" data-bind="value:concatenation">

这是网格定义:

function directorsOrRecipients(e)
{
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        reorderable: true,
        resizable: true,
        dataSource: {
            transport: {
                read: {
                    url: "http://localhost/x/api/Awards/directors/" + e.data.AwardTitleId,
                    type: "GET"
                },
                create: {
                    url: "http://localhost/x/api/awards/directors",
                    type: "POST",
                    data: {
                        awardTitleId: e.data.AwardTitleId,
                        personId: localStorage.personId,
                        nameId: localStorage.nameId,
                        isOnBallot: "True",//I need to get this value based on the user input.,
                        concatenationString: "test1",//I need to get this value based on the user input.
                        whoEntered: 0
                    }
                }
            },
            schema: {
                model: {
                    id: "namefirstlast",
                    fields: {
                        "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: "namefirstlast", title: "Name", editor: namesAutoComplete },
            { field: "directorsequence", title: "Director Sequence", format: "{0:n0}" },
            { field: "isonballot", title: "On ballot?" },
            { field: "concatenation", title: "Concatenation" },
            { field: "MoreNames", title: "More names?", format: "{0:n0}" },
            { command: ["edit"], title: "&nbsp;", width: 100 }],
        sortable: true,
        sort: { field: "namefirstlast", dir: "desc" },
        editable: "inline",
        toolbar: [{
            name: "create",
            text: "Add New Director/Recipient"
        }]
    });
}

任何人都可以帮我一把吗?

谢谢!

4

1 回答 1

0

终于想通了

您可以通过以下方式从您正在内联编辑的单元格中获取值:

save: function(a)
{
   var value = a.model.Item;
}

这是整个代码:

save: function(a)
        {
            directorData["Operation"] = "I";

            if (!a.model.isNew())
            {
                directorData["AwardTitleId"] = awardTitleId;
                directorData["PersonId"] = a.model.PersonId;
                directorData["NameId"] = a.model.NameId;
                directorData["Operation"] = "U";
            }

            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;

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

            });
        },
于 2013-09-12T00:22:05.983 回答