0

I need to implement a sought of onRendered() event that would ensure all of the grid is rendered before I do something, which is to .hide() it. My gaol is to have a .hide() and .show() button attached to the div the grid resides in, with the default status set at hidden. The problem is that at the point in which my script executes the initial .hide(), the grid is not fully created yet by the grid.js script. I would rather not do any delay loop. Much rather have a callback.

Any help would be appreciated

Thanks Pat

cube
  • 1,774
  • 4
  • 23
  • 33
  • Possible duplicate of http://stackoverflow.com/questions/6224661/do-action-after-render-method-is-completed?answertab=active#tab-top – magiconair Nov 07 '11 at 11:39

2 Answers2

2

This should work without a callback. I have a SlickGrid app where I show and hide the grid in response to UI events. The grid exists as soon as it is instantiated (with new Slick.Grid) and can be manipulated with the .hide()and .show() methods.

I did find one catch though...

If you create the div tag with display: none (so it is initially hidden) the grid columns do not initialise properly. To workaround this I create the div tag with visibility: hidden and remove this style before using the .hide()and .show() methods.

My code looks roughly like this:

  <div id="mygrid" style="visibility: hidden"></div>

  $grid = $("#mygrid")

  grid = new Slick.Grid($grid, gridData, gridColumns, gridOptions);

  // Hide grid by default, remembering to remove the visibility style
  $grid.hide();
  $grid.css("visibility", "visible");

  // You can now show and hide the grid using normal jQuery methods
  $grid.show();
  $grid.hide();

Hope this helps.

njr101
  • 9,499
  • 7
  • 39
  • 56
0

The slick grid has implemented an event onRendered event github source. We can subscribe to this event and make the appropriate use of it.

Harish
  • 85
  • 14
  • 1
    we did add that over a year ago but it should be noted that we are talking about the [6pac/SlickGrid](https://github.com/6pac/SlickGrid/blob/master/slick.grid.js#L5957) fork (not the original repo) – ghiscoding Aug 24 '21 at 21:54
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – Shayan Shafiq Aug 28 '21 at 15:43