YUI DataTable - 如何只有一个分页器?

发布于 2024-07-15 19:27:28 字数 1470 浏览 8 评论 0原文

我正在使用 Grails UI 插件 1.0.2(YUI 为 2.6.1)的 Grails 1.1 项目中使用 YUI DataTable。

默认情况下,DataTable 显示 2 个分页器:一个位于表格上方,另一个位于表格下方。 查找 YUI API 文档,我可以看到我可以将 YUI 容器数组作为配置参数传递,但是 - 这些容器的名称是什么?

我尝试使用 Firebug 查看页面的 HTML。 包含分页器的 div 的 ID 为:yui-dt0-paginator0(上图)和 yui-dt0-paginator1(下图)。 如果我使用它们来配置导航器的容器,那么导航器根本不会显示。 以下是包含 Datatable 元素的 GSP 页面的相关摘录。

    <div class="body">
        <h1>This is the List of Control Accounts</h1>
        <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
        </g:if>
        <div class="yui-skin-sam">
            <gui:dataTable
            controller="controlAccount" action="enhancedListDataTableJSON"
            columnDefs="[
                [key:'id', label:'ID'],
                [key:'col1', label:'Col 1', sortable: true, resizeable: true],
                [key:'col2', label:'Col 2', sortable: true, resizeable: true]
                ]"
            sortedBy="col1"
            rowsPerPage="20"
            paginatorConfig="[
            template:'{PreviousPageLink} {PageLinks} {NextPageLink} {CurrentPageReport}',
            pageReportTemplate:'{totalRecords} total accounts',
            alwaysVisible:true,
            containers:'yui-dt0-paginator1'
            ]"
            rowExpansion="true"
            />
        </div>
    </div>

有什么帮助吗?

谢谢!

罗洛

I'm using the YUI DataTable in a Grails 1.1 project using the Grails UI plugin 1.0.2 (YUI being 2.6.1).

By default, the DataTable displays 2 paginators: one above and another one below the table. Looking up the YUI API documentation, I could see that I can pass an array of YUI containers as a config parameter but - what are the names of these containers?

I've tried loooking at the HTML of the page using Firebug. The ID of the divs containing the paginators are: yui-dt0-paginator0 (above) and yui-dt0-paginator1 (below). If I use them to configure the containers for the navigator, then the navigator is just not displayed at all. Here's the relevant extract of the GSP page containing the Datatable element.

    <div class="body">
        <h1>This is the List of Control Accounts</h1>
        <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
        </g:if>
        <div class="yui-skin-sam">
            <gui:dataTable
            controller="controlAccount" action="enhancedListDataTableJSON"
            columnDefs="[
                [key:'id', label:'ID'],
                [key:'col1', label:'Col 1', sortable: true, resizeable: true],
                [key:'col2', label:'Col 2', sortable: true, resizeable: true]
                ]"
            sortedBy="col1"
            rowsPerPage="20"
            paginatorConfig="[
            template:'{PreviousPageLink} {PageLinks} {NextPageLink} {CurrentPageReport}',
            pageReportTemplate:'{totalRecords} total accounts',
            alwaysVisible:true,
            containers:'yui-dt0-paginator1'
            ]"
            rowExpansion="true"
            />
        </div>
    </div>

Any help?

Thanks!

Rollo

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

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

发布评论

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

