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

DataTable getRecord() How to get a datavalue w. recordset and getSelectedRows

Expand Messages
  • gux194
    How Do I get a selected record Item from a Dataset in a Datatable? I have: ====================================== function GetSelected () { var v1 =
    Message 1 of 2 , Jan 31, 2008
    • 0 Attachment
      How Do I get a selected record Item from a Dataset in a Datatable?

      I have:
      ======================================
      function GetSelected ()
      {
      var v1 = myhtmlDataTable.getSelectedRows();
      var val2 = myhtmlDataTable.getRecord(v1-5);
      alert(dump(val2));
      }
      ======================================
      and I get Back:

      '_sId' => "5"
      '_oData' ...
      'time_stamp' => "2008-01-17"
      'comment' => "this is a test comment"
      'id' => "1"
      'getId' => "function ()
      {
      return this._sId;
      }"
      'getData' => "function (sKey)
      {
      if (YAHOO.lang.isString(sKey))
      {
      return this._oData[sKey];
      }
      else
      {
      return this._oData;
      }
      }"

      =====================================

      The value I want to have is: oData.id

      Also the RowID Value is off by 5. It should be _sld = 0 or 1 by the selected row. But it
      returns _sld = 5


      Any Idea ?
    • Satyam
      What you are seeing is a dump of the YAHOO.widget.Record object which is what getRecord returns. If you are looking for any of the fields within it, you
      Message 2 of 2 , Jan 31, 2008
      • 0 Attachment
        What you are seeing is a dump of the YAHOO.widget.Record object which is
        what getRecord returns. If you are looking for any of the fields within it,
        you should use method getData()

        Also, the internal record id is the index the Record object got when it was
        initially loaded and it is kept for all the lifetime of the DataTable. The
        record index is its position within the table and it can change, for
        example, with a sort. Initially both will match but the record id is not
        the same as the row index. Make sure what is it that you need.

        Avoid using variables or methods that start with an underscore, there will
        be always getter and setter methods for those if they are of any use at all.
        Some variables are for internal purposes only and you should not rely on
        them and should not expect them to be available from one version to the
        next. If you use them you are on your own. JavaScript does not handle
        private properties and that underscode is the only conventional means to
        convey to the developer that the value shouldn't be seen or trusted.

        Satyam





        ----- Original Message -----
        From: "gux194" <gux194@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Thursday, January 31, 2008 8:52 PM
        Subject: [ydn-javascript] DataTable getRecord() How to get a datavalue w.
        recordset and getSelectedRows


        > How Do I get a selected record Item from a Dataset in a Datatable?
        >
        > I have:
        > ======================================
        > function GetSelected ()
        > {
        > var v1 = myhtmlDataTable.getSelectedRows();
        > var val2 = myhtmlDataTable.getRecord(v1-5);
        > alert(dump(val2));
        > }
        > ======================================
        > and I get Back:
        >
        > '_sId' => "5"
        > '_oData' ...
        > 'time_stamp' => "2008-01-17"
        > 'comment' => "this is a test comment"
        > 'id' => "1"
        > 'getId' => "function ()
        > {
        > return this._sId;
        > }"
        > 'getData' => "function (sKey)
        > {
        > if (YAHOO.lang.isString(sKey))
        > {
        > return this._oData[sKey];
        > }
        > else
        > {
        > return this._oData;
        > }
        > }"
        >
        > =====================================
        >
        > The value I want to have is: oData.id
        >
        > Also the RowID Value is off by 5. It should be _sld = 0 or 1 by the
        > selected row. But it
        > returns _sld = 5
        >
        >
        > Any Idea ?
        >
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.516 / Virus Database: 269.19.17/1252 - Release Date:
        > 30/01/2008 20:51
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.