Skip to content

Commit 38b6f76

Browse files
authored
Merge pull request #171 from brYch97/users/dominik.brych/GridDocUpdate
Updated docs for Virtual Dataset/Grid
2 parents a6590f3 + f16878d commit 38b6f76

71 files changed

Lines changed: 8643 additions & 1857 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
279 KB
Loading
410 KB
Loading
273 KB
Loading
304 KB
Loading
65.5 KB
Loading

src/en/developer-guide/applications/controls/VirtualDataset/CellCustomizers/general.md

Lines changed: 81 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,86 @@ record.expressions.ui.setHeightExpression('talxis_singlelinetext', () => 50);
156156
```
157157
![Control customizer](/.attachments/applications/Controls/VirtualDataset/custom_control_formatting.gif)
158158

159+
### Custom Ribbon PCF
160+
161+
Since Ribbon column is treated like any other column, you can also assign a custom PCF to it. This allows you to create unique Ribbon buttons that align with your specific requirements. You can either create a fuly custom UI or leverage the `GridInlineRibbon` Base Control to build upon the existing Ribbon UI.
162+
163+
```json
164+
{
165+
"name": "_talxis_gridRibbonButtons",
166+
"dataType": "SingleLine.Text",
167+
"controls": [
168+
{
169+
"appliesTo": "renderer",
170+
"name": "talxis_TALXIS.PCF.CustomRibbonDemo",
171+
"bindings": {
172+
}
173+
}
174+
]
175+
}
176+
```
177+
**Custom Ribbon Column Definition**
178+
179+
```typescript
180+
public updateView(context: ComponentFramework.Context<IInputs>): void {
181+
ReactDOM.render(
182+
React.createElement(GridInlineRibbon, {
183+
context: context,
184+
parameters: {
185+
Record: context.parameters.Record,
186+
CommandButtonIds: context.parameters.CommandButtonIds,
187+
Dataset: context.parameters.Dataset
188+
},
189+
onOverrideComponentProps: (props) => {
190+
return {
191+
onRender: (props, defaultRender) => {
192+
return defaultRender({
193+
...props,
194+
onRenderRibbon: (props, defaultRender) => {
195+
return defaultRender({
196+
...props,
197+
onRenderCommandBar: (props, defaultRender) => {
198+
if (context.parameters.Type?.raw === 'custom') {
199+
return React.createElement(CustomButtons, {
200+
context: context,
201+
items: props.items
202+
});
203+
}
204+
return defaultRender({
205+
...props,
206+
items: props.items.map((item) => {
207+
return {
208+
...item,
209+
iconProps: {},
210+
className: mergeStyles({
211+
'.ms-Button-label': {
212+
fontWeight: 600
213+
}
214+
}),
215+
text: `${this._getEmojiFromString(item.text!)} ${item.text}`,
216+
};
217+
})
218+
});
219+
}
220+
});
221+
}
222+
});
223+
}
224+
};
225+
}
226+
} as IGridInlineRibbon),
227+
this._container
228+
);
229+
}
230+
```
231+
*Rendering of Custom Ribbon*
232+
233+
![Control customizer](/.attachments/applications/Controls/VirtualDataset/grid_native_custom_ribbon.png)
234+
*Customized native grid renderer*
235+
236+
![Custom Ribbon](/.attachments/applications/Controls/VirtualDataset/grid_fully_custom_ribbon.png)
237+
*Fully custom Ribbon PCF*
238+
159239
### Default Bindings
160240

161241
When the PCF is rendered as cell control, it will always receive these **bindings** in PCF context:
@@ -175,6 +255,7 @@ When the PCF is rendered as cell control, it will always receive these **binding
175255
| `IsInlineNewEnabled` | Whether new records can be created from the control. (Lookup only) |
176256
| `EnableTypeSuffix` | Whether the data type related suffix should be displayed, such as an icon for a Phone field. |
177257
| `EnableOptionSetColors`| Whether the control should display option set value colors (OptionSet only) |
258+
| `ShouldUnmountWhenOutputChanges`| Whether the control will unmount once a value is outputed |
178259

179260
The PCF will also receive `isControlDisabled` within `context.mode`. It's value depends on the control's role:
180261

@@ -219,39 +300,6 @@ When using a PCF control as a cell renderer, ensuring a fast render cycle is cri
219300

220301
To improve performance and speed up development, you can leverage the native cell renderer in your custom PCF. You can access it via the `GridCellRenderer` Base Control. It’s designed with performance in mind and you can simply customize it through the `onOverrideComponentProps` prop.
221302

222-
```typescript
223-
interface ICustomCellRendererWrapper {
224-
context: ComponentFramework.Context<any, any>;
225-
}
226-
227-
export const CustomCellRendererWrapper = (props: ICustomCellRendererWrapper) => {
228-
const { context } = { ...props };
229-
const formattedValue = context.parameters.value.formatted;
230-
231-
return (
232-
<GridCellRenderer
233-
context={context}
234-
parameters={context.parameters}
235-
onOverrideComponentProps={(props) => {
236-
return {
237-
...props,
238-
contentWrapperProps: {
239-
...props.contentWrapperProps,
240-
children: (
241-
<button onClick={() => alert(`Hello from ${formattedValue}!`)}>
242-
{formattedValue}
243-
</button>
244-
),
245-
},
246-
};
247-
}}
248-
/>
249-
);
250-
};
251-
```
252-
*The code snippet above utilizes the native cell renderer but replaces its content with a custom button. Since the button is embedded within the native renderer, it inherits all the styling applied at higher layers, such as padding and alignment.*
253-
254-
![PCF cell renderer](/.attachments/applications/Controls/VirtualDataset/customizer_renderer.gif)
255303

256304
> **_NOTE:_** The same concept applies to cell editors. Each native editor is managed through a Base Control, which you can utilize and tailor within your editor PCF. For instance, `talxis_TALXIS.PCF.ColorPicker` leverages the `TextField` Base Control and customizes it to suit it's needs.
257305

0 commit comments

Comments
 (0)