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

Re: SOLVED: Help - YUI:DataTable - can't get DateCellEditor() to work?

Expand Messages
  • psy3cho
    Hello Phil, I am writing in reference to the following post you made in the YUI Library group: http://tech.groups.yahoo.com/group/ydn-javascript/message/48401
    Message 1 of 3 , Sep 11, 2009
    • 0 Attachment
      Hello Phil,
      I am writing in reference to the following post you made in the YUI Library group: http://tech.groups.yahoo.com/group/ydn-javascript/message/48401

      I am having the same problem, so I am attempting to implement the fix outlined in your, I have two fields that use the DateCellEditor, date_on and date_off.

      The columns are defined has such:

      var cruiseContactsColumnDefs = [

      {key:"fields.date_on", label:"Date-onboard", formatter:YAHOO.widget.DataTable.formatDate, editor:new YAHOO.widget.DateCellEditor()},

      {key:"fields.date_off", label:"Date-offship",formatter:YAHOO.widget.DataTable.formatDate, editor:new YAHOO.widget.DateCellEditor()},
      ];

      I have placed your script in the responseSchema for the datasoruce just has you indicated:


      cruiseContactsDataSource.responseSchema = {
      resultsList: "ResultSet.Result",
      fields: ["pk", "model", "fields" , "fields.first_name", "fields.middle_name", {key:"fields.date_on", parser:"date"},{key:"fields.date_off", parser:"date"}, ]

      // overides the default YAHOO date parser
      // source: http://tech.groups.yahoo.com/group/ydn-javascript/message/48401
      var YAHOO.util.DataSource.Parser.date=function(oData){
      alert('date parser');
      var parts = oData.split(' ');
      alert('parts ' + parts);
      var datePart = parts[0].split('-');
      alert('datePart ' + datePart);
      if (parts.length > 1)
      {
      var timePart = parts[1].split(':');
      alert('timePart ' + timePart);
      alert('returning date');
      return new date(datePart[0],datePart[1]-1,datePart[2],timePart[0],timePart[1],timePart[2]);
      }
      else
      {
      alert('returning Date');
      return new Date(datePart[0],datePart[1]-1,datePart[2]);
      } //end else
      }; // end function date parser
      }; // end responseSchema

      However, when I load the page, FireFox generates this error:

      missing } after property list
      var YAHOO.util.DataSource.Parser.date=function(oData){


      Clearly, I am doing something wrong, but I can not seem to determine what it is. I am hoping you can help.







      --- In ydn-javascript@yahoogroups.com, "empois@..." <empois@...> wrote:
      >
      > I've managed to fix this now - I realised (from another post) that the
      > parser is called by the DataSource utility and not the DataTable itself.
      > Therefore, moving the parser parameter into the
      > myDataSource.responseSchema definition solves the problem:
      >
      > var myDataSource = new YAHOO.util.DataSource('units.xml');
      > myDataSource.connMethodPost = true; myDataSource.responseType =
      > YAHOO.util.DataSource.TYPE_XML; myDataSource.responseSchema = {
      > resultNode : 'unit', fields : ["unit_id", "unit_name", "unit_acronym",
      > "unit_display", {key:"unit_create_date",parser:"date"}] };
      >
      > I'm still overriding the built in date parser in order to work with
      > PostgresQL timestamp format:
      >
      > YAHOO.util.DataSource.Parser.date = function (oData) {
      > var parts = oData.split(' ');
      > var datePart = parts[0].split('-');
      > if (parts.length > 1) {
      > var timePart = parts[1].split(':');
      > return new
      > date(datePart[0],datePart[1]-1,datePart[2],timePart[0],timePart[1],timeP
      > art[2]);
      > } else {
      > return new Date(datePart[0],datePart[1]-1,datePart[2]);
      > }
      > };
      >
      > Hopefully this post will be useful for someone else!
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.