-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resize): add column resize by cell content (#309)
* feat(resize): add column resize by cell content - a quick description of the problem, by default the auto-resize will call the `grid.autosizeColumns()` which will try to find all columns in the grid viewport and that works ok with a small grid but as soon as we have many columns, it starts to wrap many words (with ellipsis) and some user might prefer to resize the column by the cell content (to match the content width with the cell width) and that might mean going wider than the grid viewport. - so this will be an opt-in feature since it will loop through the entire dataset (by default it will read no more than the first 1000 rows) and find/calculate the width it needs to show the entire text value without word being wrapped, in some cases when having many columns it might make the grid wider than the viewport (in that case the horizontal scroll will appear)
- Loading branch information
1 parent
72e38ed
commit 515a072
Showing
37 changed files
with
1,682 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
examples/webpack-demo-vanilla-bundle/src/examples/example14.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<h3 class="title is-3"> | ||
Example 14 - Columns Resize by Content | ||
<span class="subtitle is-size-5 has-text-grey-dark">(with Salesforce Theme)</span> | ||
<div class="subtitle" style="float: right; margin-top: -20px"> | ||
<a class="is-size-5" | ||
target="_blank" | ||
href="https://github.com/ghiscoding/slickgrid-universal/blob/master/examples/webpack-demo-vanilla-bundle/src/examples/example14.ts"> | ||
<span class="mdi mdi-link mdi-v-align-sub"></span> code | ||
</a> | ||
</div> | ||
</h3> | ||
|
||
<div class="columns"> | ||
<div class="column is-three-quarters"> | ||
<p> | ||
The grid below uses the optional resize by cell content (with a fixed 1000px for demo purposes), you can click on | ||
the 2 buttons to see the difference. | ||
The "autosizeColumns" is really the default option used by SlickGrid-Universal, the resize by cell content is | ||
optional because it requires to read the first thousand rows and do extra width calculation. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<hr /> | ||
|
||
<div class="columns"> | ||
<div class="column field is-narrow"> | ||
<h4 class="title is-4">Container Width (1000px)</h4> | ||
</div> | ||
<div class="column field has-addons is-narrow"> | ||
<p class="control"> | ||
<button class="button is-small" onclick.delegate="handleDefaultResizeColumns()" data-text="autosize-columns-btn"> | ||
<span class="icon mdi mdi-arrow-expand"></span> | ||
<span>(default resize) "autosizeColumns"</span> | ||
</button> | ||
</p> | ||
<p class="control"> | ||
<button class="button is-small" onclick.delegate="handleNewResizeColumns()" data-text="resize-by-content-btn"> | ||
<span class="icon mdi mdi-arrow-expand"></span> | ||
<span>Resize by Cell Content</span> | ||
</button> | ||
</p> | ||
</div> | ||
|
||
<div class="column field has-addons is-narrow"> | ||
<p class="control"> | ||
<button class="button is-small" onclick.delegate="toggleGridEditReadonly()" data-test="toggle-readonly-btn"> | ||
<span class="icon mdi mdi-table-edit"></span> | ||
<span>Toggle Edit/Readonly Grid</span> | ||
</button> | ||
</p> | ||
<p class="control"> | ||
<button class="button is-small" onclick.delegate="undoLastEdit()" data-test="undo-last-edit-btn"> | ||
<span class="icon mdi mdi-undo"></span> | ||
<span>Undo Last Edit</span> | ||
</button> | ||
</p> | ||
<p class="control"> | ||
<button class="button is-small is-info" onclick.delegate="saveAll()" data-test="save-all-btn" | ||
title="Check your console log for the result"> | ||
<span>Save All</span> | ||
</button> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div style="width: 1000px" class="grid-container"> | ||
<div class="grid1"> | ||
</div> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
examples/webpack-demo-vanilla-bundle/src/examples/example14.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$autocomplete-max-height: 250px !default; | ||
$control-height: 2.4em; | ||
|
||
@import '@slickgrid-universal/common/dist/styles/sass/slickgrid-theme-salesforce.scss'; | ||
@import 'bulma/bulma'; |
Oops, something went wrong.