Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable Column's header text does not align in v.3.3.0 #1016

Closed
ubau opened this issue Feb 24, 2021 · 18 comments
Closed

DataTable Column's header text does not align in v.3.3.0 #1016

ubau opened this issue Feb 24, 2021 · 18 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ubau
Copy link

ubau commented Feb 24, 2021

DataTable Column's header text does not align in v.3.3.0
'center' and 'right' ignored, text always stays on the left side.

image

code examples

  <Column
    field="amount"
    header="Amount"
    :style="{ width: '123px', textAlign: 'right' }"
    :sortable="true"
  >
  <Column
    field="amount"
    header="Amount"
    headerStyle="width: 123px; text-align: right"
    bodyStyle="width: 123px; text-align: right"
    footerStyle="width: 123px; text-align: right"
    :sortable="true"
  >

This is regression from v.3.2.4 and before.

@cagataycivici cagataycivici self-assigned this Feb 25, 2021
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Feb 25, 2021
@cagataycivici cagataycivici added this to the 3.3.1 milestone Feb 25, 2021
@shweinfeld
Copy link

I seem to be facing the same issue using v^.3.9.1
image

currently my code reads:
<Column field="qty" header="Quantity" style="text-align:right"></Column>

but I've also tried using headerStyle with no success.

@bjorntj
Copy link

bjorntj commented Jan 28, 2022

Seems to be the same problem using 3.11.0 also...

@rolfs42
Copy link

rolfs42 commented Feb 23, 2022

Much has changed I think and DataTable employs flexbox. Thus, at least in my setup, I can format the column via :style="{'justify-content':'flex-end'}" which works for both, the body and the header cells.

@xbhrnnd
Copy link

xbhrnnd commented Feb 24, 2022

I tried with <Column (...) alignHeader={'center'} /> an it worked for me.

@sbscan
Copy link

sbscan commented Mar 12, 2022

@cagataycivici it's not fixed. I believe flex inheritance makes the trouble.
Changing DataTable style from flex to inline-flex solves the problem. Perhaps you should change other occurrences.
DataTable.vue -> Style -> .p-column-header-content {display: inline-flex}

@zortext
Copy link

zortext commented Apr 23, 2022

@sbscan I don't think changing global styles is a good idea. It may lead to unexpected results when more complex headers with filters are used. Instead I add align-xxx classes for columns with the following css.

.align-right{
  text-align:right;
}
.align-center{
  text-align:center;
}
.p-datatable th[class*="align-"] .p-column-header-content {
  display: inline-flex ;
}

I think this is much more convenient.

@thebleucheese
Copy link

We had to use the above CSS hack and justify-content: center rather than being able to apply a headerClass.

That got the content to center but feels a bit hacky.

@fhprietor
Copy link

I using 3.15.0. Don't align

@wanglin86769
Copy link

I have the same problem with 3.15.0, is there any workaround to align center for table column header?

@ManuelTS
Copy link

I have the same problem with 3.15.0, is there any workaround to align center for table column header?

Same here

@lao-tseu-is-alive
Copy link

same for me

@rubjo
Copy link
Contributor

rubjo commented Aug 25, 2022

SCR-20220825-cw1

@may820806
Copy link

SCR-20220825-cw1

life saver

@Slimelvone
Copy link

image

Add headerClass="column-text-right"

<Column
  field="totalValue"
  header="XXX"
  sortable
  :showFilterOperator="false"
  :showFilterMatchModes="false"
  :showAddButton="false"
  filterMatchMode="contains"
  headerClass="column-text-right"
>
  <template #body="{ data }">
    <div class="text-right">{{ $helper.toCurrency(data.totalValue) }}</div>
  </template>
</Column>

<style lang="scss">
  .column-text-right {
    .p-column-header-content{
      text-align: right; // or center
      display: block !important;
    }
  }
</style>

@mr-feek
Copy link

mr-feek commented Oct 13, 2023

:pt="{ headerContent: 'justify-content-end' }" on the column component worked well for right aligning the header for me

@duzijie
Copy link

duzijie commented Nov 7, 2023

I have the same problem with 3.15.0, is there any workaround to align center for table column header?

    <Column field="code">
        <template #header>
            <span class="flex-1 text-center">Code</span>
        </template>
    </Column>

@Robertofs1
Copy link

I have the same problem with 3.15.0, is there any workaround to align center for table column header?

    <Column field="code">
        <template #header>
            <span class="flex-1 text-center">Code</span>
        </template>
    </Column>

worked for me!! thanks

@smlombardi
Copy link

This will not work for a sortable table, as it "pushes" the sort icon away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests