SlickGrid
SlickGrid copied to clipboard
explicitInitialization = true does not work with hidden parents
When explicitInitialization=true
and the grid is inside a invisible parent, then it leaks var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' };
into the dom. This in turn breaks other functionality. In our case we are placing the grid inside a bootstrap modal, but the leaked style settings breaks bootstrap's functionality.
Slickgrid requires a visible parent to initialise, so before initialising, it makes an invisible parent object visible with an absolute position off the screen by applying these CSS settings. it caches the settings and replaces them with the original settings after initialisation is complete.
Regardless of your modal settings, it will still be necessary for this process to occur in order to initialise the grid. However we could possibly make a change to allow you to use different settings than the cssShow
settings above, which are currently baked in.
If the original settings are not being restored correctly, then that is a bug, and I can fix if you can diagnose and provide a one-page test case.
The original settings do not get a chance to be restored because the init
method checks for the explicitInitialization
flag.
if (!options.explicitInitialization) {
finishInitialization();
}
The finishInitialization
does not fire which means that slickgrid leaves part of dom outside its container in a altered state.
Later I indeed call grid.init()
which invokes finishInitialization()
but by that time its too late as the altered dom has interfered with other components's functionality.
I'll post an example later today.
Actually, that description is fine, don't worry about an example. Strange that we haven't run across this issue before.
The easiest solution I can think of is to provide an option flag to suppress the css caching entirely and expose it as methods for you to call at appropriate points (or of course, optionally use your own alternative method). Would this work for you?
Yes that will work for us, thanks.
OK, have added options.suppressCssChangesOnHiddenInit
, and exposed cacheCssForHiddenInit
and restoreCssFromHiddenInit
as public methods. Note that there is code both in stage 1 init and stage 2 init (finishInitialization()
) that requires the parent to be visible. So you are going to need to take care of that in an outer code block. I have a sneaking suspicion that these changes may in the end be shown to be not necessary, But please, prove me wrong!
Note that these have been committed to the codebase, but I haven't done a public release at this point until this is tested and you're happy with it.
it looks like a code change was implemented in SlickGrid but no feedback was provided, I think it's safe to close. Please provide more details if the problem occurs