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

DataTable which row was selected?

Expand Messages
  • andrewrjones86
    Hi, I have set the table up with rowSingleSelect:true. I want the user to select a row, which then updates part of a page based on the data from that row.
    Message 1 of 3 , Feb 28, 2007
    • 0 Attachment
      Hi,

      I have set the table up with rowSingleSelect:true. I want the user to
      select a row, which then updates part of a page based on the data from
      that row. However, I cant work out how to get which row has been
      selected. Once I can do this, I will need to get data from a
      particular column in the row.

      Can anybody give me a some pointers to help me get started?

      Cheers,
      Andrew
    • Satyam
      This is what I figured: var onRowSelectEvent= function (e) { console.log(window.myDataTable.getRecordSet().getRecord(e.els[0].recordId)); }; The expression
      Message 2 of 3 , Feb 28, 2007
      • 0 Attachment
        This is what I figured:
         
        var onRowSelectEvent= function (e) {
         console.log(window.myDataTable.getRecordSet().getRecord(e.els[0].recordId));
        };
         
        The expression above returns a record, which have the original values of the DataSource as properties.  Otherwise, I found that the event gives more information about the HTML (which has been dynamically generated by the widget and is mostly unknown to me) than about the data in it.
         
        There should be a better way.
         
        Satyam
         
         
         
         
         
         
        ----- Original Message -----
        Sent: Wednesday, February 28, 2007 5:40 PM
        Subject: [ydn-javascript] DataTable which row was selected?

        Hi,

        I have set the table up with rowSingleSelect: true. I want the user to
        select a row, which then updates part of a page based on the data from
        that row. However, I cant work out how to get which row has been
        selected. Once I can do this, I will need to get data from a
        particular column in the row.

        Can anybody give me a some pointers to help me get started?

        Cheers,
        Andrew


        No virus found in this incoming message.
        Checked by AVG Free Edition.
        Version: 7.5.446 / Virus Database: 268.18.4/705 - Release Date: 27/02/2007 15:24
      • andrewrjones86
        I managed to get this working so thought I would post what I done in case anyone else is trying to do the same. Firstly create the DataTable with
        Message 3 of 3 , Mar 8, 2007
        • 0 Attachment
          I managed to get this working so thought I would post what I done in
          case anyone else is trying to do the same.

          Firstly create the DataTable with rowSingleSelect:true.

          Next add the event by doing the following:

          myDataTable.subscribe("selectEvent",eventSelectRow);

          Then create the function which is ran when a row is selected, as shown
          below

          function eventSelectRow(e){

          // gets the row object
          var row = this.getRecordSet().getRecord(e.els[0].recordId);
          }

          Once you have the row object, it will have the original values of the
          DataSouce as properties. So if you have a column of users, the
          following will show the user you selected.

          alert(row.user);

          Andrew



          --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
          >
          > This is what I figured:
          >
          > var onRowSelectEvent= function (e) {
          >
          console.log(window.myDataTable.getRecordSet().getRecord(e.els[0].recordId));
          > };
          >
          > The expression above returns a record, which have the original
          values of the DataSource as properties. Otherwise, I found that the
          event gives more information about the HTML (which has been
          dynamically generated by the widget and is mostly unknown to me) than
          about the data in it.
          >
          > There should be a better way.
          >
          > Satyam
          >
          >
          >
          >
          >
          >
          > ----- Original Message -----
          > From: andrewrjones86
          > To: ydn-javascript@yahoogroups.com
          > Sent: Wednesday, February 28, 2007 5:40 PM
          > Subject: [ydn-javascript] DataTable which row was selected?
          >
          >
          > Hi,
          >
          > I have set the table up with rowSingleSelect:true. I want the user to
          > select a row, which then updates part of a page based on the data from
          > that row. However, I cant work out how to get which row has been
          > selected. Once I can do this, I will need to get data from a
          > particular column in the row.
          >
          > Can anybody give me a some pointers to help me get started?
          >
          > Cheers,
          > Andrew
          >
          >
          >
          >
          >
          >
          >
          ------------------------------------------------------------------------------
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG Free Edition.
          > Version: 7.5.446 / Virus Database: 268.18.4/705 - Release Date:
          27/02/2007 15:24
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.