Announcement

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

    ListGrid using RestDataSource and setData not transforming ISO date to DataSource-defined type

    When setting data on a ListGrid, the date fields do not appear to be transforming ISO text dates to actual date values as expected. I thought I understood in reading that the RestDataSource would perform that conversion. In the below sample, one sees the grid dates are not formatted nor are the form date values displayed when assigning the selected record, apparently due to dates being interpreted as text. Is there a simple work-around? Thanks in advance.

    Code:
    isc.RestDataSource.create({ ID:'rds1', fields: [
        { name: "rds1Id", type: "integer", primaryKey: true, hidden: true },
        { name: "nme", type: "string", title:'Name' },
        { name: "frDt", type: "date", format: 'MM/dd/yyyy', title:'From', defaultValue: new Date(1900,0,1) },
        { name: "toDt", type: "date", format: 'MM/dd/yyyy', title:'To', defaultValue: new Date(1900,0,1) }
    ]});
    
    isc.ListGrid.create({
     ID: 'rds1Grid',
     height: 90,
     width: 300,
     autoFetchData: false,
     dataSource: rds1,
     saveLocally: true,
     selectionType: 'single',
     defaultFields: [
                    { name: "nme", width:80 },
                    { name: "frDt", width:80 },
                    { name: "toDt", width: 80 }
    ],
     selectionChanged:(rec)=>{rds1Frm.setValues(rec);}
    });
    
    rds1Grid.setData([{rds1Id:1, nme:'XYZ Corp', frDt:'2025-01-12', toDt:'2025-04-30'},
    {rds1Id:2, nme:'New Corp', frDt:'2025-03-11', toDt:'2025-05-30'}]);
    
    isc.DynamicForm.create({
      ID: 'rds1Frm',
      top:100,
      height:50,
      width: 200,
      dataSource:rds1,
      fields: [ {name:'nme'}, {name:'frDt'}, {name:'toDt'}]
    });

    #2
    In setData(), supply the Date values as actual Dates, not strings. Search the SmartClient Reference for "createLogicalDate" and be sure to read the Date & Time Format and Storage overview.

    Comment

    Working...
    X