jQuery UI Widgets Forums Grid Grid's datetimeinput keeps returning long datetime format

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 7 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • keyur
    Participant

    I am trying to use datetimeinput column to change date related data in my grid.
    The json data I am supplying in grid is as below

    [{“id”:1,”firstname”:”keyur”,”lastname”:”Padalia”,”gender”:”Female”,”active”:true,”date_of_birth”:”1983-03-22T00:00:00″,”note”:”This is a sample note.”},{“id”:2,”firstname”:”Nick”,”lastname”:”Goddard”,”gender”:”Male”,”active”:true,”date_of_birth”:”1950-01-20T00:00:00″,”note”:”Second user”},{“id”:3,”firstname”:”Malcolm”,”lastname”:”McIlhagga”,”gender”:”Male”,”active”:false,”date_of_birth”:”1973-10-12T00:00:00″,”note”:”Third user”}]

    My Grid setup:
    $(document).ready(function () {

    //User Grid
    var data = <?php echo $grid_data ?>;
    var source =
    {
    localdata: data,
    datafields: [
    {name: ‘id’, type: ‘int’},
    {name: ‘firstname’, type: ‘string’},
    {name: ‘lastname’, type: ‘string’},
    {name: ‘gender’, type: ‘string’},
    {name: ‘active’, type: ‘bool’},
    {name: ‘date_of_birth’, type: ‘date’},
    {name: ‘note’, type: ‘string’}
    ],
    id: ‘id’,
    datatype: “json”
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    var cellStyle = function (row, columnfield, value) {
    return ”;
    }
    $(“#user_grid”).jqxGrid(
    {
    width: 550,
    source: dataAdapter,
    columnsresize: true,
    sortable: true,
    editable: true,
    altrows: true,
    autoheight: true,
    rowsheight: 20,
    selectionmode: ‘singlecell’,
    editmode: ‘selectedcell’,
    columns: [
    {hidden: true, datafield: ‘id’, width: 0},
    {text: ‘First Name’, datafield: ‘firstname’, align: ‘center’, width: 80, cellclassname: cellStyle},
    {text: ‘Last Name’, datafield: ‘lastname’, align: ‘center’, width: 80, cellclassname: cellStyle},
    {text: ‘Gender’, datafield: ‘gender’, align: ‘center’, columntype: ‘dropdownlist’, width: 60, cellclassname: cellStyle},
    {text: ‘Active’, datafield: ‘active’, align: ‘center’, columntype: ‘checkbox’, width: 60, cellclassname: cellStyle},
    {text: ‘DOB’, datafield: ‘date_of_birth’, align: ‘center’, columntype: ‘datetimeinput’, cellsformat: “yyyy-MM-dd”, width: 150, cellclassname: cellStyle},
    {text: ‘Note’, datafield: ‘note’, align: ‘center’, width: 120, cellclassname: cellStyle}

    ]
    });

    And it’s returning “Wed Mar 23 1983 00:00:00 GMT+0000 (GMT)” format.

    Is there anything I can do to make the return date type tobe yyyy-MM-dd?


    Peter Stoev
    Keymaster

    Hi keyur,

    This format is called Javascript Date Object and our Grid works with Javascript Date objects. To get the text of a cell, use the “getcelltext” method Best

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.