【问题标题】:How to specify position for sorting icons in displaytag如何在显示标签中指定排序图标的位置
【发布时间】:2013-03-25 06:29:42
【问题描述】:

我已经使用“sortable=true”对 displaytag 中的列进行了排序...但是我想在列的最右侧显示排序图标...我该怎么做? 这里只提一栏供大家参考……

<display:column  property="issuerName" scope="col" sortable="true" title="${issuerName}"  headerClass="hixTableHeader" class="displayTagtd" /> 

CSS 代码:

th.sortable a {
    background-image: url(../images/common/header/arrow_off.png);
    background-repeat: no-repeat;
    background-position:right;
    text-decoration: none;
    padding-right:25px;
    padding-left: 25px;

}

th.order1 a{
    background-image: url(../images/common/header/arrow_down.png);
    background-position:right;
    background-repeat: no-repeat;
    text-decoration: none;
    padding-right:25px;
    padding-left: 25px;
}

th.order2 a{
    background-image: url(../images/common/header/arrow_up.png);
    background-repeat: no-repeat;
    text-decoration: none;
    background-position:right;
    padding-right:25px;
    padding-left: 25px;
}

【问题讨论】:

    标签: java css jsp jquery-ui-sortable displaytag


    【解决方案1】:

    尝试将其放在&lt;th&gt; 而不是&lt;a&gt;&lt;a&gt; 是一个 display:inline 元素,因此它不会拉伸 &lt;th&gt; 的整个大小。

    th.sortable {
        background-image: url(../images/common/header/arrow_off.png);
        background-repeat: no-repeat;
        background-position:right;
    }
    
    th.order1 {
        background-image: url(../images/common/header/arrow_down.png);
        background-position:right;
        background-repeat: no-repeat;
    }
    
    th.order2 {
        background-image: url(../images/common/header/arrow_up.png);
        background-repeat: no-repeat;
        background-position:right;
    }
    

    或者,您可以应用以下内容,这将使&lt;a&gt; 填充&lt;th&gt; 这可能更可取,因为您可以单击&lt;th&gt; 上的任意位置以激活排序。

    th a {
        display:block;
        width:100%;
        height:100%;
    }
    

    更新

    确保您也保留当前样式,要保留下划线,您需要确保它仍然针对您的 &lt;a&gt; 标记。您可以添加它来定位&lt;th&gt; 标签内的所有&lt;a&gt; 标签。

    th a {
        text-underline:none;
    }
    

    【讨论】:

    【解决方案2】:

    您可能需要更改包含&lt;display:column&gt; html 代码的模板文件

    【讨论】:

    • 能不能说的详细一点?
    • 我一直在使用 struts 2 标签,其中每个标签都有一个相应的免费标记模板文件,用于将标签呈现为传递给浏览器的 html 内容。在您的情况下, display:column 应该有一个这样的模板(可能是其他模板语言)。现在的问题是在列标题中定位与文本一起出现的图像,所以我猜你必须更改该模板文件中的代码才能达到所需的结果。
    猜你喜欢
    • 1970-01-01
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 2022-12-12
    • 2018-12-19
    • 1970-01-01
    相关资源
    最近更新 更多