Ngx-datatable set column width dynamically

I’m storing the column widths of my ngx-datatable inside a database. I get these values using an AJAX call.

How can I set these values for the datatable?

What I’ve tried:

  1. setting the [width] property on the <ngx-datatable-column> element
  2. injecting the datatable as @ViewChild(DatatableComponent) table: DatatableComponent; and setting this.table.bodyComponent.columns[0].width = 500;

    I’ve tried these methods with and without this.table.recalculate();, but nothing seems to work.

EDIT

I’m using datatable-column with header-template and cell-template.

95 thoughts on “Ngx-datatable set column width dynamically”

  1. Usually I don’t learn post on blogs, but I would like to say that this
    write-up very compelled me to take a look at and do so!
    Your writing style has been surprised me. Thanks, quite nice article.

    Reply
  2. Howdy! I know this is kinda off topic however , I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest writing a blog post or
    vice-versa? My website covers a lot of the same subjects as yours and I feel
    we could greatly benefit from each other. If you happen to be interested feel free to shoot me an email.
    I look forward to hearing from you! Terrific blog by the way!

    Reply
  3. My spouse and I stumbled over here coming from a different web address and thought I might as well
    check things out. I like what I see so now i am following you.
    Look forward to looking at your web page for a second time.

    Reply
  4. Hello, i read your blog occasionally and i own a similar one and i was just curious if you get a lot
    of spam responses? If so how do you reduce it, any plugin or anything you can recommend?
    I get so much lately it’s driving me insane so any assistance is very much appreciated.

    Reply
  5. Hey there! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no data backup.

    Do you have any solutions to prevent hackers?

    Reply
  6. It’s actually a great and helpful piece of info. I’m happy that you simply shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.

    Reply
  7. Can I just say what a comfort to uncover a person that really understands what they’re discussing on the net.
    You certainly know how to bring an issue to light and make it important.
    A lot more people should check this out and understand
    this side of the story. I was surprised that you aren’t more popular
    because you definitely have the gift. cheap flights http://1704milesapart.tumblr.com/ cheap flights

    Reply
  8. Superb site you have here but I was wanting to know if you knew
    of any message boards that cover the same topics talked about here?
    I’d really like to be a part of online community where I can get
    feed-back from other knowledgeable individuals that share the
    same interest. If you have any recommendations, please let me
    know. Bless you! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

    Reply
  9. Thanks for one’s marvelous posting! I definitely enjoyed reading it,
    you can be a great author. I will always bookmark your blog and definitely will come back very soon. I want to encourage you to ultimately continue your great posts, have a
    nice day! scoliosis surgery https://0401mm.tumblr.com/ scoliosis
    surgery

    Reply
  10. I’m not sure why but this blog is loading incredibly slow for me. Is anyone else having this problem or is it a problem on my end? I’ll check back later on and see if the problem still exists.

    Reply
  11. Hey! I know this is kinda off topic nevertheless I’d figured I’d ask. Would you be interested in trading links or maybe guest authoring a blog article or vice-versa? My blog addresses a lot of the same subjects as yours and I believe we could greatly benefit from each other. If you might be interested feel free to send me an e-mail. I look forward to hearing from you! Fantastic blog by the way!

    Reply

Leave a Comment