You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/main/src/components/AnalyticalTable/Recipes.mdx
+64Lines changed: 64 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -159,4 +159,68 @@ Please note that the internal react-table is resetting its hidden state after hi
159
159
/>
160
160
```
161
161
162
+
## How to scale custom cells?
163
+
164
+
Scaling of custom cells is not supported when used with `scaleWidthMode: AnalyticalTableScaleWidthMode.Grow` or `scaleWidthMode: AnalyticalTableScaleWidthMode.Smart`, as we're using the text of the cell for our calculation.
165
+
Since v1.22.0 you can use the column option `scaleWidthModeOptions` to pass a string for the internal width calculation of the header cell (`headerString`) and the body cells (`cellString`).
166
+
167
+
```jsx
168
+
constcolumns= [
169
+
// This column is automatically scaled because the header and body cells consists of text content only.
170
+
{ Header:'Text Content', accessor:'name' },
171
+
{
172
+
accessor:'age',
173
+
// The header isn't included in the calculation of the column width, because it contains a custom component.
174
+
Header: () => (
175
+
<FlexBox direction={FlexBoxDirection.Column}>
176
+
<Text wrapping={false}>Long header text in a vertical layout</Text>
177
+
<Link>Click me!</Link>
178
+
</FlexBox>
179
+
),
180
+
scaleWidthModeOptions: {
181
+
headerString:'Long header text in a vertical layout'
182
+
}
183
+
},
184
+
{
185
+
id:'1',
186
+
// The body cells aren't included in the calculation of the column width, because they contain a custom component.
187
+
Header:'Custom cell',
188
+
Cell: () => (
189
+
<FlexBox direction={FlexBoxDirection.Column}>
190
+
<Text wrapping={false}>Long body cell text in a vertical layout</Text>
191
+
<Link>Click me!</Link>
192
+
</FlexBox>
193
+
),
194
+
scaleWidthModeOptions: {
195
+
cellString:'Long body cell text in a vertical layout'
196
+
}
197
+
},
198
+
{
199
+
id:'2',
200
+
// Neither the header nor the body cells are included in the calculation of the column width,
201
+
// because they contain a custom component.
202
+
Header: () => (
203
+
<FlexBox direction={FlexBoxDirection.Column}>
204
+
<Text wrapping={false}>Long header text in a vertical layout</Text>
205
+
<Link>Click me!</Link>
206
+
</FlexBox>
207
+
),
208
+
Cell: () => (
209
+
<FlexBox direction={FlexBoxDirection.Column}>
210
+
<Text wrapping={false}>Long body cell text in a vertical layout</Text>
211
+
<Link>Click me!</Link>
212
+
</FlexBox>
213
+
),
214
+
scaleWidthModeOptions: {
215
+
headerString:'Long header text in a vertical layout',
216
+
cellString:'Long body cell text in a vertical layout'
* Defines the string used for internal width calculation of custom header cells (e.g. `Header: () => <Link>Click me!</Link>`).
95
+
*
96
+
* You can find out more about it [here](https://sap.github.io/ui5-webcomponents-react/?path=/docs/data-display-analyticaltable-recipes--docs#how-to-scale-custom-cells).
97
+
*
98
+
* __Note:__ This property has no effect when used with `AnalyticalTableScaleWidthMode.Default`.
99
+
*/
100
+
headerString?: string;
101
+
/**
102
+
* Defines the string used for internal width calculation of the longest cell inside the body of the table (e.g. `Cell: () => <Link>Click me!</Link>`).
103
+
*
104
+
* You can find out more about it [here](https://sap.github.io/ui5-webcomponents-react/?path=/docs/data-display-analyticaltable-recipes--docs#how-to-scale-custom-cells).
105
+
*
106
+
* __Note:__ This property has no effect when used with `AnalyticalTableScaleWidthMode.Default`.
* Allows passing a custom string for the internal width calculation of custom cells for `scaleWidthMode` `Grow` and `Smart`.
251
+
*
252
+
* You can find out more about it here [here](https://sap.github.io/ui5-webcomponents-react/?path=/docs/data-display-analyticaltable-recipes--docs#how-to-scale-custom-cells).
253
+
*
254
+
* __Note:__ This property has no effect when used with `AnalyticalTableScaleWidthMode.Default`.
* __Note:__ Custom cells with components instead of text as children are ignored by the `Smart` and `Grow` modes.
476
+
* __Note:__ Custom cells with components instead of text as children are ignored by the `Smart` and `Grow` modes. To support them you can use the `scaleWidthModeOptions` column option.
448
477
* __Note:__ For performance reasons, the `Smart` and `Grow` modes base their calculation for table cell width on a subset of column cells. If the first 20 cells of a column are significantly smaller than the rest of the column cells, the content may still not be fully displayed for all cells.
0 commit comments