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

How to subscribe events to new data in ScrollingDataTable?

Expand Messages
  • m31va
    Hello, I have a ScrollingDataTable that can get updated with new rows and I cannot get events to fire in the table. Here is a snippet of code:
    Message 1 of 1 , Sep 22, 2009
      Hello,

      I have a ScrollingDataTable that can get updated with new rows and I cannot get events to fire in the table. Here is a snippet of code:

      *******************************************************************

      // Set the column definitions
      var columnDefs = [
      {key:"column1" hidden:true},
      {key:"column2", label:"Name", resizeable:false},
      {key:"column3", hidden:true}
      ];

      var dataSource = new YAHOO.util.DataSource("myAction.do");
      dataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
      dataSource.connMethodPost = true;
      dataSource.connXhrMode = "queueRequests";

      dataSource.responseSchema =
      {
      resultsList:"data",
      fields:["column1", "column2", "column3"]
      };

      // Create the DataTable with local data source
      var myTable = new YAHOO.widget.ScrollingDataTable("myTableContainer", columnDefs, dataSource,
      {
      initialLoad : false,
      height: "450px",
      width: "350px",
      selectionMode: "single",
      MSG_EMPTY: "No search results"
      });

      // Event handlers for the search results table
      myTable.subscribe("rowMouseoverEvent", myTable.onEventHighlightRow);
      myTable.subscribe("rowMouseoutEvent", myTable.onEventUnhighlightRow);
      myTable.subscribe("rowClickEvent", myTable.onEventSelectRow);

      YAHOO.util.Event.addListener("searchButton", "click", function()
      {
      var urlParam = 'searchTerm=' + searchTerm.val();

      myTable.getDataSource().sendRequest(urlParam, {success: myTable.onDataReturnInitializeTable, failure: myTable.onDataReturnInitializeTable, scope: myTable});
      });
      *******************************************************************

      My page has a "Search" button that lets me search for things and any results are added to myTable via myTable.onDataReturnInitializeTable
      I cannot get rowMouseoverEvent and rowMouseoutEvent to show the highlighting/unhighlighting effect. Clicking on a row seems to select it, but it doesn't highlight.

      Is this happening because I have to re-subscribe to the events after the new rows are added? Thanks in advance!
    Your message has been successfully submitted and would be delivered to recipients shortly.