Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / Right align content in hierarchical grid when datatype is string

Right align content in hierarchical grid when datatype is string

New Discussion
8FA7536E308AC2CEB237474D5D3272280F526B02
8FA7536E308AC2CEB237474D5D3272280F526B02 asked on Apr 1, 2020 7:06 AM

Hi,

I am using hierarchical grid and have a couple of numeric and a few string column in my object. When I am binding the numeric columns with data type as the number, it is also changing the alignment of the column header. I want the header as is and position of all the option like sort and filter icon should be consistent across the grid but just cell with numeric value get right align.

I tried ng-template and align the cell value but it’s not working.

Can you please help here.

Thanks,
Dev

Sign In to post a reply

Replies

  • 0
    Vasil Pavlov
    Vasil Pavlov answered on Jun 4, 2019 3:54 PM

    Hello Dev,

     

    Thank you for posting in our forum.

     

    Just to be sure I understand your question: you want to change the text alignment of the columns with a dataType of string to be to the right, for the content only, but leave the headers as they are (aligned to the left), is that correct?

    A certain class: 'igx-grid__td–number' gets added to the ‘number’ cells, and tells them to align to the right with those CSS rules:

        text-align: right;

        justify-content: flex-end

     

    You could do either of those two things:

    1. The igxGrid allows the user to set custom cell styling – when a given condition is “true” the given custom class would be added to the cell. More details you may find in this help topic.

     

    1. The Columns configuration section of the igxGrid overview topic shows how to use the cell template (that is the template that would be applied to all cells in a given column) and add some custom styling.

     

    If you use some combination of the both approaches, you may add the igx-grid__td—number style, along with “width: 100%” to the cell template and this would align the content cells’ text to the right. The template for such a column in the grid configuration would look like this:

     

    
            
                    {{ cell.value }}
                
    
    

     

    Please let me know if you need some further assistance or if I have misunderstood your question.

    • 0
      8FA7536E308AC2CEB237474D5D3272280F526B02
      8FA7536E308AC2CEB237474D5D3272280F526B02 answered on Jun 5, 2019 4:26 PM

      this is exactly what I am looking for. this worked for me.

      Thanks…

      • 0
        Vasil Pavlov
        Vasil Pavlov answered on Jun 6, 2019 7:53 AM

        Hello Dev,

         

        I am glad that you find my answer helpful.

         

        Feel free to contact me if you have any additional questions regarding this matter.

    • 0
      Mason Zeimet
      Mason Zeimet answered on Jul 15, 2019 6:05 PM

      How would you apply the right-align to the headers as well?

      • 0
        Mason Zeimet
        Mason Zeimet answered on Jul 15, 2019 8:02 PM

        I’m sorry, I meant to ask how you would apply a right-align to the headers without using the dataType property of the column?

        If I were to apply a center-align rather than a right-align, I would use this class for the cellClasses input of the cell:

        center-align {
            text-align: center;
            justify-content: center;
        }

        But how would I achieve the center alignment for the header as well?

        I also upvoted myself on accident since it’s my first post here and was seeing what the buttons did

      • 0
        Vasil Pavlov
        Vasil Pavlov answered on Jul 16, 2019 3:17 PM

        Hello Mason,

         

        The Columns Configuration section in my first response shows snippet for this as well, the ng-template looks very similar, but is decorated with an igxHeader directive instead. If you have already added this ‘.center-align’ class to your component CSS file, this is what the column declaration would look like:

         

        
            
                
        {{ column.field }}

         

        Please note that if you want to style both the column cells and the headers, you would need to use the two snippets I have shown together, like this:

        
            
                
        {{ column.field }}
        {{ cell.value }}

         

        Feel free to contact me if you need any additional assistance.

      • 0
        Shobhana Suara
        Shobhana Suara answered on Mar 30, 2020 11:05 AM

        i am unable to apply styles to header to right align as well content

      • 0
        Shobhana Suara
        Shobhana Suara answered on Apr 1, 2020 7:06 AM

        I am unable to align the header and content of the grid using above answer. Could you please help me out. I want to align the header and content to left and filter icon to right as it is for datatype 'String'

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Favorites
0
Replies
8
Created On
Apr 01, 2020
Last Post
5 years, 11 months ago

Suggested Discussions

Created on

Apr 1, 2020 7:06 AM

Last activity on

Feb 25, 2026 9:29 AM