ericmbarnard/KoGrid — pull request #38 by kellypleahy (2012-05-11 04:17:02+00:00)
Title: Attempt at column hiding...

Eric,

I don't expect you to accept this pull request as is. I was hoping you could take a look at it and help me understand what I should be doing in the subscribed action in Grid.js (returned by createColumnWidthClosure()) to handle a width change on a column properly. A pull request was the easiest way I could think of to collaborate on this - if there's a better way feel free to recommend!

Here's what we're trying to do. We need a good way to hide columns (permanently is ok for a given population of the grid) for our UI. This is because we have data that is automatically retrieved but some of the columns are not terribly useful - but only the user will understand which are useful, so we want a quick way for them to hide the "unimportant" columns so that they can look at the data they want to see quickly.

We thought that an easy way to do this would be setting the width to 0 on the columns. Just setting the observable width didn't seem to be enough (see the code in HeaderCell.js), so we then thought we needed a handler to update the CSS styles. I did that, but that still didn't seem to be enough. A few more guesses got me to where we are now, which is definitely not right either.

It seems to work fine after the first time hiding a column, but on the first hide it "loses" the grid rows until you scroll. This is why I have the "rm.dataSource.notifySubscribers(...)" and "rm.renderedRange.notifySubscribers(...)" stuff in there - in the hopes this would trigger 'filter-like' behavior.

However, I can't seem to get the 'filter-like' behavior to happen on the first time you hide a column (after the data has been rendered once).

Any idea why? I'm testing on IE9, btw, if that makes a difference.