Author Topic: Is there a way format a date column inside the colModel?  (Read 64 times)

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 40
    • View Profile
Is there a way format a date column inside the colModel?
« 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%', }
    ];

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6323
    • View Profile
Re: Is there a way format a date column inside the colModel?
« Reply #1 on: December 15, 2024, 06:56:03 am »

pbassey

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Is there a way format a date column inside the colModel?
« Reply #2 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?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6323
    • View Profile
Re: Is there a way format a date column inside the colModel?
« Reply #3 on: December 16, 2024, 12:12:04 am »
it's simply format: 'mm/dd/yyyy'