1

I am using swimlane's ngx-datatable. I need to give specific widths to couple of columns in my table, but it is not working. This is how I create my table:

page.component.html:

<ngx-datatable [rows]="rows" [columns]="columns" rowHeight="auto" columnMode="force" [reorderable]="false" [swapColumns]="false"></ngx-datatable>

page.component.ts:

this.columns = [
   { prop: 'col1', resizeable: false, sortable: false, width: 30 }, 
   { prop: 'col2', resizeable: false }, 
   { prop: 'col3', resizeable: false, sortable: false }, 
   { prop: 'col4', resizeable: false, sortable: false },
   { prop: 'col5', resizeable: false, sortable: false, width: 30 }
];
3
  • 1
    Can you try to add these properties too? minWidth: 30, maxWidth: 30 Commented Jul 26, 2021 at 13:43
  • @Akif it worked! Why it worked? :D Commented Jul 26, 2021 at 13:46
  • 1
    Divine providence... Commented Jul 26, 2021 at 13:49

1 Answer 1

4

As mentioned in the documentation, default value of the minWidth property is 100. IMHO, if we try to define a width value smaller than 100, then we need to define the minWidth property too.

minWidth: number

Minimum width of the column in pixels. Default value: 100

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.