Skip to content

formatting a date column

New Discussion
Sanjay
Sanjay asked on Nov 6, 2012 1:08 PM

Hi,

I want to format igGrid column for dates like “yyyy-mm-dd”, dd-mm-yyyy 10:20Pm”, …….

Is there any way to do it ??

Sign In to post a reply

Replies

  • 0
    Flavio
    Flavio answered on Oct 25, 2012 10:48 AM

    Hi Sanjaysutar,

    let’s wait for an infragistis team confirm, but I think this is what you were looking for:

    //Initialize
    
    $(".selector").igGrid({
    
        autoGenerateColumns: false,
    
        columns: [
    
            { headerText: "Product ID", key: "ProductID", dataType: "number", format: "number" },
    
            { headerText: "Production Date", key: "ProductionDate", dataType: "date", format: "ddd, MMM-d-yy HH:mm" },
    
        ]           
    
    });
    You can find it directly on the Infragistics objects help:
    If you look at the options, you will findcolumnsand then different possible attributes, such asdataType(for your sample it will be “date”),headerTextand, of course,format(for your sample a string with format type, such as “dd-MM-yyyy” or everything else).
    Hope will help you,
    Flavio
  • 0
    [Infragistics] Tsvetelina Georgieva
    [Infragistics] Tsvetelina Georgieva answered on Oct 25, 2012 11:46 AM

    Hello sanjaysutar ,

    Flavio is right. You should use format property for the purpose

    More information you can find in the help docs too

    https://www.igniteui.com/help/iggrid-overview

    Let us know if you need further assistance.

     

    • 0
      Sanjay
      Sanjay answered on Nov 2, 2012 7:17 PM

      Hi Tsvetelina,

      It looks like we can give format options while specifying the columns.

      What if I have hundreds of columns in the grid ?? Is there any way to specify only columns to which I want to apply for format ??

      • 0
        [Infragistics] Tsvetelina Georgieva
        [Infragistics] Tsvetelina Georgieva answered on Nov 5, 2012 4:52 PM

        Hello sanjaysutar ,

        Thank you for your update.

        I am not sure how you want to manipulate these columns.

        Are they autoGenerated and you want to format only the date columns or you define all of them but you need to specify format only to specific ones?

        • If you want to have the columns autogenerated you can set format by explicitly defining the columns with the same Key as in the dataSource.

        Thus the defined column will override the autogenerated one and the format will be applied to it.

        You should keep in mind that in this case the defined columns will appear before the autogenerated ones.

        • If you want to set the format to all date columns in the grid you can use the regional property for the purpose

        For more information please refer to the help documentation.

        Hope hearing from you.

      • 0
        Sanjay
        Sanjay answered on Nov 5, 2012 5:24 PM

        Yes the columns are autogenerated and there are over 100 of columns.

        Out of those 100 columns lets say I want to format 2 columns which are of type DATETIME


        As per your comment, I tried defining only a single column explicitly as below:

        @(Html.Infragistics().Grid<Data>(Model.DataCollection).ID("mGrid")

               .AutoGenerateColumns(true)

                .Columns(col =>
                          {
                                     col.For(x => x.CreateDate).HeaderText("CreateDate").DataType("date").Format("MM-dd-yyyy h:mm:ss tt");
                           }
                 )
                .Height("600px")
                .DataBind()
                .Render()
        )

        The above code only renders the explicitly defined column and does not render the remaining ones although AUTOGENERATECOLUMNSis set to TRUE.

      • 0
        [Infragistics] Tsvetelina Georgieva
        [Infragistics] Tsvetelina Georgieva answered on Nov 6, 2012 1:06 PM

        Hello

        You haven't set DefaultColumnWidth.

        Please see the answer of Martin Pavlov to another your post

        http://www.infragistics.com/community/forums/p/75190/380169.aspx#380251

        Hope this helps

      • 0
        Martin Pavlov
        Martin Pavlov answered on Nov 6, 2012 1:08 PM

        Hi,

        You should either define grid width or set the defaultColumnWidth option in order to make it work.

        Best regards,

        Martin Pavlov

        Infragistics, Inc.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Sanjay
Favorites
0
Replies
7
Created On
Nov 06, 2012
Last Post
13 years, 3 months ago

Suggested Discussions

Created by

Created on

Nov 6, 2012 1:08 PM

Last activity on

Feb 24, 2026 2:58 PM