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

Re: [ydn-javascript] Re: Hidden columns in DataTable....

Expand Messages
  • Satyam
    ... Two ways. Using named formatters is usually reserved for built-in formatters. For your own custom formatters you usually set formatter to a reference to
    Message 1 of 8 , Jul 2, 2008
    • 0 Attachment
      santini.alberto wrote:
      > A little question: if I have a formatter option in the column
      > definitions as
      >
      > ...
      > {key: "level", label: "Level", formatter: "rowMarker", hidden: true},
      > ...
      >
      > how to apply "rowMarker" at "level" field?
      >
      > Thanks in advance,
      > Alberto
      >
      Two ways.

      Using named formatters is usually reserved for built-in formatters. For
      your own custom formatters you usually set formatter to a reference to
      the formatter function itself

      {key: "level", label: "Level", formatter: function(el, oRecord, oColumn, oData) { el.innerHTML = oData }, hidden: true},

      You can also add your formatter to the list of built in formatters by
      adding it to the static Formatter object:

      YAHOO.widget.DataTable.Formatter['rowMarker'] = function(el, oRecord,
      oColumn, oData) { el.innerHTML = oData } ;

      see:
      http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#property_DataTable.Formatter
    • santini.alberto
      ... For ... oColumn, oData) { el.innerHTML = oData }, hidden: true}, ... Maybe I explained not very well my issue: if I delete the hidden column from the
      Message 2 of 8 , Jul 2, 2008
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
        >
        >
        >
        > santini.alberto wrote:
        > > A little question: if I have a formatter option in the column
        > > definitions as
        > >
        > > ...
        > > {key: "level", label: "Level", formatter: "rowMarker", hidden: true},
        > > ...
        > >
        > > how to apply "rowMarker" at "level" field?
        > >
        > > Thanks in advance,
        > > Alberto
        > >
        > Two ways.
        >
        > Using named formatters is usually reserved for built-in formatters.
        For
        > your own custom formatters you usually set formatter to a reference to
        > the formatter function itself
        >
        > {key: "level", label: "Level", formatter: function(el, oRecord,
        oColumn, oData) { el.innerHTML = oData }, hidden: true},
        >
        > You can also add your formatter to the list of built in formatters by
        > adding it to the static Formatter object:
        >
        > YAHOO.widget.DataTable.Formatter['rowMarker'] = function(el, oRecord,
        > oColumn, oData) { el.innerHTML = oData } ;
        >

        Maybe I explained not very well my issue: if I delete the hidden
        column from the column definitions (and letting the field in
        responseSchema) I cannot use the formatter.
        At the moment I'm using the second approach you suggested, because I
        define the function formatter as string in a Dialog runtime.

        But if delete that column definition I don't know how to put the
        formatter. :)


        Thanks,
        Alberto
      • Satyam
        ... Well, of course you wouldn t, if you don t plan to show it, why could you care to have a formatter? However, if you plan those hidden fields to affect the
        Message 3 of 8 , Jul 2, 2008
        • 0 Attachment
          santini.alberto wrote:
          > Maybe I explained not very well my issue: if I delete the hidden
          > column from the column definitions (and letting the field in
          > responseSchema) I cannot use the formatter.
          > At the moment I'm using the second approach you suggested, because I
          > define the function formatter as string in a Dialog runtime.
          >
          > But if delete that column definition I don't know how to put the
          > formatter. :)
          >
          >
          > Thanks,
          > Alberto
          Well, of course you wouldn't, if you don't plan to show it, why could
          you care to have a formatter?

          However, if you plan those hidden fields to affect the formatting of the
          other fields, put the formatter in those fields. They have access to
          the hidden fields through the oRecord argument. If you plan to affect
          the row, then place a formatter in any of the visible columns, let the
          value of that field pass through and do whatever else you meant for the row.

          Satyam
        • santini.alberto
          ... Good question! :) I use the information of the hidden column to change the background color of the row. var rowMarker = function (cell, rec, col, data) {
          Message 4 of 8 , Jul 2, 2008
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
            > Well, of course you wouldn't, if you don't plan to show it, why could
            > you care to have a formatter?

            Good question! :)
            I use the information of the hidden column to change the background
            color of the row.

            var rowMarker = function (cell, rec, col, data) {
            if (data === 1) {
            markLevel1[rec.getId()] = rec;
            } else if (data === 2) {
            markLevel2[rec.getId()] = rec;
            } else if (data > 2) {
            markLevel3[rec.getId()] = rec;
            }
            cell.innerHTML = data;
            };
            YAHOO.widget.DataTable.Formatter.rowMarker = rowMarker;

            And when it fires the render event i do:

            var updateMarks = function () {
            Dom.removeClass(
            Dom.getElementsByClassName('mark1', 'tr', 'tbl'), 'mark1');
            Dom.removeClass(
            Dom.getElementsByClassName('mark2', 'tr', 'tbl'), 'mark2');
            Dom.removeClass(
            Dom.getElementsByClassName('mark3', 'tr', 'tbl'), 'mark3');

            for (var recKey in markLevel1) {
            if (YAHOO.lang.hasOwnProperty(markLevel1, recKey)) {
            Dom.addClass(oCatDataTable.getTrEl(markLevel1[recKey]),
            'mark1');
            }
            }
            ...

            >
            > However, if you plan those hidden fields to affect the formatting of
            the
            > other fields, put the formatter in those fields. They have access to
            > the hidden fields through the oRecord argument. If you plan to affect
            > the row, then place a formatter in any of the visible columns, let the
            > value of that field pass through and do whatever else you meant for
            the row.

            Right! I didn't think about that.

            Thanks for the hint,
            Alberto
          Your message has been successfully submitted and would be delivered to recipients shortly.