扩展数据网格

发布于 2024-07-29 13:09:36 字数 13738 浏览 4 评论 0原文

我想扩展 ASP.NET DataGrid Web 控件以添加许多附加功能,但最重要的是,我想让网格主体可滚动。

我已经解决了 HTML,但覆盖控件的呈现令人困惑。 最终控制的基本结构应该如下所示:

<div id="grid1" class="grid">
<div class="grid-header">
    <div class="grid-header-l"></div>
    <div class="grid-header-c">
        <div class="grid-header-wrapper">
            <div class="wrapper">Grid Header</div>
        </div>
    </div>
    <div class="grid-header-r"></div>
</div>
<div class="grid-body">
    <div class="grid-column-headers">
        <div class="grid-column-headers-l"></div>
        <div class="grid-column-headers-c">
            <div class="grid-column-headers-wrapper">
                <table class="grid-column-header-table" cellpadding="0" cellspacing="0" border="0">
                    <tbody>
                        <tr>
                            <td>
                                <div class="grid-column-header-cell asc">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="grid-column-header-cell">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                            <td class="last">
                                <div class="grid-column-header-cell">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="grid-column-headers-r"></div>
    </div>
    <div class="grid-body-content">
        <div class="grid-body-content-t">
            <div class="grid-body-content-t-l"></div>
            <div class="grid-body-content-t-c"></div>
            <div class="grid-body-content-t-r"></div>
        </div>
        <div class="grid-body-content-m">
            <div class="grid-body-content-m-l"></div>
            <div class="grid-body-content-m-c">
                <div class="grid-body-content-wrapper">
                    <div class="scroll-wrapper">
                        <table class="grid-content-table" cellpadding="0" cellspacing="0" border="0">
                            <tbody>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="grid-body-content-m-r"></div>
        </div>
        <div class="grid-body-content-b">
            <div class="grid-body-content-b-l"></div>
            <div class="grid-body-content-b-c"></div>
            <div class="grid-body-content-b-r"></div>
        </div>
    </div>
</div>

有人知道最好的方法应该是什么吗? 谁能指点我一些教程吗? 我注意到作者在将渲染的 html 发送到响应流之前捕获了它并对其进行了更改。 然而我不喜欢使用这种方法。

I would like to extend the ASP.NET DataGrid web control to add lots of additional features but most important of all, I would like to make the body of the grid scrollable.

I have the HTML worked out but overriding the rendering of the control is confusing. The basic structure of final control should look like so:

<div id="grid1" class="grid">
<div class="grid-header">
    <div class="grid-header-l"></div>
    <div class="grid-header-c">
        <div class="grid-header-wrapper">
            <div class="wrapper">Grid Header</div>
        </div>
    </div>
    <div class="grid-header-r"></div>
</div>
<div class="grid-body">
    <div class="grid-column-headers">
        <div class="grid-column-headers-l"></div>
        <div class="grid-column-headers-c">
            <div class="grid-column-headers-wrapper">
                <table class="grid-column-header-table" cellpadding="0" cellspacing="0" border="0">
                    <tbody>
                        <tr>
                            <td>
                                <div class="grid-column-header-cell asc">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="grid-column-header-cell">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                            <td class="last">
                                <div class="grid-column-header-cell">
                                    <div class="grid-column-header-cell-wrapper">
                                        <div class="grid-column-header-text" title="Column Header Name">Column Header Name</div>
                                        <a href="javascript:;" class="grid-column-header-button" title="Hide/Show Columns"><span></span></a>
                                        <div class="grid-column-header-divider"></div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="grid-column-headers-r"></div>
    </div>
    <div class="grid-body-content">
        <div class="grid-body-content-t">
            <div class="grid-body-content-t-l"></div>
            <div class="grid-body-content-t-c"></div>
            <div class="grid-body-content-t-r"></div>
        </div>
        <div class="grid-body-content-m">
            <div class="grid-body-content-m-l"></div>
            <div class="grid-body-content-m-c">
                <div class="grid-body-content-wrapper">
                    <div class="scroll-wrapper">
                        <table class="grid-content-table" cellpadding="0" cellspacing="0" border="0">
                            <tbody>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                    <td>
                                        <div class="grid-content-cell">Cell Text/Value</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="grid-body-content-m-r"></div>
        </div>
        <div class="grid-body-content-b">
            <div class="grid-body-content-b-l"></div>
            <div class="grid-body-content-b-c"></div>
            <div class="grid-body-content-b-r"></div>
        </div>
    </div>
</div>

Anyone know what the best approach should be? Can anyone point me to some tutorial? I have noticed one where the author captured the rendered html before it is sent to the response stream and altered it. I do not like to use that approach however.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十级心震 2024-08-05 13:09:36

您可以尝试这种方法。 对我来说效果很好。

You can try this approach. Works good for me.

樱娆 2024-08-05 13:09:36

因为我只想修改控件的输出,所以“扩展”控件实际上意味着我只需覆盖渲染。

我找到了有关控制适配器的文章,可以使用它来改变输出。 CodePlex 上存在名为“CSS 控制适配器'。 它对于 DataGrid 以外的更多控件都非常有帮助。

Because I only wanted to modify the output of the control, 'extending' the control actually meant that I only had to override the rendering.

I found articles on control adapters that one can use to alter the output. A project exists on CodePlex named 'CSS Control Adapters'. It has been very helpful on more controls than just the DataGrid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文