开发者

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

开发者 https://www.devze.com 2022-12-16 03:11 出处:网络
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.

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开发者_C百科 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.


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().


I'd recommend posting this to the YUI forums -- http://yuilibrary.com/forum/ -- that's a great place to get support on DataTable issues.


I stumbled upon this question looking for information on how to retrieve information from a dataset that was NOT displayed in the datatable. IF you place the hidden data in the datasource before any field you wish to be displayed, it will be rendered blank, but if you place it after your last field that will be rendered (as defined by the columns object), then they will not render but still be accessible through the record).

var columns = [
    {key:"Whatchamacallits", children:[
        {key:"name" },
        {key:"price" }
    ]}
];
var ds = new YAHOO.util.DataSource('index.php...');
oDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
oDataSource.responseSchema = {
    fields:["name","price","id"]
};
var dt = new YAHOO.widget.DataTable("dt-id", columns, ds, {});
dt.subscribe("rowClickEvent", dt.onEventSelectRow);
dt.subscribe("rowSelectEvent", function(p){ alert(p.getData('id'); });
0

精彩评论

暂无评论...
验证码 换一张
取 消