-
-
Notifications
You must be signed in to change notification settings - Fork 119
Grid Auto Resize
Almost all grids from the demos are using the auto-resize feature, and the feature does what its name suggest, it resizes the grid to fill entirely within the container it is contained. It also automatically resizes when the user changes its browser size.
All you need to do is enable the Grid Option enableAutoResize: true
and provide necessary information in the autoResize
, at minimum you should provide your container name.
<div id="demo-container">
<angular-slickgrid gridId="grid1"
[columnDefinitions]="columnDefinitions"
[gridOptions]="gridOptions"
[dataset]="dataset">
</angular-slickgrid>
</div>
this.columnDefinitions = [
// ...
];
this.gridOptions = {
autoResize: {
containerId: 'demo-container'
},
enableAutoResize: true
};
There are multiple options you can pass to the autoResize
in the Grid Options, you can see them all in the autoResizeOption.interface
If you always use the same configuration over and over (for example your container is always the same name), then I suggest you to look at the Global Options. This is the recommended way of using the auto-resize.
- Have you put your grid in a
<div>
container referenced in yourautoResize
grid options? - I have the container defined but it still doesn't resize, why?
This feature uses window.resize
event and if you change the size of your DIV programmatically, it will not change the size of your grid, mainly because that action did not trigger a window.resize
event. However to circumvent this issue, you can call the auto-resize of the grid manually with the ResizerService
. For example, we change the DIV CSS classes to use a different Bootstrap container size, that won't trigger an event and we have to manually call the resize, below is the code to do that.
angularGridReady(angularGrid: AngularGridInstance) {
this.angularGrid = angularGrid;
}
closeSidebar() {
this.isSidebarOpen = false;
this.angularGrid.resizerService.resizeGrid();
}
openSidebar() {
this.isSidebarOpen = true;
this.angularGrid.resizerService.resizeGrid();
}
Contents
- Angular-Slickgrid Uncyclo
- Installation
- Styling
- Interfaces/Models
- Testing Patterns
- Column Functionalities
- Global Grid Options
- Localization
- Events
- Grid Functionalities
- Auto-Resize / Resizer Service
- Resize by Cell Content
- Composite Editor
- Context Menu
- Custom Tooltip
- Add/Delete/Update or Highlight item
- Dynamically Change Row CSS Classes
- Excel Copy Buffer
- Export to Excel
- Export to File (CSV/Txt)
- Grid State & Presets
- Grouping & Aggregators
- Row Detail
- SlickGrid Controls
- SlickGrid Plugins
- Pinning (frozen) of Columns/Rows
- Tree Data Grid
- SlickGrid & DataView objects
- Addons (controls/plugins)
- Backend Services