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

Re: [ydn-javascript] How do I listen for the dataErrorEvent on a DataSource

Expand Messages
  • Satyam
    You don t use the Event utility for custom errors. Components such as DataSource and DataTable have their own subscribe method to set listeners to subscribe
    Message 1 of 2 , Mar 30, 2009
      You don't use the Event utility for custom errors. Components such as
      DataSource and DataTable have their own subscribe method to set
      listeners to subscribe to their events, thus, it is not:

      YAHOO.util.Event.addListener(this.datasource, "dataErrorEvent", handleDataError);


      but

      this.datasource.subscribe("dataErrorEvent",handleDataError);

      and likewise with DataTable.

      Satyam

      ckingsolekai escribió:
      > I know this is probably a simple question, but I can't seem to figure it out. Maybe its a monday problem...
      >
      > Anyhow, I want to be able to handle the "dataErrorEvent" when my datatable can't parse its jsonData... usually this occurs when there's been an exception on the server and the data is just a stacktrace.
      >
      > So, I have tried to add an event listener on both the datasource and the datatable without success. The fireEvent code is called in dataSource.js, but I never get my callback. I think there's something I'm misunderstanding about the event registration in general.
      >
      > Here's my code:
      >
      > this.datasource = new YAHOO.util.DataSource(url);
      > this.datasource.responseType = YAHOO.util.DataSource.TYPE_JSON;
      > this.datasource.responseSchema = {
      > resultsList: "records",
      > metaFields: {
      > totalRecords: "totalRecords" // Access to value in the server response
      > },
      > fields:[ {key:"id"},
      > {key:"text"}
      > ]
      > };
      >
      > YAHOO.util.Event.addListener(this.datasource, "dataErrorEvent", handleDataError);
      >
      > var columns = [{key:"selected",label:"Selected", width:"30" , formatter:checkFormatter},
      > {key:"text", label:"Text", sortable:true, resizeable:true, width:"300", formatter:hhdFormatter}
      > ];
      >
      > // DataTable instance
      > var oConfigs = {
      > initialRequest: "startIndex=0&results=20", // Initial values
      > paginator: paginatorWidget,
      > dynamicData: true
      > };
      >
      > // render datatable
      > this.datatable = new YAHOO.widget.DataTable("noteDatatable", columns, this.datasource, oConfigs );
      > this.datatable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
      > handleReturnData(oRequest, oResponse, oPayload);
      > oPayload.totalRecords = oResponse.meta.totalRecords;
      > return oPayload;
      > };
      >
      > YAHOO.util.Event.addListener(this.datatable, "dataErrorEvent", handleDataError);
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 8.5.285 / Virus Database: 270.11.32/2030 - Release Date: 03/30/09 08:40:00
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.