سؤال

Is there a way to sort the initial data displayed on UI using tr:table? I know there are sort properties which can be defined on tr:column and which are used to sort the data present in the table.

But the requirement here is to have the data sorted by default when the page is opened. Is there a way to do that except sorting the table data from back end?

هل كانت مفيدة؟

المحلول

You can't sort a table by default, but you have to do it programmatically. With a little bit of work you can write a reusable PhaseListener which you can control from your JSF page.

Make sure it only handles a single phase (for example PhaseId.RESTORE_VIEW) and use it to set the sort order using setSortCriteria:

List<SortCriterion> sortCriteria = new ArrayList<SortCriterion>(1);
String property = "myProperty";
boolean ascending = true;
sortCriteria.add(new SortCriterion(property, ascending));
myCoreTable.setSortCriteria(sortCriteria);

Now you only have to add two <f:attribute/>s on your table to pass both the property name and the ascending boolean so you can create a reusable listener for all your tables.

In your <tr:document> you can have a <f:attribute/> with a list of table ID's to process.

نصائح أخرى

as far as I know: No!

You can read from here for more information: "TRINIDAD-1491"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top