jQWidgets Forums

jQuery UI Widgets Forums Grid problem with cellsformat in jqxGrid('addrow'…) function

This topic contains 1 reply, has 2 voices, and was last updated by  svetoslav_borislavov 1 year, 10 months ago.

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

  • fabriceb
    Participant

    Hi,

    I use dates in columns of my grids.
    The format of dates in the source used to generate grid comes from sql, to the dates are in format : jj-mm-yyyy

    here is a simple configuration :
    var data = [{firstname: “bob”, date: ‘2022-09-06’}, {firstname: “kim”, date: ‘2022-09-05’}];
    var source = {
    localdata: data,
    datafields: [{
    name: ‘firstname’,
    type: ‘string’
    }, {
    name: ‘date’,
    type: ‘date’
    }],
    datatype: “array”
    };

    var adapter = new $.jqx.dataAdapter(source);
    $(“#jqxgrid”).jqxGrid({
    width: 500,
    height: 200,
    theme: ‘energyblue’,
    source: adapter,
    sortable: true,
    columns: [{
    text: ‘First Name’,
    datafield: ‘firstname’,
    columngroup: ‘Name’,
    width: 90
    }, {
    text: ‘Order Date’,
    datafield: ‘date’,
    width: 160,
    cellsformat: ‘dd/MM/yyyy’
    }],
    });

    it works great to generate the grid, the format is converted te “jj/MM/yyyy”.

    but when I want to add a new row using jqxGrid(‘addrow’…), the date appears in format “jj-mm-yyyy” in the new row.
    $(“#addrowbutton”).on(‘click’, function () {
    var datarow = [{firstname: “new name”, date: ‘2022-09-01’}];

    var commit = $(“#jqxgrid”).jqxGrid(‘addrow’, null, datarow)
    });

    it seams to work only when I convert date to object… but why does it work with “jj-mm-yyyy” when I generate grid first time ?

    here is the fiddle :
    http://jsfiddle.net/mogador/uwL7rfgx/

    fabriceb

    Hi,

    If you want to avoid creating Date object, add the row this way:
    var commit = $(“#jqxgrid”).jqxGrid(‘addrow’, null, datarow)

    Best regards,
    Svetoslav Borislavov

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

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

You must be logged in to reply to this topic.