vb.net 如何使用 Telerik RadGrid 启用网格水平滚动?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29287281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 18:55:16  来源:igfitidea点击:

How to enable grid horizontal scrolling with Telerik RadGrid?

asp.netvb.nettelerikradgrid

提问by PhoenixFly

Per title, I am trying to enable horizontal scrolling for a Telerik RadGrid. Beforehand, I used a parent div to control the width and height and then set the overflow property, which enabled horizontal scrolling. However, using this approach my grid stretches past the div width and along with it any uniformity.

根据标题,我正在尝试为 Telerik RadGrid 启用水平滚动。之前,我使用父div来控制宽度和高度,然后设置溢出属性,从而启用水平滚动。但是,使用这种方法,我的网格会延伸超过 div 宽度,并且随之而来的是任何均匀性。

Right now my code looks like this:

现在我的代码是这样的:

<div style="height:100%; float:left; width:99%">
    <div id="divFull" runat"server" style="width:99%; height:99%">
        <Telerik:RadGrid ID="deskFull" runat="server" Width="3200px" Height="100%"
            AllowPaging="True">
            <ClientSettings>
                <Scrolling AllowScroll="True" UseStaticHeaders="True"
                    SaveScrollPosition="True" />
            </ClientSettings>
            <MasterTableView AutoGenerateColumns="False" TableLayout="Fixed">
                <Columns>
                    <Telerik:GridBoundColumn DataField="Desk" HeaderText="Desk" />
                    <etc...>
                    <etc...>
                </Columns>
            </MasterTableView>
        </Telerik:RadGrid>
    </div>
</div>

What I am wanting to achieve is to not have the div tag control the scrolling, but rather the RadGrid itself. I have tried setting the column width to 200px via HeaderStyle-Width="200px" and restricting the grid's width to 100% of the parent div, but none of this worked. No horizontal scroll bar appeared on the grid and instead left a chunk of white space below the paging bar.

我想要实现的是不让 div 标签控制滚动,而是让 RadGrid 本身。我尝试通过 HeaderStyle-Width="200px" 将列宽设置为 200px 并将网格的宽度限制为父 div 的 100%,但这些都不起作用。网格上没有出现水平滚动条,而是在分页栏下方留下了一大块空白。

I have followed the online tutorials and have asked my colleague's for help, but no answers have come up.

我已经按照在线教程进行了操作,并向我的同事寻求帮助,但没有任何答案。

回答by Phil

There are plenty of examples of this on teleriks site

Teleriks 网站上有很多这样的例子

http://www.telerik.com/forums/radgrid-horizontal-scrolling

http://www.telerik.com/forums/radgrid-horizo​​ntal-scrolling

which states:

其中指出:

In order to display horizontal scroll for navigation, you need to make sure that the total width of the columns (either auto-generated or declaratively set) exceeds the width of the grid.

为了显示用于导航的水平滚动,您需要确保列的总宽度(自动生成的或声明性设置的)超过网格的宽度。

and here is a live demo showing horizontal scrolling: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/scrolling/scrolling/defaultcs.aspx

这是一个显示水平滚动的现场演示:http: //demos.telerik.com/aspnet-ajax/grid/examples/functionality/scrolling/scrolling/defaultcs.aspx

Are you sure the width of all of the columns in your grid exceeds the grid width? Try setting the grid to a fixed width.

您确定网格中所有列的宽度都超过了网格宽度吗?尝试将网格设置为固定宽度。