This is a migrated thread and some comments may be shown as answers.

"stringifyDates" : true

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eyal
Top achievements
Rank 1
Eyal asked on 17 Jun 2015, 11:37 AM

Hello,

posted in DataSource forum, nobody answers, maybe here is the right place.

In some demos & examples I found this : "stringifyDates": true  in the data source configuration, 

but didn't find anything in the documentation about this.

another thing on same subject,  I try to use the parameterMap , to parse the model sent to the server,and stringify the date in the model "SupplyDate": { "type": "date" }, but  its never called! please see example here.

var ds = new kendo.data.DataSource({
    "type": (function () { if (kendo.data.transports['aspnetmvc-ajax']) { return 'aspnetmvc-ajax'; } else { throw new Error('The kendo.aspnetmvc.min.js script is not included.'); } })(),
    "transport": {
        "read": {
            "url": '/Controller/Products_Get',
            "data": function () {
                return {
                    "OrderNumber": "0001"
                };
            },
            "complete": function (jqXHR, textStatus) {
                if (textStatus == "error") {
                    var msg = "read event completed with error. invalid url or other javascript error";
                    console.log(msg);
                } else {
                    var result = JSON.parse(jqXHR.responseText);
                    console.log("jqXHR.responseText:\n" + jqXHR.responseText, '#ffffff', '#0011cc');
                }
            }
        },
        "update": {
            "//type": "POST",
            //"dataType": "json",
            //"contentType": "application/json",
            "url": '/Controller/Product_Upsert',
            "complete": function (jqXHR, textStatus) {
                Parse_UpsertOrDelete_Complete("update", jqXHR, textStatus);
            }
        },
        "create": {
            //"type": "POST",             
            //"dataType": "json",
            //"contentType": "application/json",
            "url": '/Controller/Product_Upsert',
            "complete": function (jqXHR, textStatus) {
                Parse_UpsertOrDelete_Complete("create", jqXHR, textStatus);
            }
        },
        "destroy": {
            //"type": "POST",              
            //"dataType": "json",
            //"contentType": "application/json",
            "url": '/Controller/Product_Delete',
            "complete": function (jqXHR, textStatus) {
                Parse_UpsertOrDelete_Complete("destroy", jqXHR, textStatus);
            }
        },
        "stringifyDates": true,
        "prefix": "",
        "parameterMap": function (data, operation) {
  
            console.log("operation: " + operation + " data: " + JSON.stringify(data));
  
            if (operation === "update" || operation === "create" || operation === "destroy") {
                return JSON.stringify({ entity: data });                  
            }
            return data;
        }
    },
    "pageSize": 1000,
    "page": 1,
    "total": 0,
    "serverPaging": true,
    "serverSorting": true,
    "serverFiltering": true,
    "serverGrouping": true,
    "serverAggregates": true,
    "filter": [],
    "error": function (jqXHR) {
        console.log("jqXHR.status =" + jqXHR.status);
    },
    "schema": {
        "data": "Data",
        "total": "Total",
        "errors": "Errors",
        "model": {
            "id": "OrderNumber",
            "fields": {                                      
                "OrderNumber": { "type": "number" },
                "SupplyDate": { "type": "date" },                  
                "CustomerName": { "type": "string" },                  
                "Units": { "type": "number" }
            }
        }
    }
});


function Parse_UpsertOrDelete_Complete(action, jqXHR, textStatus) { // handle complete...}

 

 

 Controller

class ProductEntity {
    public int OrderNumber {get;set;}
    public DateTime SupplyDate {get;set;}                  
    public string CustomerName {get;set;}                
    public int Units {get;set;}
}
  
[AcceptVerbs(HttpVerbs.Post)]
public async Task<ActionResult> Product_Upsert([DataSourceRequest]DataSourceRequest request,
                   ProductEntity entity)
{
  
        ProductEntity product =  entity;
  
        // product.SupplyDate  not set correctly when not using
        //  (   "stringifyDates": true  in the DataSource )
  
           
}

 

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 19 Jun 2015, 06:55 AM

Hello Eyal,

 

We have already answered your question in the other forum thread you have opened on this matter.

 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Eyal
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or