Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
[fix bug 1932978] Using Record ID for subsort is unreliable, since it…
Browse files Browse the repository at this point in the history
… is a String. Created count property to use instead.
  • Loading branch information
Jenny Han-Donnelly committed Jun 2, 2008
1 parent 35f96df commit 8581d93
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion widget/datatable/src/js/DataTable.js
Expand Up @@ -5720,9 +5720,10 @@ sortColumn : function(oColumn, sDir) {

// Default sort function
function(a, b, desc) {
YAHOO.util.Sort.compare(a.getData(oColumn.key),b.getData(oColumn.key), desc);
var sorted = YAHOO.util.Sort.compare(a.getData(oColumn.key),b.getData(oColumn.key), desc);
if(sorted === 0) {
return YAHOO.util.Sort.compare(a.getId(),b.getId(), desc);
return YAHOO.util.Sort.compare(a.getCount(),b.getCount(), desc); // Bug 1932978
}
else {
return sorted;
Expand Down
23 changes: 22 additions & 1 deletion widget/datatable/src/js/RecordSet.js
Expand Up @@ -702,7 +702,8 @@ YAHOO.lang.augmentProto(RS, util.EventProvider);
* @param oConfigs {Object} (optional) Object literal of key/value pairs.
*/
YAHOO.widget.Record = function(oLiteral) {
this._sId = "yui-rec" + YAHOO.widget.Record._nCount;
this._nCount = YAHOO.widget.Record._nCount;
this._sId = "yui-rec" + this._nCount;
YAHOO.widget.Record._nCount++;
this._oData = {};
if(oLiteral && (oLiteral.constructor == Object)) {
Expand All @@ -728,6 +729,16 @@ YAHOO.widget.Record = function(oLiteral) {
YAHOO.widget.Record._nCount = 0;

YAHOO.widget.Record.prototype = {
/**
* Immutable unique count assigned at instantiation. Remains constant while a
* Record's position index can change from sorting.
*
* @property _nCount
* @type Number
* @private
*/
_nCount : null,

/**
* Immutable unique ID assigned at instantiation. Remains constant while a
* Record's position index can change from sorting.
Expand Down Expand Up @@ -759,6 +770,16 @@ YAHOO.widget.Record.prototype = {
//
/////////////////////////////////////////////////////////////////////////////

/**
* Returns unique count assigned at instantiation.
*
* @method getId
* @return Number
*/
getCount : function() {
return this._nCount;
},

/**
* Returns unique ID assigned at instantiation.
*
Expand Down

0 comments on commit 8581d93

Please sign in to comment.