0

这个问题已经被问过(Wicket 6 IColumn How the name can be of type other than string?),但没有得到回答。我突出了要回答的问题,以粗体...

接口 IColumn 包含一个方法 getSortProperty(),它返回任何类型 S 的值。名称如何可以是字符串以外的类型?

    /**
     * Returns the name of the property that this header sorts. If null is returned the header will
     * be unsortable.
     * 
     * @return the sort property
     */

S getSortProperty();

http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.html

在 wicket 旧版本 6 中:

PropertyColumn<SomeClass> column = new PropertyColumn(Model.of("Header"), "sortProperty", "propertyExpression"); 

检票口 6:说明:

PropertyColumn(IModel<String> displayModel, S sortProperty, String propertyExpression);

例子:

PropertyColumn<SomeClass, Long> column = new PropertyColumn(Model.of("Header"), ?, "propertyExpression"); 

在地上写什么“?”

4

2 回答 2

0
PropertyColumn<SomeClass, Long> column = new PropertyColumn(Model.of("Header"), 4l, "propertyExpression"); 

E.g. this could be used if SortableDataProvider was able to identify the sorted column by index (here 4th).

于 2013-06-13T10:53:37.707 回答
0

sortProperty 是一个字符串,用于标识要排序的属性。因此,它将始终是一个字符串。

例如,如果您的表位于 MyFirstSortableClass 的集合上,其中包含一个“日期”属性(具有相应的 getter/setter 的“日期”类型),您可以将“日期”设置为 sortProperty,以便为表选择的 SortableDataProvider 知道使用MyFirstSortableClass 的“日期”属性对列表进行排序。

dataprovider 的排序方式取决于它的实现,例如在我们的项目中,我们有两个 dataprovider,它们通过 order by 子句在数据库中排序,dataprovider 通过 List.sort 或类似的东西在 java 中排序。

于 2013-07-12T11:34:22.220 回答