Search code examples
javascriptyuiyui-datatableyui-datasource

Get full data set, sorted with YUI Data Table with Pagination


I hope I am describing my issue enough.. here goes:

I have a YUI data table, get a server side set of records via JSON, and then populates the data.

Users can click on the headers to sort the data in three of the 6 columns, (which are using a custom sort function for each column). The sorting is done client-side.

When a user sorts the data, I need to be able to get a complete list of the values from one of the columns being shown. I need all the data available, not just what's rendered to the page. The data hidden via pagination must be included.

Any ideas? I've tried the handleDataReturnPayload and doBeforeLoadData methods of the DataTable but both give the original, unsorted data.

I'm really stuck here and I've got a client depending on a feature that depends on me getting this sorted list.

Thanks in advance.


Solution

  • Satyam, over at the YUI Forums answered my question perfectly.

    The data is actually stored in the RecordSet. At any time you can go and look at it, and it will be sorted as shown on the screen, but it will have all the data, whether shown or not.

    Method getRecordset() will give you a reference to it and then you can loop through its records.

    You can listen to the columnSortEvent to be notified a sort has occurred.

    I just subscribed to the columnSortEvent event and looped through the array returned by datatable.getRecordSet().getRecords().