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

Could auto width coexist with set width #85

Open
crystianwendel opened this issue Jul 10, 2022 · 0 comments
Open

Could auto width coexist with set width #85

crystianwendel opened this issue Jul 10, 2022 · 0 comments

Comments

@crystianwendel
Copy link

I think it would be nice if auto width could coexist with fixed width.

I use auto width most of the time, but sometimes a single column content can make a mess if it's too large. I would like to set width of some columns, and still have autowidth for the rest of them.

In my project, i did this as a monkey patch, but i could make a PR if you think this could me useful.

def initialize(struct)
  @fixed_witdh_columns = []
  @is_open = true
  @col_formats = {}
  @last_row_number = -1
  super(struct)
end

def set_column_width(col, width)
  @fixed_witdh_columns << col
  set_column(col, col, width, @col_formats[col])
end

def close
  return unless auto_width?

  @column_widths.each do |num, width|
    next if @fixed_witdh_columns.include?(num)

    set_column_width(num, width + 0.2)
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant