Author Topic: Autofit after refresh data and view  (Read 8179 times)

motoguru

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Autofit after refresh data and view
« on: February 17, 2014, 10:44:49 pm »
Next problem :)

I'm using simple script which is hidding columns "live" and then fires "refreshDataAndView" on grid. Ocassionally, when all columns are hidden and then I'm bringing them back (by using colModel[column].hidden = false;  or true) autoFit on column widths couting width wrong. Screen attached - upper grid is before show and hide actions, lower one is after few hide/show column operations. Widths are different, no other colModel settings are modified. In scrollModel autoFit is enabled. My colModel is the one from another thread (this one about filtering and searching).

Sorry for the grid visibility - graphic designer is about to start restyling it. You can see horizontal black lines slightly different than dark gray cell background and they are column separators (cell borders).

Upd: there is a letter mistake on the screenshot, should be: refreshDataAndView instead refreshDateAndView.
« Last Edit: February 18, 2014, 03:26:25 pm by motoguru »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Autofit after refresh data and view
« Reply #1 on: February 26, 2014, 07:49:41 pm »
With autoFit : true the column widths won't remain the same after you hide all columns and show them again as widths are re-computed according to the available width in the viewport everytime columns are hidden/shown.
« Last Edit: February 26, 2014, 07:53:37 pm by paramquery »

motoguru

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Autofit after refresh data and view
« Reply #2 on: February 27, 2014, 08:03:20 pm »
Why widths are not computed to proportionally (each equal) fit all the grid width all the time..? I mean why they start proportionally and then, when hidden/shown again they're not proportionally equal, then refresh (f5) and they are equal again? It's a bit strange behaviour. Nothing changed in 2.0.4.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Autofit after refresh data and view
« Reply #3 on: February 27, 2014, 08:34:45 pm »
The purpose of autoFit is to prevent scrolling and fill up the entire width of the viewport by distributing extra / deficient width space equally among columns.

Its purpose is not to maintain equal widths.

motoguru

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Autofit after refresh data and view
« Reply #4 on: February 27, 2014, 08:43:43 pm »
So how to get result I want? For example:

I got 8 columns at start. My grid is 800px width, so I want them to be 100px each (and its done by autofit initially). Then, I want to hide 4 of them, so now I have 4 columns. Obviously, when I would start with 4, autofit would make them 200px each. It does "live", but when I bring 4 columns back (to get 8 like before) and do it "live", widths are computed according to screen attached (like randomly?, for example col1: 120px, col2: 200px, col3:200px and so on to fill 800px...). How to bring them back and split 800px ALWAYS equally between columns after show/hide operations (like an old html table width="*" behaviour). Don't know how to explain it in more detailed way to be honest...

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Autofit after refresh data and view
« Reply #5 on: February 27, 2014, 09:48:11 pm »
I'm afraid to say there is no inbuilt option for that currently.

You have to recompute the widths and assign to column.width while showing the columns.

motoguru

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Autofit after refresh data and view
« Reply #6 on: February 28, 2014, 04:20:14 pm »
Okay, thought about it before, but I was in hope there is built in function for it :)

Thanks anyway.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5637
    • View Profile
Re: Autofit after refresh data and view
« Reply #7 on: May 28, 2014, 09:11:46 am »
motoguru

you might be able to do it using % widths for columns which is supported in latest version 2.1.0