Webgrid 列包含下拉列表 onchange 下拉列表必须在对象中更新我想要行或对象的唯一 ID

发布于 2024-10-31 07:40:42 字数 1915 浏览 3 评论 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) 中传递两个参数,但我不知道如何做同样的事情,请建议我紧急 提前致谢。

Sample code:-

<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)
                 )
                 )
          }

        } 

I want to pass two parameter in GetPage(this,@item.AppUserId) but i am not getting how to do the same please suggest me its urgent
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2024-11-07 07:40:42
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) {

        }
    );
}
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
)

and then:

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

        }
    );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文