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

Re: Is there a method to get the contents of a cell

Expand Messages
  • pankaj_vaidya
    ... to Newrec2 , ... to Newrec2 . ... query on ... Hi, I tried out the approach suggested but I am getting an error saying that textContent is null or
    Message 1 of 3 , Jul 8, 2007
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "ishmalius" <ishmalius@...>
      wrote:
      >
      > --- In ydn-javascript@yahoogroups.com, "pankaj_vaidya"
      > <pankaj_vaidya@> wrote:
      > >
      > >
      > > Is there any method for getting the contents of a given cell ?
      > >
      > > Here is what I am trying to do:
      > > Suppose I have the following table with Inline Editing enabled:
      > >
      > > id | field1 | field2 |
      > > 1 | data12 | Oldrec1 |
      > > 2 | data34 | Oldrec2 |
      > >
      > > Now if I edit the cell containing the text "Oldrec2"
      to "Newrec2",
      > > the logger displays the following message:
      > >
      > > Cell "yui-dt0-bdrow1-cell2" was updated from "Oldrec2"
      to "Newrec2".
      > > Now, I want to get the contents of the first cell in the row
      > > (cell identifier "yui-dt0-bdrow1-cell0" )so that I can fire a
      query on
      > > the database like :
      > > update table set field2 = ? where id = ?.
      > >
      > > So is there a method which will let me do something like this :
      > > getCellContents("yui-dt0-bdrow1-cell0")
      > > OR getCellContents(tableIdentifier,1,0)
      > >
      >
      > I agree. Since Datatable and Datasource are MVC, then it
      > would be -much- better for the events to indicate the row and
      > column index of the affected cell than just the TD involved.
      > Either that, or return an Object of the data that set the row
      > in the first place.
      >
      > Here is a little function I have for getting the ith column
      > field from the row of the given TD:
      >
      > /**
      > * Return the value in the 'col' column of the
      > * row that is the parent of the current (probably td) node
      > */
      > function getColValue(node, col)
      > {
      > var row = node;
      > while (row.tagName != "tr")
      > {
      > row = row.parentNode;
      > if (!row || !row.tagName)
      > return "undefined";
      > }
      > var tds = row.getElementsByTagName("td");
      > if (tds.length == 0 || tds.length<=col)
      > return "undefined";
      > return tds[col].textContent.replace(/^\s+|\s+$/g,"");
      > }
      >

      Hi,
      I tried out the approach suggested but I am getting an error saying
      that " 'textContent' is null or not an object ". Do I have to do
      something additional for this to work?

      This was signature of your function:
      function getColValue(node, col)

      So here is what I tried to pass:
      getColValue(oArgs.target,1);

      Any suggestions ?
    Your message has been successfully submitted and would be delivered to recipients shortly.