ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: pbassey on December 15, 2024, 01:56:42 am

Title: Is there a way format a date column inside the colModel?
Post by: pbassey on December 15, 2024, 01:56:42 am
I have the following colModel definition and I would like the syntax to format the createDate column as mm/dd/yyyy:
    var colModel = [
        { title: "Title", dataType: "string", dataIndx: "title", editable: false, minWidth: '30%', },
        { title: "Content Owner", dataType: "String", dataIndx: "ownerId", editable: false, minWidth: '10%', },
        { title: "Node", dataType: "string", dataIndx: "contentLayout", editable: false, minWidth: '10%', },
        { title: "Type", dataType: "string", dataIndx: "contentType", editable: false, minWidth: '10%', },
        { title: "Status", dataType: "String", dataIndx: "status", editable: false, minWidth: '10%', },
        { title: "Date", dataType: "String", dataIndx: "createdDate", editable: false, minWidth: '20%', }
    ];
Title: Re: Is there a way format a date column inside the colModel?
Post by: paramvir on December 15, 2024, 06:56:03 am
Please use column.format property

https://paramquery.com/pro/api#option-column-format
Title: Re: Is there a way format a date column inside the colModel?
Post by: pbassey on December 15, 2024, 10:18:39 pm
Below is the format command I used, but it seemed to have no effect to the screen output:

        {
            title: "Date", dataType: "String", dataIndx: "createdDate", editable: false, minWidth: '20%',
            format: function (val) {
                return [ 'mm/dd/yyyy'][val];
            }
        }

Can you tell me what I did wrong?
Title: Re: Is there a way format a date column inside the colModel?
Post by: paramvir on December 16, 2024, 12:12:04 am
it's simply format: 'mm/dd/yyyy'