jQWidgets Forums

jQuery UI Widgets Forums Angular How to dynamically set grid column width

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 5 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • ilywanzi
    Participant

    Hi, I met a problem to set grid column width. I set “100%” for the grid width, but for the column width, I found two scenarios.

    First, if there are not many columns, I only set the first column to “10%”, not set the rest, then all the columns will fit the whole width. But if the number of columns change later, become 20 columns, then all the columns will become very narrow, and the horizontal scroll bar is not showing.

    Second, if I use number the set the column width, such as 100, or 150, if not many columns, then those columns can not fit the whole width. But the good thing is that if we have many columns, then the scroll bar will show up.
    Is there a way to handle this problem? Thanks.


    ilywanzi
    Participant

    Hi, I have done this by this way:

    
    if(colNum > 9) {
      columns.push({...baseCol, editable: true, columntype: 'numberinput', width: 150 })
    }
    else {
      columns.push({ ...baseCol, editable: true, columntype: 'numberinput' });
    }

    Not sure if it is a good way to solve the problem.


    Hristo
    Participant

    Hello ilywanzi,

    Yes, this is a good solution.
    If you know the exact moment when the number of columns is changed then you could change their width” member.
    For this purpose, the setcolumnproperty method will be useful.
    More details you could find in the API Documentation page.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.