Bhoomesh Joshi
Bhoomesh Joshi

Reputation: 27

Unable to set column width dynamatically in PrimeReact data-table

I have created SPFx with React solution. I have used "primereact": "^9.4.0" version.

I need to set the column width dynamically in the Prime React data-table column.

I have added the same code as below to bind dynamic columns in the Prime React data-table.

columnsArray?.map((col) => {
  return (
    <Column
    key={col?.field}
    field={col?.field}
    header={col?.header} 
    style={{ width: col?.width + 'px', whiteSpace: 'nowrap' }}
    sortable
    filter
    filterClear={filterClearTemplate}
    filterApply={filterApplyTemplate}
    reorderable={true}
    body={getAllFieldData}
   />
  )
 }
})

Everything is working as expected except the width property.

Also, I have tried max-width and min-width properties, and it works as expected.

Can anyone help me with the same?

Thanks

Upvotes: 1

Views: 217

Answers (0)

Related Questions