0

示例代码:-

<script type="text/javascript">
function ViewDataChange() {
    alert("In");
}

 function GetPage(data) {
    debugger;
    var item = document.getElementById("AppId").value;
    var i=0;
    for (i = 0; i < data.length; i++) {

        if (data[i].selected) {
            var selectedRole = data[i].value + "#" + item;

            $.getJSON("/Calls/SelectedBookingRole", { Id: selectedRole }, function (d) 

            });
            break;
        }
    }                      
}

  @{using (Ajax.BeginForm("DeleteAttendee", "Calls", new AjaxOptions { UpdateTargetId = "GridAttendee", HttpMethod = "Post", LoadingElementId = "LoadingImageAttendees" }))
          {  

        @usersGrid.GetHtml(
        htmlAttributes: new { OnItemCreated = "this.ViewDataChange()" },
        tableStyle: "grid TBLGrid",
        mode: WebGridPagerModes.Numeric,

        headerStyle: "header",
        alternatingRowStyle: "alt",

        rowStyle: "row",
                columns: usersGrid.Columns(
                  usersGrid.Column(null, null, format: @<input type="hidden" name="AppId" value="@item.AppUserId"/>, style: "", canSort: false),
                  usersGrid.Column("Name", "Name ", style: "", canSort: false),
                  usersGrid.Column("ListItemId", "Booking Role", format: (item) => Html.DropDownList("ddlBookingRole", ViewBag.BookingRoleList as SelectList, new { onchange = "GetPage(this);" }), style: "width:70%", canSort: false),
                  usersGrid.Column("PortaCallParticipantId", "Delete", format: @<input type="image" src="../../Content/images/deleteIcon.gif" name="Id" value="@item.AppUserId" />, style: "align:center", canSort: false)
                 )
                 )
          }

        } 

我想传入两个参数,GetPage(this,@item.AppUserId)但我不知道如何做同样的事情,请提前告诉我它的紧急感谢。

4

1 回答 1

0
usersGrid.Column(
    "ListItemId", 
    "Booking Role", 
    format: (item) => Html.DropDownList(
        "ddlBookingRole", 
        ViewBag.BookingRoleList as SelectList, 
        new { onchange = "GetPage(this, '@item.AppUserId');" }
    ), 
    style: "width:70%", 
    canSort: false
)

接着:

function GetPage(ddlBookingRole, appUserId) {
    $.getJSON(
        '/Calls/SelectedBookingRole', 
        { id: ddlBookingRole.value, appUserId: appUserId }, 
        function(d) {

        }
    );
}
于 2011-04-09T07:46:21.430 回答