[ 
https://issues.apache.org/jira/browse/TRINIDAD-959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12571315#action_12571315
 ] 

Paul Mander commented on TRINIDAD-959:
--------------------------------------

I think this is supported already. Just extend SortableModel

public class MyCollectionModel extends SortableModel {
                public MyCollectionModel(Object model) {
                        super(model);
                }

                public MyCollectionModel() {
                        super();
                }

                @Override
                public int getRowCount() {
                        return -1;
                }
        }

In your page bean return a CollectionModel rather than a Collection as follows:

public CollectionModel getItems() {
                List<Row> result = new ArrayList<Row>();
                result.add(new Row("Bob", "Smith"));
                result.add(new Row("Tom", "Jones"));
                result.add(new Row("Jack", "Brown"));
                // add in a few more rows 
                for (int i = 1; i < 10; i++) {
                        result.add(new Row(String.valueOf(i), "generated"));
                }
                MyCollectionModel model = new MyCollectionModel(result);
                return model;
}

Then in your page:

                       <tr:table value="#{table.items}" var="row" 
                                rows="5">
                                <tr:column headerText="First Name" 
sortable="true"
                                        sortProperty="firstName">
                                        <tr:outputText value="#{row.firstName}" 
/>
                                </tr:column>
                                <tr:column headerText="Last Name">
                                        <tr:outputText value="#{row.lastName}" 
/>
                                </tr:column>
                        </tr:table>



> Table sorting for uknown row count
> ----------------------------------
>
>                 Key: TRINIDAD-959
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-959
>             Project: MyFaces Trinidad
>          Issue Type: Improvement
>    Affects Versions: 1.0.7-core
>            Reporter: Tomas Havelka
>
> Is planned to support sorting in model with not known row count (-1) in near 
> future?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to