我結束瞭解決這個問題,使用jQuery PubSub,UI佈局的訪問器方法和SlickGrid的resizeCanvas()
方法的組合。它似乎工作得很好。
注意:我的項目已經在使用pubsub了,我使用RequireJS加載我的模塊。
所以,在我的網格模塊文件,我訂閱接收它生活在窗格中,它保存到一個局部變量的新innerHeight的方法,然後調用我的resize();
功能:
$.subscribe("units/set_grid_height", function (new_height) {
grid_opts.height = new_height;
resize();
});
// ...
// grid = the jQuery element that represents the SlickGrid
// slick = the instantiated slickgrid
function resize() {
grid.css('height', grid_opts.height);
slick.resizeCanvas();
}
然後在我的init JS文件(在佈局定義),我設置了正確的出版爲初始狀態,每次中心窗格中的變化:
layout = $('body').layout({
center: {
onresize: function (name, el, state, opts, layout_name) {
$.publish("units/set_grid_height", [state.innerHeight]);
}
}
});
$.publish("units/set_grid_height", [layout.state.center.innerHeight]);
這似乎做的正是我想要的。我知道這不是一個通用的解決方案,但它看起來並不像SlickGrid可以獨立完成所有這些。
如何使用autoHeight設置?它可能比這個問題更新... – w00t 2011-11-17 15:33:29