Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
IgbDataGrid - IgbDateTimeColumn - How to custom format

I would like to display my dates in my own custom format (like using a C# format string).


I have tried using

- DataBoundScript (script gets called, but cannot figure out how to change output)

- FormatOverrideScript (never seems to get called)

Any ideas?

No Data
  • 28785
    Offline posted

    Hello Terry, 

    There must a bug or limitation on setting FormatString to custom format. As of now there only 1 way to format with the columns directly which is a set of International DateTime formats. However if you want to customize the format to your liking I recommend using the IgbGrid. The IgbDataGrid is deprecated and I don't think we will put alot of effort in getting custom formats there. 

    In JS setup a file in wwwroot with the following:

    function OnFormatter(column, args) {
    return formatDate(args.OrderDate);
    igRegisterScript("OnFormatter", OnFormatter, false);
    function formatDate(date) {
    const monthNames = ["Jan", "Feb", "Mar", "Apr",
    "May", "Jun", "Jul", "Aug",
    "Sep", "Oct", "Nov", "Dec"];
    var d = new Date(date),
    //month = '' + (d.getMonth() + 1),
    month = '' + monthNames[(d.getMonth())],
    day = '' + d.getDate(),
    year = d.getFullYear();
    //if (month.length < 2)
    // month = '0' + month;
    if (day.length < 2)
    day = '0' + day;
    return [year, month, day].join('-');

    For more details please see the sample attached.

No Data