5

Is it possible to make the first column of a SlickGrid fixed? So that it is always visible during horizontal scrolling, like the header-row?

Thanks for help!

user1027167
  • 4,320
  • 6
  • 33
  • 40
  • so I found nothing in the source (version SlickGrid v2.0 alpha). Maybe the answer ist just "no". – user1027167 Nov 17 '11 at 07:52
  • 1
    Thee's an answer to the same question form the SlickGrid author here: http://groups.google.com/group/slickgrid/browse_thread/thread/ba6a85279f3cfd5f – njr101 Nov 18 '11 at 10:45

3 Answers3

12

There was another forum link (can't find it now) that lead my to JLynch's fork. He maintains both a 1.4.3 tag with his patches for frozen columns and rows, as well as maintaining a 2.0 head. Here is the 2.0 example with both frozen rows and columns.

In that example, the author uses a couple additional options properties:

        ,topPanelHeight: 25
        ,frozenColumn: 2
        ,frozenRow: 5

Hopefully this does what you want without having to hack too much on the core!

bollwyvl
  • 1,231
  • 11
  • 6
  • his slickgrid.js different with normal, hard to do some update with new slickgrid version. We should find another way. – Stiger Aug 30 '13 at 01:39
5

I think you can make in the event .onViewportChanged() the next steps:

  1. Get the columns with .getColumns() and stored in an array variable arrColumns.
  2. Then detect the first column.
  3. Store the data with .getData() in an array variable arrData
  4. Sort arrColumns putting the first column at the beginning.
  5. Set the columns in the new arrColumns with .setColumns()
  6. Reassembly arrData with the order of the new arrColumns.
  7. Call .resizeCanvas()
  8. Cross your fingers. :D

Sorry but I don't find a method or an option in that you can make this behavior in the way that you want.

Well, see what you think of this. It is far from perfect, but it is an idea. I would make something better if the method scrollTo() would be public.

Galled
  • 4,146
  • 2
  • 28
  • 41
  • Why not try and make some tests? – Galled Nov 17 '11 at 13:39
  • not very performant because you have to handle all the data of the grid. next problem: horizontal scrolling is done pixel by pixel and not column by column. – user1027167 Nov 18 '11 at 10:59
  • 1
    That's a pretty awesome example. All you'd have to do to make it perfect is offset that fixed column by the same number of pixels the other columns are. – Nick Retallack Mar 27 '12 at 02:02
0

I know this doesn't fully match your needs, but you can completely avoid horizontal scrolling by setting forceFitColumns to true in the options object.

I reckon that this behavior would be undesirable for users with a very small screen.

deprecated
  • 5,142
  • 3
  • 41
  • 62