4

I'm just starting to use SlickGrid but I've had a lot of success creating a remote model that can interact with the paging plugin. The only problem I have seems to be a browser issue, but I'm curious if anyone knows a trick that may resolve the issue.

I'm retrieving the data page by page in my model via AJAX and updating the grid with the grid.setData() and grid.render() methods.

The problem I would like to solve is that when the length of data changes the vertical scroll bar gets really confused, unless I change the current visibility of the filter panel (grid.hideTopPanel() or grid.showTopPanel()). By confused I mean that the scroll handle in the scroll bar doesn't change size to indicate the different number of rows that are now current, and if the list grows, the scroll handle size jumps all over the place as I scroll up and down.

I'm assuming the "fix" works because it forces the browser to recalculate the view port height, but is there any way to force that to happen? Or is there a better way to do what I'm trying to do?

Josh Russo
  • 3,080
  • 2
  • 41
  • 62

3 Answers3

3

Ok mleibman straightened me out, what I actually was looking for was grid.updateRowCount(). I believe he will be adding a call to this in grid.setData(), but for now just make sure the 2 method calls are used together.

Josh Russo
  • 3,080
  • 2
  • 41
  • 62
0

Have you tried grid.invalidate() ? Im my experience that forces the grid to recalculate pretty much everything. It may be more heavy-handed than you need but at least you can see if a complete invalidate solves the problem.

njr101
  • 9,499
  • 7
  • 39
  • 56
  • If you look at the grid.setData() method it does call invalidate but thanks for the suggestion – Josh Russo Mar 28 '12 at 17:33
  • I didn't realise you were calling `setData()` multiple times. You're right, if you keep resetting the data reference then you'll get an `invalidate()` each time anyway. Glad you found a fix. – njr101 Mar 29 '12 at 11:59
0

I figured it out. You need to call grid.resizeCanvas() after calling grid.setData(). It seems like this should be part of the grid.setData() method because a call to it will change the number of rows. But anyway, that's what you need to do.

Josh Russo
  • 3,080
  • 2
  • 41
  • 62