Loading ...
Sorry, an error occurred while loading the content.

datatable 2.5.2 problem sorting links in formatters

Expand Messages
  • inna_work
    Hello, I have a datatable using YUI 2.5.2 that has a few sortable columns. The columns that have numbers or strings do not pose any issues. One column has a
    Message 1 of 2 , Dec 9, 2008
    • 0 Attachment
      Hello,
      I have a datatable using YUI 2.5.2 that has a few sortable columns.
      The columns that have numbers or strings do not pose any issues.
      One column has a formatter that creates a link out of data and logic
      based on other column values. The link is built as a string, not as
      a DOM element and is then set to el.innerHTML. The value is either
      empty or a link.
      PROBLEM: When sorting by digits, the column with the link gets
      duplicate links in the rows that should not have anything.

      This is unfortunately very urgent and I already have spent countless
      hours investigating it.

      My formatters code:
      formatInvestigate : function(el, oRecord, oColumn, oData){

      var repValue = oRecord.getData(configObj.ipFields.rep);
      if (repValue == configObj.ipFields.repBad) {
      var link = "<a class=\"popup investigateLink\" target=\"_blank\" ";
      link += "title=\"" + I18N.get("investigate_alt") + "\" ";
      link += "href=\"" + configObj.tableProps.investigateURL;
      link += oRecord.getData(configObj.ipFields.ip) + "\">";
      link += I18N.get("investigate");
      link += "</a>";
      el.innerHTML = link;

      }

      }


      Table column config:
      {
      label: I18N.get("investigate"),
      sortable : sortable,
      formatter: IPBuilder.formatInvestigate
      };

      Suggestions for the workaround, please???
    • Satyam
      The DataTable tries to reuse the DOM elements that it has created as much as possible. What you are probably seeing in those cells that should be empty are
      Message 2 of 2 , Dec 9, 2008
      • 0 Attachment
        The DataTable tries to reuse the DOM elements that it has created as
        much as possible. What you are probably seeing in those cells that
        should be empty are the remains of their former content. Don't assume
        the DataTable will clear the cells before filling them in, in most cases
        it would be a waste of time and people want it as fast as possible.

        In the 'else' part of your formatter, set the cell contents to '':

        } else {
        el.innerHTML = '';
        }

        Satyam


        nna_work wrote:
        > Hello,
        > I have a datatable using YUI 2.5.2 that has a few sortable columns.
        > The columns that have numbers or strings do not pose any issues.
        > One column has a formatter that creates a link out of data and logic
        > based on other column values. The link is built as a string, not as
        > a DOM element and is then set to el.innerHTML. The value is either
        > empty or a link.
        > PROBLEM: When sorting by digits, the column with the link gets
        > duplicate links in the rows that should not have anything.
        >
        > This is unfortunately very urgent and I already have spent countless
        > hours investigating it.
        >
        > My formatters code:
        > formatInvestigate : function(el, oRecord, oColumn, oData){
        >
        > var repValue = oRecord.getData(configObj.ipFields.rep);
        > if (repValue == configObj.ipFields.repBad) {
        > var link = "<a class=\"popup investigateLink\" target=\"_blank\" ";
        > link += "title=\"" + I18N.get("investigate_alt") + "\" ";
        > link += "href=\"" + configObj.tableProps.investigateURL;
        > link += oRecord.getData(configObj.ipFields.ip) + "\">";
        > link += I18N.get("investigate");
        > link += "</a>";
        > el.innerHTML = link;
        >
        > }
        >
        > }
        >
        >
        > Table column config:
        > {
        > label: I18N.get("investigate"),
        > sortable : sortable,
        > formatter: IPBuilder.formatInvestigate
        > };
        >
        > Suggestions for the workaround, please???
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - http://www.avg.com
        > Version: 8.0.176 / Virus Database: 270.9.15/1837 - Release Date: 08/12/2008 9:38
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.