Ticket #2529872 (closed defect)

Reporter


Jenny Donnelly
Opened: 01/26/11
Last modified: 04/16/12
Status: closed
Type: defect
Resolution: fixed

Owner


Luke Smith
Target Release: 3.4.0
Priority: P3 (normal)
Summary: [bz 4284252] XHR data load breaks sorting
Description:

Calling load after setting up sorting breaks sorting.

Type: defect Observed in Version: 3.3.0
Component: DataTable Severity: S3 (normal)
Assigned To: Luke Smith Target Release: 3.4.0
Location: Library Code Priority: P3 (normal)
Tags: Relates To:
Browsers: All
URL:
Test Information:

YUI({ filter: 'raw' }).use("datasource-get", "datasource-jsonschema", "datatable-sort", "datatable-datasource", function (Y) {
var cols = ["Title", "Phone", {key:"Rating.AverageRating", label:"Rating", sortable:true}];
ds = new Y.DataSource.Get({
source:"http://query.yahooapis.com/v1/public/yql?format=json&env=store%3A//datatables.org/alltableswithkeys"})
.plug(Y.Plugin.DataSourceJSONSchema, {
schema: {
resultListLocator: "query.results.Result",
resultFields: ["Title", "Phone", "Rating.AverageRating"]
}
}),
dt = new Y.DataTable.Base({columnset:cols, summary:"Pizza places near 98089", caption:"Table with JSON data from YQL"}).plug(Y.Plugin.DataTableDataSource,
{datasource:ds}).plug(Y.Plugin.DataTableSort);
dt.render("#pizza");

Y.Plugin.DataTableDataSource.prototype.onDataReturnInitializeTable = function(e) {
var rs = dt.get("recordset")
rs.set("records", e.response.results);
dt._uiSetRecordset(rs);
}

dt.datasource.load({request:"&q=select%20*%20from%20local.search%20where%20zip%3D%2794089%27%20and%20query%3D%27pizza%27"});

/*dt.on("recordsetChange", function(e){
dt.get("recordset").unplug(Y.Plugin.RecordsetSort);
dt.unplug(Y.Plugin.DataTableSort);
dt.plug(Y.Plugin.DataTableSort);
//dt.get("recordset").plug(Y.Plugin.RecordsetSort, {dt: dt});

//dt.get("recordset").sort.addTarget(dt);
// Attach UI hooks
//dt.after("recordsetSort:sort", function() {
// this._uiSetRecordset(this.get("recordset"));
//});
});*/
});

Change History

George

YUI Developer

Posted: 02/3/11
  • summary changed from XHR data load breaks sorting to [bz 4284252] XHR data load breaks sorting

Luke Smith

YUI Contributor

Posted: 02/18/11

Luke Smith

YUI Contributor

Posted: 03/3/11
  • milestone changed from 3.NEXT to 3.4.0
  • status changed from assigned to accepted

Glenn

Posted: 04/22/11

I've encountered this problem also. The issue is that by default the onDataReturnInitializeTable method of the DataTableDataSource creates a new RecordSet object when loading a new data set, however the DataTableSort plugin is listening on the particular RecordSet instance. Since that's thrown away on a load the sort plugin never notices that there's new data to be sorted. I created a special subclass of DataTableDataSource that fixes this bug. Instead of creating a new RecordSet instance, it empties the old one and adds the new results.


SorterDataTableDataSource = function() {
SorterDataTableDataSource.superclass.constructor.apply(this, arguments);
}

Y.extend(SorterDataTableDataSource, Y.Plugin.DataTableDataSource, {
onDataReturnInitializeTable : function(e) {
var dt = this.get("host"), rs = dt.get("recordset");
dt.set("recordset", rs.empty().add(e.response.results));
}
}, {
NS: "datasource",
NAME: "dataTableSorterDataSource"
});

We're all waiting on Luke's new and improved DataTable :)

Luke Smith

YUI Contributor

Posted: 06/28/11

Ticket #2530184 was marked as a duplicate of this ticket.

Luke Smith

YUI Contributor

Posted: 06/28/11

Ticket #2529975 was marked as a duplicate of this ticket.

Luke Smith

YUI Contributor

Posted: 07/18/11

Replace the Recordset records, not the Recordset

Fixes #2529872

onDataReturnInitializeTable was replacing the
Recordset instance managed by the DataTable rather
than just replacing its records. Since a fair
amount of functionality is tied to the Recordset,
this broke stuff.

View Commit: 364b3f41370b5853ec58ed0f094565f69ab7c7fd

Luke Smith

YUI Contributor

Posted: 07/18/11
  • status changed from accepted to checkedin

Luke Smith

YUI Contributor

Posted: 07/18/11
  • completed changed from 0 to .25
  • estimated changed from 0 to .25
  • sprint changed to sprint 3

George

YUI Developer

Posted: 08/18/11
  • resolution changed to fixed
  • status changed from checkedin to closed

Luke Smith

YUI Contributor

Posted: 09/26/11

Ticket #2531191 was marked as a duplicate of this ticket.

msn [bot]

  • Username: msn [bot]
Posted: 04/16/12
  • browser changed from N/A to All