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

Formatting doesn't apply when manually setting data on grid

4 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 02 Aug 2012, 08:45 PM
I have a Grid connected to DataSource and displayed on clipboard01.jpg
When I click on the Calculate button, I collect some the Grid's data and send it over to the server with an Ajax call
I return Json with some calculated values for the MTM field, which I'm adding to the grid...

    $.ajax({
        type: "POST",
        dataType: "json",
        data: unwindDataToPostObj,
        url: direction
    })
    .done(function (response) {
        var grid = $("#gridAssoc").data("kendoGrid");
        grid.dataSource.data(response);
        grid.refresh();
    })
    .fail(function (jqXHR) {
        console.log("error");
    });

Please look at picture: clipboard02.jpg now
The formatting for the Trade Date & Settle Date is now broken, although it was declarative set by the book.

    // ** Grid widget
    $("#gridAssoc").kendoGrid({
        dataSource: CFDUnwind._assocTradesDataSource,
        navigatable: true,
        selectable: "single",
        height: 300,
        resizable: true,
        sortable: {
            mode: "single",
            allowUnsort: false
        },
        columns: [
            { field: "Strategy", title: "Strategy", width: 60 },
            { field: "ImagineSNum", title: "ImagineSNum", width: 50 },
 
            {
                field: "TradeDate", title: "Trade Date", width: 48,
                template: '#= kendo.toString(TradeDate,"MM/dd/yyyy") #'
            },
            {
                field: "SetlDate", title: "Settle Date", width: 48,
                template: '#= kendo.toString(SetlDate,"MM/dd/yyyy") #'
            },
...etc....

1. Why is the formatting not obeyed?
2. In other words how do I manually set the data on the grid and preserve any formatting already set on the columns?

~ Boris

4 Answers, 1 is accepted

Sort by
0
Brannon
Top achievements
Rank 1
answered on 28 Sep 2012, 03:52 PM
Did you resolve the date issue after setting the grid datasource in the client?  I'm having the same issue.  Thanks!
0
Boris
Top achievements
Rank 1
answered on 28 Sep 2012, 04:14 PM
Brannon,

Yes, I resolved it with a hack :(
I ended up creating a new DTO on the server, and a brand new JSON response based on it,
where I have already formatted the dates and treated them as strings...

It did the job perfectly, but I don't like it...

~ Boris
0
Brannon
Top achievements
Rank 1
answered on 28 Sep 2012, 04:16 PM
Thanks,  I did the exact same thing.  I don't like it either, but it works for now.
0
Boris
Top achievements
Rank 1
answered on 28 Sep 2012, 04:17 PM
Well...Cheers! :)
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Brannon
Top achievements
Rank 1
Boris
Top achievements
Rank 1
Share this question
or