Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem displaying date

    I've got a RestDataSource that contains a date field. This datasource feeds a ListGrid, a DynamicForm, and a DetailViewer.
    The date is formatted as expected in the grid and the form (default short) but in the viewer it is formatted as as long string(guessing localestring).
    In reading the docs I see there is a property DateDisplayFormat and I set this to toUSShortDate in the viewer but get no change. (DateDisplayFormat:"toUSShortDate")
    Just to try it out I added the useTextField:true property in the field definition of the datasource and this change was seen in the form but still getting the long sting for the date in the detailviewer?
    Can someone point me to my error?

    #2
    Hi DocSeussMan,

    "DateDisplayFormat" is the name of a Type. The way you actually set it is via detailViewer.dateFormatter and related properties.

    Comment


      #3
      I have the same problem and this doesn't seem to be working. I have a field in a ListGrid defined as "date" type, and the ListGrid's dateFormatter property is set to "toUSShortDate" as specified in the reference docs. But when I view the ListGrid the dates show as, e.g., "/Date(1030683600000)/"

      What am I doing wrong?

      Here's my code for clarity (this is a simplified version of the overloaded ListGrid I'm using):

      Code:
      isc.ClassFactory.defineClass("DataTable","ListGrid");
      isc.DataTable.setProperties({
          autoDraw: false,
          autoFetchData: false,
          selectionType: "single",
          dateFormatter: "toUSShortDate"
      });
      And I set the fields as follows:

      Code:
      var schema=isc.XMLTools.toJS(xmlDoc);
      
      this.dataSource=isc.BrowserSource.create({
          fields: []
      });
      
      for (i=0;i<schema.Field.length;i++) {
          this.dataSource.fields[i]={
              name: schema.Field[i].Source,
              title: schema.Field[i].Title,
              type: schema.Field[i].Type
          };
      }
      I've used the Developer Console to confirm that, yes, the offending field has type="date", so that's not the problem. It seemed to me I did this exactly right, but clearly I've missed something. Help?

      Comment


        #4
        Sorry, I left out one important line:

        Code:
                        this.grid.setDataSource(this.dataSource);
        (where this.grid is the grid that displays the fields, and this.dataSource is the BrowserSource object I created above)

        Comment


          #5
          Maybe I should mention, also, that the .NET JavaScriptSerializer object serializes a date field as: "\/Date(1030683600000)\/"

          That's how the dates are coming through in my fetch JSON. Is that correct?

          Comment


            #6
            Aha! It should come through as: new Date(number), no quotes, no "\/". Ok, problem solved. Hope I didn't take up too much of your time :)

            Comment

            Working...
            X