jQuery UI Widgets Forums Grid Date sorting

This topic contains 4 replies, has 2 voices, and was last updated by  Dimitar 9 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Date sorting Posts
  • Date sorting #58317

    Siva
    Participant

    I have a date column which displays date in multiple formats (“MMMM-dd-yy”,”dd MMMM yyyy”,”dddd, MMMM dd, yyyy”). Currently it is sorting as string .I tried changing the datatype to ‘date’, but it didnt work. How to perform date sorting for this?

    Date sorting #58322

    Dimitar
    Participant

    Hello Siva,

    Please share your source definition and grid initialization code so that we may determine what causes the issue.

    Best Regards,
    Dimitar

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

    Date sorting #58325

    Siva
    Participant

    function getAdapter() {
    var source =
    {
    datatype: “json”,
    datafields:
    [
    { name: ‘Type’, type: ‘string’ },
    { name: ‘Date’, type: ‘string’},
    { name: ‘IsSecure’, type: ‘string’ }

    ],
    url: urlGetAllJobs,
    async: true
    };

    $grid = $(“#jqxgrid_joblist”);

    $grid.jqxGrid({
    width: ‘100%’,
    height: getInnerHeight(),
    columnsheight: columnsheight,
    rowsheight:rowsheight,
    scrollbarsize: 8,
    source: getAdapter(),
    theme: theme,
    columnsresize: true,
    sortable: true,
    columnsreorder: true,
    enablehover: true,
    enabletooltips: true,
    showemptyrow: false,
    showtoolbar: false,
    sorttogglestates: 1,
    groupable: false,

    columns:
    {
    text: ”, datafield: ‘Type’, filtertype: ‘checkedlist’,
    renderer: headerRenderer,
    cellsrenderer: imageRenderer,
    width: ‘5%’,
    resizable: false
    },
    {
    text: ‘date;, datafield: ‘Submission’,
    renderer: columnsHeaderStyle,
    cellsrenderer: rowsCellStyle,
    filtertype: ‘date’,
    width: ‘15%’,
    }
    });

    here date is in string, so,i get unexpected results. I need to sort it in date format.

    Date sorting #58326

    Siva
    Participant

    Any answers please??
    Thanks in advance

    Date sorting #58346

    Dimitar
    Participant

    Hi Siva,

    There are several issues in your code:

    1) the type of the “Date” datafield should be set to “date”, not “string”:

    { name: 'Date', type: 'date'},

    2) In the second column definition there is a typo – ; instead of :

    text: 'date'

    3) The same column also does not refer to an existing datafield in the source. I think you should change “Submission” to “Date” (which is defined).

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.