|
| 1 | +--- |
| 2 | +title: Dragging a Column in RadGrid Displays a Large White Box |
| 3 | +description: Resolving the issue where dragging a column in RadGrid with virtual scroll enabled displays a large white box instead of matching the column width. |
| 4 | +type: troubleshooting |
| 5 | +page_title: Large White Box Appears While Dragging Columns in RadGrid |
| 6 | +meta_title: Large White Box Appears While Dragging Columns in RadGrid |
| 7 | +slug: radgrid-white-box-dragging-columns |
| 8 | +tags: radgrid, asp.net ajax, css, column-reordering, virtual-scroll, debugger, styles |
| 9 | +res_type: kb |
| 10 | +ticketid: 1691575 |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment |
| 14 | + |
| 15 | +<table> |
| 16 | +<tbody> |
| 17 | +<tr> |
| 18 | +<td>Product</td> |
| 19 | +<td>RadGrid for ASP.NET AJAX</td> |
| 20 | +</tr> |
| 21 | +<tr> |
| 22 | +<td>Version</td> |
| 23 | +<td>2022.2.622</td> |
| 24 | +</tr> |
| 25 | +</tbody> |
| 26 | +</table> |
| 27 | + |
| 28 | +## Description |
| 29 | + |
| 30 | +When dragging a column to a new position in a [RadGrid](https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/overview) with virtual scroll paging enabled, a large white box appears instead of matching the width of the column. This behavior is caused by CSS rules overriding the dragger's styling, making it stretch across the screen. |
| 31 | + |
| 32 | +## Cause |
| 33 | + |
| 34 | +The issue occurs because RadGrid generates a floating dragger element styled with dimensions matching the column width. If global CSS rules applied to `table`, `tr`, or `td` elements on the page override these styles (e.g., `width: 100%` or `display: block`), the dragger element expands beyond the intended size. |
| 35 | + |
| 36 | +## Solution |
| 37 | + |
| 38 | +To achieve the correct behavior, apply CSS overrides to constrain the dragger's width. Follow these steps: |
| 39 | + |
| 40 | +1. Open the browser's Developer Tools by pressing F12. |
| 41 | +2. Use the following script to pause execution while dragging a column: |
| 42 | + ```javascript |
| 43 | + setTimeout(function(){ debugger; }, 3000); |
| 44 | + ``` |
| 45 | +3. Drag a column header and inspect the `<div>` element with classes like `rgHeader rgHeaderOver RadGrid RadGrid_Silk` and its `<table>` child. |
| 46 | +4. Inspect your site stylesheets for global CSS rules applied to `table`, `tr`, or `td` elements, and ensure they do not override RadGrid's styling. Applying the above CSS constraints resolves the issue. |
| 47 | +5. Alternatively apply the following CSS rules to limit the dragger's width: |
| 48 | + |
| 49 | + Limit the dragger width to its content: |
| 50 | + ```css |
| 51 | + div.rgHeaderOver table { |
| 52 | + width: auto !important; |
| 53 | + table-layout: auto !important; |
| 54 | + } |
| 55 | + ``` |
| 56 | + |
| 57 | + Force the dragger to match the column width: |
| 58 | + ```css |
| 59 | + div.rgHeaderOver { |
| 60 | + width: auto !important; |
| 61 | + max-width: 200px; /* Adjust to the column width */ |
| 62 | + } |
| 63 | + |
| 64 | + div.rgHeaderOver table { |
| 65 | + width: auto !important; |
| 66 | + } |
| 67 | + ``` |
| 68 | + |
| 69 | + |
| 70 | +## See Also |
| 71 | + |
| 72 | +- [RadGrid Documentation](https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/overview) |
| 73 | +- [Troubleshooting CSS Issues - Part 1](https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools) |
| 74 | +- [Troubleshooting CSS Issues - Part 2](https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools-(part-2)) |
0 commit comments