将 GridView 包装在链接到 AJAX 工具包 ResizingControlExtender 的面板中
我正在尝试创建一个可调整大小的 GridView 包装为服务器控件。 我正在使用 AJAX 控件套件中的 ResizableControlExtender,据我所知,它要求
- 要调整大小的控件 的面板内
- 必须位于初始面板大小 必须与初始目标控制相匹配 尺寸。
我可以在测试 .aspx 页面中愉快地完成此操作,只需将网格正常地放入面板中即可,不会出现任何问题。 当我运行页面并查看源代码时,我可以看到面板呈现为围绕网格的 div。
但是,当我将其包装在服务器控件中时,面板的自动调整大小不会发生。 相反,面板的渲染 div 没有高度和宽度设置,因此在某种程度上小于网格。
我认为这是因为我没有设置扩展器的最小尺寸,然后扩展器将面板尺寸设置为空。 我没有设置最小大小,因为我无法在渲染之前计算网格的大小(因为它取决于 CSS)。
所以,我要么错误地使用了扩展器,要么我需要能够计算网格的高度(我相信这只能在javascript中实现?)
我已经用css中的固定大小破解了这个,但是这是垃圾,如果调整大小会导致换行。
任何想法/提示/等将不胜感激。
I am trying to create a resizable GridView wrapped up as a server control. I am using the ResizableControlExtender from the AJAX Control Kit, which as far as I know requires that
- the control that is to be resized
must reside inside a panel - the initial panel size
must match the initial target control
size.
I can do this happily in a test .aspx page with no issues by just putting my grid in the panel as normal. When I run the page and view the source, I can see that the panel is rendered as a div that surrounds the grid.
But, when I wrap it in a server control, the automatic sizing of the panel is not happening. Instead, the rendered div for the panel has no height and witdh settings and is therefore somehow smaller than the grid.
I think this is because I am not setting the minimum size of the extender and the extender is then setting the panel size to nothing. I am not setting the minimum size because I can't calculate the size of the grid before it is rendered (as it depends on the css).
So, I am either using the extender incorrectly or I need to be able to calculate the height of the grid (which I believe is only possible in javascript?)
I have hacked this with fixed sizes in the css but this is rubbish and breaks if resizing results in wrapping.
Any ideas/tips/etc would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 GridView(呈现为表格)位于 div 内,则 div 不能小于 GridView。 问题在于与 ResizeControlExtender 关联的 JavaScript 将调整大小句柄放置在错误的位置。 如果您尚未设置面板的高度和宽度 css 样式,则会发生这种情况。
以下代码已经过测试并且可以正常工作:
为了使其正常工作,我所做的就是向包含 GridView 的面板添加一个样式。 该样式设置初始高度和宽度,并且 ResizeControlExtender 正确放置在左下角。
我用于调整大小的 JavaScript 直接取自 AjaxToolkit 示例项目:
-Frinny
If GridView (rendered as a table) is within the div then the div cannot be smaller than the GridView. The problem is that the resize handle is being placed in the wrong spot by the JavaScript associated with the ResizeControlExtender. This happens if you haven't set the height and width css style for the panel.
The following code has been tested and works properly:
To get this to work all I did was add a style to the Panel containing the GridView. The style sets the initial height and width and the ResizeControlExtender is properly placed in the bottom left corner.
The JavaScript I used for resizing was taken directly out of the AjaxToolkit Example project:
-Frinny