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

Re: [ydn-javascript] Re: Datatable: get data from selected rows

Expand Messages
  • Satyam
    getSelectedRows is not a global function but a method of DataTable, you cannot call it without prefixing with the instance of the DataTable you want it to act
    Message 1 of 4 , Nov 28, 2007
    • 0 Attachment
      getSelectedRows is not a global function but a method of DataTable, you
      cannot call it without prefixing with the instance of the DataTable you want
      it to act upon.

      Satyam

      ----- Original Message -----
      From: "erolunala" <euenala@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Wednesday, November 28, 2007 3:16 PM
      Subject: [ydn-javascript] Re: Datatable: get data from selected rows


      > Thanks alot Dave!
      > I am using 2.3.1 and I've tried your suggested changes but somehow I
      > am still unable to call the modified function "getSelectedRecords()"
      > via my form button <input type="button" value="Sel"
      > onclick="getSelectedRecords()">. IE nags me with an "object
      > expected"-error.
      > Any ideas?
      >
      > Cheers
      >
      > Erol
      >
      > --- In ydn-javascript@yahoogroups.com, "daveboulden" <dave@...> wrote:
      >>
      >> If you are using v2.3.1, then change:
      >>
      >> arrIds=myDataTable.getSelectedRecordIds();
      >>
      >> to:
      >>
      >>
      >> arrIds= myDataTable.getSelectedRows();
      >>
      >>
      >> then, as an example, to get the first selected record use:
      >>
      >>
      >> myRec=myDataTable.getRecord(arrIds[0]);
      >> myRecData=myRec.getData();
      >>
      >>
      >>
      >>
      >> --- In ydn-javascript@yahoogroups.com, "erolunala" <euenala@>
      >> wrote:
      >> >
      >> > Hi,
      >> > I want to access the data from the selected rows in a YUI
      >> DataTable. I
      >> > have tried several things but had no luck so far. It would be great
      >> if
      >> > anyone could help me getting this to work.
      >> > Here's a excerpt of the code I'm using now, the part that doesn't
      >> work
      >> > is the function below "//display selected data" and/or the <input
      >> > type="button" value="Sel" onclick="getSelectedRecords()">...
      >> >
      >> > Thanks for you help,
      >> >
      >> > Erol
      >> >
      >> >
      >> > this.myDataSource = new
      >> > YAHOO.util.DataSource(YAHOO.example.Data<%=parNum%>.Par<%=parNum%>);
      >> > this.myDataSource.responseType =
      >> > YAHOO.util.DataSource.TYPE_JSARRAY;
      >> > this.myDataSource.responseSchema = {
      >> > fields:
      >> > [{key:"regiment"},{key:"duty"},{key:"fname"},{key:"lname"},
      >> {key:"address"},{key:"zip"},{key:"city"},{key:"officePhone"},
      >> {key:"officeMobile"},{key:"officeFax"},{key:"officeEmail"},
      >> {key:"homePhone"},{key:"homeMobile"},{key:"homeFax"},
      >> {key:"homeEmail"},{key:"rank"},{key:"train"},{key:"prefix"},
      >> {key:"pager"},{key:"base"}]
      >> > };
      >> >
      >> > this.myDataTable = new
      >> > YAHOO.widget.DataTable("Par<%=parNum%>", myColumnDefs,
      >> > this.myDataSource, {sortedBy:{key:"regiment", dir:"asc"}});
      >>
      >> >
      >> > //select a row with a checkbox
      >> > this.myDataTable.subscribe("checkboxClickEvent",
      >> function(oArgs){
      >> > var elCheckbox = oArgs.target;
      >> > var elRecord = this.getRecord(elCheckbox);
      >> > var name = elRecord.getData("lname");
      >> > if(elCheckbox.checked) {
      >> > this.selectRow(elRecord);
      >> > }
      >> > else {
      >> > this.unselectRow(elRecord);
      >> > }
      >> > }
      >> > );
      >> >
      >> > //display selected data
      >> > function getSelectedRecords(){
      >> > arrIds=myDataTable.getSelectedRecordIds();
      >> > for(i=0; i<arrIds.length; i++)
      >> > {
      >> > alert(myDataTable.getRecordSet().getRecord
      >> (arrIds[i]).toJSONString());
      >> > }
      >> > }
      >> > };
      >> >
      >> > });
      >> > </script>
      >> > <input type="button" value="Sel" onclick="getSelectedRecords
      >> ()">
      >> > </form>
      >> >
      >>
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.503 / Virus Database: 269.16.9/1155 - Release Date:
      > 27/11/2007 20:30
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.