Announcement

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

    How to get formatted date string in transformRequest?

    Hi guys.

    My version info is:
    SmartClient Version: SC_SNAPSHOT-2010-12-20/LGPL Deployment (built 2010-12-20)

    So, I'm using smartclient as a javascript client, and I provide a "transformRequest" callback so that I can convert to my back end API's expected format. Everything works great, except for dates. In the example I posted below, if I dip into dsRequest.data.hireDate, I expect to find something like "2007/10/22", which I can send directly to my back end, but instead I find a javascript Date object. What do I have to do to get the expected string result in dsRequest.data? Thanks much!

    Here's my sample application. Examine the "transformRequest" callback to see what I'm talking about...

    Code:
    <HTML><HEAD>
        <SCRIPT>var isomorphicDir="isomorphic/";</SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Core.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Containers.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Grids.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Forms.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
        <SCRIPT SRC=isomorphic/system/modules/ISC_Calendar.js></SCRIPT>
        <SCRIPT SRC=isomorphic/skins/standard/load_skin.js></SCRIPT>
    </HEAD><BODY BGCOLOR='silver'>
    
    <SCRIPT>
    
        // simple client-only dataSource
        isc.DataSource.create({
            ID:"employees",
            clientOnly:true,
            fields:[
                {name:"employeeID", type:"sequence", hidden:true, primaryKey:true},
                {name:"name", title:"Name"},
                {name:"hireDate", canedit:true, title:"Hiring Date", type:"date"}
            ],
            testData:[
                {employeeID:452, name:"Gene Porter", hireDate:new Date(2005,1,4)},
                {employeeID:782, name:"Cheryl Pearson", hireDate:new Date(2007,11,6)},
                {employeeID:751, name:"Rogine Leger", hireDate:new Date(2007,10,22)},
            ],
            transformRequest:function(dsRequest){
                if (dsRequest.operationType == "update") {
                    console.log(typeof dsRequest.data.hireDate); // outputs "object", when what I want is something like "2007/10/22"
                }
            }
        })
    
        isc.ListGrid.create({
            ID:"employeeGrid",
            width:250, height:100,
            canEdit:true,
            dataSource:"employees",
            autoFetchData:true,
            dateFormatter:"toJapanShortDate",
            dateInputFormat:"YMD"
        });
    
    
    </SCRIPT>
    </BODY>
    </HTML>

    #2
    Bump. Any thoughts?

    Comment


      #3
      Bump again. Dmitri? Little help?

      Comment

      Working...
      X