评论(3

梦初启 2024-07-22 19:27:28

好的,我现在有了。 将其发布在这里以防有人遇到同样的问题。

所以你要做的就是通过任何 id 创建一个“容器”(一个 DIV 即可),并将其引用到容器配置项中。 示例:

<div class="body">
    <h1>This is the List of Control Accounts</h1>
    <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
    </g:if>
            <div class="yui-skin-sam">
                    <gui:dataTable
                    controller="controlAccount" action="enhancedListDataTableJSON"
                    columnDefs="[
                            [key:'id', label:'ID'],
                            [key:'col1', label:'Col 1', sortable: true, resizeable: true],
                            [key:'col2', label:'Col 2', sortable: true, resizeable: true]
                            ]"
                    sortedBy="col1"
                    rowsPerPage="20"
                    paginatorConfig="[
                    template:'{PreviousPageLink} {PageLinks} {NextPageLink} {CurrentPageReport}',
                    pageReportTemplate:'{totalRecords} total accounts',
                    alwaysVisible:true,
                    containers:'dt-paginator'
                    ]"
                    rowExpansion="true"
                    />
            </div>
            <div id="dt-paginator" class="yui-skin-sam yui-pg-container" style="text-align: right;">
</div>

您只需确保与 div 关联的类是 yui-pg-container。
作为额外的好处,该 div 上的样式会将分页器向右对齐。

罗洛

Ok, I have it now. Posting it here in case someone bumps into the same question.

So what you have to do is create a 'container' (a DIV will do) by whatever id, and reference it into the containers configuration item. Example:

<div class="body">
    <h1>This is the List of Control Accounts</h1>
    <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
    </g:if>
            <div class="yui-skin-sam">
                    <gui:dataTable
                    controller="controlAccount" action="enhancedListDataTableJSON"
                    columnDefs="[
                            [key:'id', label:'ID'],
                            [key:'col1', label:'Col 1', sortable: true, resizeable: true],
                            [key:'col2', label:'Col 2', sortable: true, resizeable: true]
                            ]"
                    sortedBy="col1"
                    rowsPerPage="20"
                    paginatorConfig="[
                    template:'{PreviousPageLink} {PageLinks} {NextPageLink} {CurrentPageReport}',
                    pageReportTemplate:'{totalRecords} total accounts',
                    alwaysVisible:true,
                    containers:'dt-paginator'
                    ]"
                    rowExpansion="true"
                    />
            </div>
            <div id="dt-paginator" class="yui-skin-sam yui-pg-container" style="text-align: right;">
</div>

You just have to make sure that the class associated to the div is yui-pg-container.
As an added bonus, the style on that div will align the paginator to the right.

Rollo

心作怪 2024-07-22 19:27:28

对于 YUI 2.8.0(也许还有 2.6),有一种更简单的方法。 只需添加样式:

.yui-skin-sam .yui-dt-paginator {
    text-align:right;
} 

#yui-dt0-paginator1 {
    display:none;
}

这样做的优点是分页器与表格右边框对齐。 如果您希望分页位于表格底部,只需将 yui-dt0-paginator1 更改为 yui-dt0-paginator0 即可。

With YUI 2.8.0 (and maybe with 2.6 as well) there is an easier way. Just add the styles:

.yui-skin-sam .yui-dt-paginator {
    text-align:right;
} 

#yui-dt0-paginator1 {
    display:none;
}

This has the advantage that the paginator is aligned to the tables right border. If you want to have the pagination at the bottom of the table, just change yui-dt0-paginator1 to yui-dt0-paginator0.

榆西 2024-07-22 19:27:28

我有数十个 YUI 数据表,并且不想为每个数据表编写一个选择器,所以这就是我所做的。 在每个数据表周围创建一个“容器”div,然后使用第一个子选择器将可见性设置为隐藏,如下所示:

.container_div .yui-dt-paginator:first-child {
    visibility:hidden;
}

注意 .container_div 可以被称为您喜欢的任何名称。

感谢 Rollo 和 jm 的启发,这是两种想法的混搭。

I have many tens of YUI datatables and didn't want to have to write a selector for each one so here is what I did. Create a 'container' div around each datatable then use the first-child selector to set the visibility to hidden like so:

.container_div .yui-dt-paginator:first-child {
    visibility:hidden;
}

note .container_div can be called what ever you like.

Thanks to both Rollo and jm for the inspiration, it's kind of a mashup of both ideas.

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