WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Sortable Table - sorting images, Hee-Do Hong, February 25, 2004

Subject: Sortable Table - sorting images From: Hee-Do Hong Date: February 25, 2004

when you wanna sort images in sortable table you should add custom sort type. but this is not enough.

I should edit "sortabletable.js" file like following:

SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
 // if we have defined a custom getRowValue use that
 if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
  return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);

 var s;
 var c = oRow.cells[nColumn];
 if (typeof c.innerText != "undefined")
    s = c.innerText;
 else
  s = SortableTable.getInnerText(c);
 return this.getValueFromString(s, sType);
};

should be,

SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
 // if we have defined a custom getRowValue use that
 if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
  return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);

 var s;
 var c = oRow.cells[nColumn];
 if (typeof c.innerText != "undefined" && c.innerText) 
  s = c.innerText;
 else
  s = SortableTable.getInnerText(c);
 return this.getValueFromString(s, sType);
};

and,

SortableTable.getInnerText = function (oNode) {
 var s = "";
 var cs = oNode.childNodes;
 var l = cs.length;
 for (var i = 0; i < l; i++) {
    switch (cs[i].nodeType) {
   case 1: //ELEMENT_NODE
    s += SortableTable.getInnerText(cs[i]);
    break;
   case 3: //TEXT_NODE
    s += cs[i].nodeValue;
    break;

  }
 }
 return s;
};

should be,

SortableTable.getInnerText = function (oNode) {
 var s = "";
 var cs = oNode.childNodes;
 var l = cs.length;
 for (var i = 0; i < l; i++) {
    if (cs[i].nodeType == 1) { //ELEMENT_NODE
      if (cs[i].tagName.toUpperCase() == "IMG")
        s += cs[i].alt;
      else
      s += SortableTable.getInnerText(cs[i]);
    } else if (cs[i].nodeType == 3) { //TEXT_NODE
      s += cs[i].nodeValue;
    }

 }
 return s;
};

and then you can sort images by it's alt text.




Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX