QI 有一个 jQuery 函数,它使我的数据网格搜索结果可滚动。
但是,如果我更新面板,滚动条就会消失,结果只会填满整个页面。是因为它没有再次调用该函数吗?这是我当前的代码。
jQuery
<script type="text/javascript">
$(document).ready(function scroll() {
$('#<%=gvMapping.ClientID%>').Scrollable({ ScrollHeight: 370 });
}
)
</script>
<script type="text/javascript">
function getGL(){
var button = document.getElementById("<%= btnGetGLDept.ClientID %>");
button.click();
}
</script>
HTML
<%--Mapping Search Bar --%>
<div class="searchrev1">
<asp:TextBox ID="mpSearch" class="txtbox" runat="server" text="Please start entering Department Name or Number to search"
onfocus="if(this.value==this.defaultValue) {this.value='';$(this).css('color','#3B3B3B');}"
onblur="if(this.value=='') {this.value=this.defaultValue;$(this).css('color','rgb(173,180,195)');}" Width="400px"/>
<asp:Button ID="mapsearch" text="Search" runat="server"
onclick="getGLDepts" />
<asp:CheckBoxList ID="mpcbl" class="cbl" runat="server" DataSourceID="Rollup"
DataTextField="COA_SYSTEM" DataValueField="COA_SYSTEM" ondatabound="chkFormat" OnClick="javascript:scroll;getGL();"></asp:CheckBoxList>
<asp:SqlDataSource ID="Rollup" runat="server"
ConnectionString="<%$ ConnectionStrings:Rollup2ConnectionString %>"
SelectCommand="SELECT DISTINCT [COA_SYSTEM] FROM [T_ROLLUP_GL_EXCEPT]">
</asp:SqlDataSource>
</div>
<%--Mapping Graph --%>
<div class="botcontent">
<asp:Label ID="lblGLDeptData" runat="server"></asp:Label>
</div>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<div class="topcontent">
<asp:GridView ID="gvMapping" runat="server" GridLines="none" AutoGenerateColumns="false">
<HeaderStyle CssClass="GVFixedHeader" />
<Columns>...</Columns>
</asp:GridView>
<asp:Button ID="btnGetGLDept" runat="server" OnClick="getGLDepts" CssClass="invisible" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
单击时,我让 Checkboxlist 调用函数 getGL() 。然后调用 jquery 函数,该函数调用按钮单击来调用 c# 代码。这是不发生可滚动的时候。