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

Column width #134

Closed
FaisalAriyanto opened this issue Jan 21, 2017 · 13 comments
Closed

Column width #134

FaisalAriyanto opened this issue Jan 21, 2017 · 13 comments

Comments

@FaisalAriyanto
Copy link

Is there a way to quickly setup the width for each colom?

@PrazSam
Copy link

PrazSam commented Jan 25, 2017

I'm facing the same issue. @FaisalAriyanto you are asking about a "quick" way. It seems you have a workaround or..?

@FaisalAriyanto
Copy link
Author

@PrazSam My bad way to set width:

ngAfterViewInit() {
document.getElementsByClassName('column_name')['0'].style.width = '100px'
}

@PrazSam
Copy link

PrazSam commented Jan 26, 2017

Since there are no any other way yet, this is the greatest way. @FaisalAriyanto Thanks for saving my day.

@alifatic
Copy link

@FaisalAriyanto i want to ask, do u know how to add overflow-x , inside tbody, i've added in css but not working

@PrazSam
Copy link

PrazSam commented Jan 27, 2017

@alifatic Why overflow-x just for tbody ? I don't know what you really looking for. If you are trying to make the table horizontally scrollable, just use table inside a div and make it scrolable.

<div class="smart-table-container">
    <ng2-smart-table ..... > </ng2-smart-table >
</div>
.smart-table-container{
    overflow-x: scroll;
}

you may use min width for the table.

.ng2-smart-table  {
    min-width: 1500px;
}

@ManpreetSingh80
Copy link

ManpreetSingh80 commented Mar 8, 2017

You can also use css class in column or just insert data in html type and define width there.

@sushanzh
Copy link

@FaisalAriyanto I was trying your workaround below where Region is my column name. I placed the function in the component.ts file. It didn't seem to take any effect. Did I miss anything? I'm looking for a way to set the width of each column, or alternatively configure it so that the column width accommodates the text value inside the cells full but don't wrap to the next row (go horizontally across, not wrap to the next row. Thank you for your help!

ngAfterViewInit() {
document.getElementsByClassName('Region')['0'].style.width = '100px'
}

@sushanzh
Copy link

@ManpreetSingh80 I tried adding class: 'wide' to the column setting, it doesn't take effect either. I think I'm missing something...

settings = {
columns: {
region: {
title: 'Region',
filter: false,
class: 'wide'
},
...
}

@ManpreetSingh80
Copy link

ManpreetSingh80 commented Mar 18, 2017

@sushanzh You can try html type

title: 'Region', type: 'html', filter: false, valuePrepareFunction: (value) => { return '<div class="wide">' + value + '</div>'; }

@FaisalAriyanto
Copy link
Author

@sushanzh Maybe ngAfterViewInit cannot find your table, i run script there because i expect that table show in DOM and can find column name and change width manual by javascript.

@sushanzh
Copy link

@FaisalAriyanto and @ManpreetSingh80 thank you for your replies. I have tried again, and the html type method works for me! Thank you!!!

@gregoiremotot
Copy link

gregoiremotot commented Aug 30, 2019

:host {
  ::ng-deep .yourColumnName .ng2-smart-title {
    width: 100px;
  }
}

thanks to @ishansinghania
#103 (comment)

@Ajinkyadon
Copy link

@alifatic Why overflow-x just for tbody ? I don't know what you really looking for. If you are trying to make the table horizontally scrollable, just use table inside a div and make it scrolable.

<div class="smart-table-container">
    <ng2-smart-table ..... > </ng2-smart-table >
</div>
.smart-table-container{
    overflow-x: scroll;
}

you may use min width for the table.

.ng2-smart-table  {
    min-width: 1500px;
}

Thanks, man you help me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants