带按钮分组行的页面

问题描述 投票:0回答:1

我有一个gridview页面,有分组行。当我通过第二个gridview中的ajax更新信息时,在点击按钮Plus,减号后刷新信息。如何在不点击Plus-minus的情况下更新第二个网格内的数据? enter image description here

我在另一个gridview中显示和关闭gridview的代码。

$('.glyphicon-plus').click(function (event) {
                    if ($(this).hasClass("glyphicon-plus"))
                        $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>");
                    else
                        $(this).closest("tr").next().remove();
                    $(this).toggleClass('glyphicon-plus glyphicon-minus');});

代码gridview

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" Style="display: none" Visible="true"><ContentTemplate><asp:GridView ID="grdId" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid" Width="100%" OnRowDataBound="grdId_RowDataBound" HeaderStyle-HorizontalAlign="Center"><Columns></Columns>
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>

ajax方法

var thisCell=this.value;var id=this.id; $.ajax({type: \"POST\",url: \"myPage.aspx/myMethod\",data: '{value:\"'+comment+'\",id:\"'+id+'\"}',
    contentType: \"application/json; charset=utf-8\",
    dataType: \"json\",success: function(response) {}}); 
javascript asp.net
1个回答
0
投票

通过JS解决问题,在加载时,我使用脚本来更改我的架构gridview。

$('#MainContent_GridView > tbody  > tr').each(function () {
                     var div1 = $(this).find('.hideGroup');
                     $(this).find('.hideGroup').remove();
                     var row = $('<tr>').append($('<td>')).append($('<td colspan = "999">').append(div1));
                     $(row).insertAfter($(this).closest('tr'));
                 });

并在事件点击代码上更改。

$('.glyphicon-plus').click(function (event) {var thisHG = $(this).closest("tr").next().find('.hideGroup');
                    console.log(thisHG);
                    thisHG.toggle();
                    $(this).toggleClass('glyphicon-plus glyphicon-minus');
}
© www.soinside.com 2019 - 2024. All rights reserved.