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

Hidden columns in DataTable....

Expand Messages
  • santini.alberto
    Hello. I modified the basic example of DataTable control adding 5 hidden columns. As you ll see there are, at the left of the datatable, 5 strips. Am I missing
    Message 1 of 8 , Jul 2 2:02 AM
    • 0 Attachment
      Hello.

      I modified the basic example of DataTable control adding 5 hidden
      columns. As you'll see there are, at the left of the datatable, 5
      strips. Am I missing something? Or is it the annoying problem of the
      minWidth (just noticed in the last weeks in the forum)?


      <script type="text/javascript">
      /*global YAHOO */
      YAHOO.util.Event.addListener(window, "load", function () {
      YAHOO.example.Basic = function () {
      var myColumnDefs = [
      {key: "id", sortable: true, resizeable: true},
      {key: "date", formatter:
      YAHOO.widget.DataTable.formatDate, sortable: true, sortOptions:
      {defaultDir: YAHOO.widget.DataTable.CLASS_DESC}, resizeable: true},
      {key: "quantity", formatter:
      YAHOO.widget.DataTable.formatNumber, sortable: true, resizeable: true},
      {key: "amount", formatter:
      YAHOO.widget.DataTable.formatCurrency, sortable: true, resizeable: true},
      {key: "title", sortable: true, resizeable: true},
      {key: "h1", hidden: true},
      {key: "h2", hidden: true},
      {key: "h3", hidden: true},
      {key: "h4", hidden: true},
      {key: "h5", hidden: true}
      ];

      this.myDataSource = new YAHOO.util.DataSource([
      {id: "po-0167", date: new Date(1980, 2, 24), quantity: 1,
      amount: 4, title: "A Book About Nothing"},
      {id: "po-0783", date: new Date("January 3, 1983"),
      quantity: null, amount: 12.12345, title: "The Meaning of Life"},
      {id: "po-0297", date: new Date(1978, 11, 12), quantity:
      12, amount: 1.25, title: "This Book Was Meant to Be Read Aloud"},
      {id: "po-1482", date: new Date("March 11, 1985"),
      quantity: 6, amount: 3.5, title: "Read Me Twice"}
      ]);
      this.myDataSource.responseType =
      YAHOO.util.DataSource.TYPE_JSARRAY;
      this.myDataSource.responseSchema = {
      fields: ["id", "date", "quantity", "amount", "title"]
      };

      this.myDataTable = new YAHOO.widget.DataTable("basic",
      myColumnDefs, this.myDataSource, {caption: "DataTable
      Caption"});
      }();
      });
      </script>


      Thanks in advance,
      Alberto Santini
    • Satyam
      The columns should be narrow strips on the right hand side of the table, not the left. If that is the case, that is fine, hidden columns are meant to be
      Message 2 of 8 , Jul 2 2:15 AM
      • 0 Attachment
        The columns should be narrow strips on the right hand side of the table,
        not the left. If that is the case, that is fine, hidden columns are
        meant to be hinted at so the user can eventually shown them by means you
        should provide.

        If you don't mean to ever show those columns, don't declare them in the
        column definitions. If they are declared in
        theDataSource.responseSchema.fields array, the values will be available
        in the RecordSet for you to use and the columns won't be shown at all.

        Satyam


        santini.alberto wrote:
        > Hello.
        >
        > I modified the basic example of DataTable control adding 5 hidden
        > columns. As you'll see there are, at the left of the datatable, 5
        > strips. Am I missing something? Or is it the annoying problem of the
        > minWidth (just noticed in the last weeks in the forum)?
        >
        >
        > <script type="text/javascript">
        > /*global YAHOO */
        > YAHOO.util.Event.addListener(window, "load", function () {
        > YAHOO.example.Basic = function () {
        > var myColumnDefs = [
        > {key: "id", sortable: true, resizeable: true},
        > {key: "date", formatter:
        > YAHOO.widget.DataTable.formatDate, sortable: true, sortOptions:
        > {defaultDir: YAHOO.widget.DataTable.CLASS_DESC}, resizeable: true},
        > {key: "quantity", formatter:
        > YAHOO.widget.DataTable.formatNumber, sortable: true, resizeable: true},
        > {key: "amount", formatter:
        > YAHOO.widget.DataTable.formatCurrency, sortable: true, resizeable: true},
        > {key: "title", sortable: true, resizeable: true},
        > {key: "h1", hidden: true},
        > {key: "h2", hidden: true},
        > {key: "h3", hidden: true},
        > {key: "h4", hidden: true},
        > {key: "h5", hidden: true}
        > ];
        >
        > this.myDataSource = new YAHOO.util.DataSource([
        > {id: "po-0167", date: new Date(1980, 2, 24), quantity: 1,
        > amount: 4, title: "A Book About Nothing"},
        > {id: "po-0783", date: new Date("January 3, 1983"),
        > quantity: null, amount: 12.12345, title: "The Meaning of Life"},
        > {id: "po-0297", date: new Date(1978, 11, 12), quantity:
        > 12, amount: 1.25, title: "This Book Was Meant to Be Read Aloud"},
        > {id: "po-1482", date: new Date("March 11, 1985"),
        > quantity: 6, amount: 3.5, title: "Read Me Twice"}
        > ]);
        > this.myDataSource.responseType =
        > YAHOO.util.DataSource.TYPE_JSARRAY;
        > this.myDataSource.responseSchema = {
        > fields: ["id", "date", "quantity", "amount", "title"]
        > };
        >
        > this.myDataTable = new YAHOO.widget.DataTable("basic",
        > myColumnDefs, this.myDataSource, {caption: "DataTable
        > Caption"});
        > }();
        > });
        > </script>
        >
        >
        > Thanks in advance,
        > Alberto Santini
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG.
        > Version: 8.0.101 / Virus Database: 270.4.3/1529 - Release Date: 01/07/2008 19:23
        >
      • santini.alberto
        ... table, ... you ... Yes on the right, not on the left. :) Ok, I thought the colums was not visible at all. ... Yes, I will do so. I misunderstood the
        Message 3 of 8 , Jul 2 2:59 AM
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
          >
          > The columns should be narrow strips on the right hand side of the
          table,
          > not the left. If that is the case, that is fine, hidden columns are
          > meant to be hinted at so the user can eventually shown them by means
          you
          > should provide.

          Yes on the right, not on the left. :)
          Ok, I thought the colums was not visible at all.

          >
          > If you don't mean to ever show those columns, don't declare them in the
          > column definitions. If they are declared in
          > theDataSource.responseSchema.fields array, the values will be available
          > in the RecordSet for you to use and the columns won't be shown at all.
          >

          Yes, I will do so. I misunderstood the display of the hidden columns.

          > Satyam
          >

          Thanks,
          Alberto
        • santini.alberto
          ... in the ... available ... A little question: if I have a formatter option in the column definitions as ... {key: level , label: Level , formatter:
          Message 4 of 8 , Jul 2 3:03 AM
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, "santini.alberto"
            <albertosantini@...> wrote:
            >
            > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
            > > If you don't mean to ever show those columns, don't declare them
            in the
            > > column definitions. If they are declared in
            > > theDataSource.responseSchema.fields array, the values will be
            available
            > > in the RecordSet for you to use and the columns won't be shown at all.
            > >
            >
            > Yes, I will do so. I misunderstood the display of the hidden columns.
            >
            > > Satyam

            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
          • 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 5 of 8 , Jul 2 3:20 AM
            • 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 6 of 8 , Jul 2 3:32 AM
              • 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 7 of 8 , Jul 2 3:38 AM
                • 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 8 of 8 , Jul 2 3:54 AM
                  • 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.