Search code examples
jqueryformattinggridcell

jqwidget grid cell formatting of json data


I'm trying jqwidget grid with json data inside a mvc project. Grid cell formatting for a date field is problem. The code below gets a cell like "/Date(1340204039263)/". How can I solve this?

$(document).ready(function () {
// prepare the data
var source = {
    datatype: "json",
    datafields: [{ name: 'PersonelId' }, { name: 'Ad' }, { name: 'DogumYili' }, { name: 'UyelikTarihi'}],
    url: 'BindBasicGrid'
};

//var dataAdapter = new $.jqx.dataAdapter(source);
var dataAdapter = new $.jqx.dataAdapter(source, {
    downloadComplete: function (data, status, xhr) { alert(JSON.stringify(data)); },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { alert(JSON.stringify(xhr)); }
});

$("#jqxgrid").jqxGrid({
    source: dataAdapter,
    theme: 'classic',
    columns: [{ text: 'Ad', datafield: 'Ad', width: 250 },
                { text: 'Doğum Yılı', datafield: 'DogumYili', width: 150 },
                { text: 'Üyelik Tarihi', datafield: 'UyelikTarihi', cellsformat: 'D', width: 180}]
});

});


Solution

  • Have you tried using this { name: 'UyelikTarihi', type: 'date'} instead of { name: 'UyelikTarihi'} in your initialization?