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

Re: [ydn-javascript] How to get the DataTable object from a linkClickEvent

Expand Messages
  • Satyam
    ... From: jinxdidnt To: Sent: Tuesday, January 29, 2008 7:05 AM Subject: [ydn-javascript] How to get the
    Message 1 of 2 , Jan 30, 2008
    • 0 Attachment
      ----- Original Message -----
      From: "jinxdidnt" <apv@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Tuesday, January 29, 2008 7:05 AM
      Subject: [ydn-javascript] How to get the DataTable object from a

      > This may be a trivial problem but I'm stuck after several hours of
      > futzing and doc diving.
      > I have up/down arrows for rows to change their order. They are set up
      > as links with onclicks to a function right now. The onclick function
      > is only visible if it's outside the scope in which the DataTable is
      > instantiated. The problem is then that there is no way to requery
      > (reload the DataTable) from the onclick function.
      > So, my onclick works, it updates the data via an Ajax request, but it
      > has no way to signal the data to update itself. This really needs to
      > happen inside the success function of the Ajax request.
      > I can think of two ways to fix this but I don't know *how* to do either.
      > I cannot globalize my DataTable and DataSource variables b/c I have
      > several instances of them in the page under different tabs. So the
      > solution has to be inside the scope of the objects.
      > 1) The onclick is changed to a cell event, but cellClickEvent with
      > onEventShowCellEditor for other fields and I don't want any of them to
      > be double clicks or any other event.

      You can have several listeners for the same event. For non-editable cells,
      onEventShowCellEditor will do nothing. Your function has to take care to do
      nothing for cells other than the ones with the up/down arrows, which, of
      course, should not be editable.

      > 2) I use a linkClickEvent instead but then how am I to pass the
      > arguments (up or down + the id of the row in question)? Can I get the
      > record from the event? I suspect so and that it's even simple but I'm
      > not seeing it. Little help?

      Yes, you can give method DataTable.getRecord the target argument from the
      event and it will provide you the record and then method getData() will give
      you the value of any field in the record. Also, from the target you can get
      any property you want to give to differentiate the up and down arrows, for
      example, classNames are a harmless property, any element can have a
      className even if that className is not defined in any stylesheet. You can
      also use the hash (#) part of the href with any arbitrary code you put
      there. Make sure to call Event.stopEvent to prevent the link from actually
      navigating anywhere.

      myDataTable.subscribe('linkClickEvent',function(ev) {
      var target = ev.target;
      var column = this.getColumn(target);
      if (column.key = 'myArrows') {
      var record = this.getRecord(target);
      // read the hash value (clean up the # sign)
      var hash = target.hash.substr(1);
      // or read a className
      if (YAHOO.util.Dom.hasClass(target,'upArrow')) ...... ;
      // to make double sure the link is not followed. (just paranoid)
      return false;

      > Thank you!
      > -Ashley
      > Yahoo! Groups Links
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.516 / Virus Database: 269.19.13/1246 - Release Date:
      > 27/01/2008 18:39
    Your message has been successfully submitted and would be delivered to recipients shortly.