Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在回发ASP.NET后,在DIV内保持gridview的水平滚动条位置_Javascript_Asp.net_Updatepanel - Fatal编程技术网

Javascript 在回发ASP.NET后,在DIV内保持gridview的水平滚动条位置

Javascript 在回发ASP.NET后,在DIV内保持gridview的水平滚动条位置,javascript,asp.net,updatepanel,Javascript,Asp.net,Updatepanel,我有一个非常长的网格视图。我想在回发时保持滚动位置。我已经尝试了很多解决堆栈溢出的方法,但我知道这对我有用 这是我的网格视图 <div class="largeGridScroll"> <asp:GridView ID="gvInventario" runat="server" AutoGenerateColumns="false" AllowSorting="true" ShowFooter="false" DataKeyNames="componen

我有一个非常长的网格视图。我想在回发时保持滚动位置。我已经尝试了很多解决堆栈溢出的方法,但我知道这对我有用

这是我的网格视图

<div class="largeGridScroll">
           <asp:GridView ID="gvInventario" runat="server" AutoGenerateColumns="false"  AllowSorting="true" ShowFooter="false" DataKeyNames="componente_id, ubicacion_id, proveedor_id"  PageSize="10"
                ShowHeaderWhenEmpty="true" AllowPaging="True" OnRowEditing="gvInventario_RowEditing" OnRowCancelingEdit="gvInventario_RowCancelingEdit" OnPageIndexChanging="gridView_PageIndexChanging" 
                 CellPadding="3"  AllowColumResize="True" onsorting="grdDetails_Sorting" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">    
                <Columns>
                </Columns>
            </asp:GridView>
            </div>
这是我的gridview的视觉效果。

当我按下其中一个按钮时,我不想像图片上那样失去滚动位置。我尝试过使用javascript和updatepanel,但没有成功,因为所有教程都有垂直滚动,而不是像我一样的水平滚动。任何帮助都将不胜感激,谢谢

我在这里找到了答案,我只需要改变一些小东西就可以了 这是我的css

.largeGridScroll 
{
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}
这是我的javascript

 $(document).ready(function () {
    maintainScrollPosition();
});

function pageLoad() {
    maintainScrollPosition();
}

function setScrollPosition(scrollValue) {
    $('#<%=hfScrollPosition.ClientID%>').val(scrollValue);
}

function maintainScrollPosition() {
    $("#dvScroll").scrollLeft($('#<%=hfScrollPosition.ClientID%>').val());
}
$(文档).ready(函数(){
保持滚动位置();
});
函数pageLoad(){
保持滚动位置();
}
函数设置滚动位置(滚动值){
$('#').val(滚动值);
}
函数位置(){
$(“#dvScroll”).scrollLeft($('#').val());
}
这是我的aspx

 <asp:HiddenField ID="hfScrollPosition" Value="0" runat="server" />
    <div  id="dvScroll" class="largeGridScroll" onscroll="setScrollPosition(this.scrollLeft);">

我在这里找到了答案,我只需要更改一些小东西,使之成为水平的 这是我的css

.largeGridScroll 
{
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}
这是我的javascript

 $(document).ready(function () {
    maintainScrollPosition();
});

function pageLoad() {
    maintainScrollPosition();
}

function setScrollPosition(scrollValue) {
    $('#<%=hfScrollPosition.ClientID%>').val(scrollValue);
}

function maintainScrollPosition() {
    $("#dvScroll").scrollLeft($('#<%=hfScrollPosition.ClientID%>').val());
}
$(文档).ready(函数(){
保持滚动位置();
});
函数pageLoad(){
保持滚动位置();
}
函数设置滚动位置(滚动值){
$('#').val(滚动值);
}
函数位置(){
$(“#dvScroll”).scrollLeft($('#').val());
}
这是我的aspx

 <asp:HiddenField ID="hfScrollPosition" Value="0" runat="server" />
    <div  id="dvScroll" class="largeGridScroll" onscroll="setScrollPosition(this.scrollLeft);">


删除了我的答案,因为它不适合您。顺便说一句,我们不知道你在用什么样的按钮,因为我们看不到标记。好的,谢谢你提供的信息,我将为它添加代码删除我的答案,因为它不适合你。顺便说一句,我们不知道你在用什么样的按钮,因为我们看不到标记。好的,谢谢你提供的信息,我将为它添加代码