1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

jqGrid string custom format like date format

Discussion in 'Programming/Internet' started by BAEK SEUNGJIN, Sep 12, 2018.

  1. I'm trying to print json data on web page with jqGrid, but there are some problems.

    Here is my js script code.

    $('#sometables').jqGrid({
    ...
    ...
    ...
    colNames: ['created_date'],
    colModel: [ {name: 'created_date', align: 'center} ],
    ...
    ...
    ...
    });


    created_date is json data(origin java String type).

    So, I can see created_date on web page grid, like this : 20180912093510, it means 2018/09/12 09:35:10.

    The problem is : How can I formatting string type in jqgrid?

    I want to see 2018/09/12 09:35:10, not 20180912093510.

    I tried first :

    {name: 'created_date', align: 'center', formatter: 'date', formatoptions: {newformat: 'Y/m/d H:i:s'}},


    but it's result was : NaN/NaN/NaN NaN:NaN:NaN

    I tried second :

    {name: 'created_date', align: 'center', formatter: 'date', formatoptions: {srcformat: 'string', newformat: 'Y/m/d H:i:s'}},


    but it's result was : 1970/01/01 00:00:00

    Can I convert string data to date-like data? Must make string-formatting function? If I can, please give some examples.

    Login To add answer/comment
     

Share This Page