[jQuery]UI.layout*SlickGrid - 使SlickGrid在layout改變大小時能自動filter高度

- - posted in jquery | Comments

目前只有一種作法,利用publish/subscribe告訴SlickGrid要去追parent的高度

1
2
3
4
5
6
7
8
9
10
11
12
13
$.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();
}
1
2
3
4
5
6
7
8
9
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]);

Comments