Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 39855ef

Browse files
committed
docs: update docs regarding ViewComponents
1 parent fe5ea8e commit 39855ef

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

docs/developers-guide-v2.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ else
180180
#### DocTypeGridEditorViewComponent
181181
Behind the scenes, Doc Type Grid Editor uses a ViewComponent to render all items. You can let it use the default component for all your editors if you like, but you can also specify your own document type specific, or editor specific view component. Or specify your own default view component.
182182

183-
If you are not the type of developer that likes to put business logic in your views, then the ability to seperate logic from your view is a must. To render your grid editor item with a document type or editor specific view component, you need to create a view component, and give it a name in the format `{DocTypeAlias or EditorAlias}DocTypeGridEditorViewComponent`.
183+
If you are not the type of developer that likes to put business logic in your views, then the ability to seperate logic from your view is a must. To render your grid editor item with a document type or editor specific view component, you need to create a view component, and give it a name in the format `{EditorAlias or Document Type Alias}DocTypeGridEditorViewComponent`.
184+
185+
Note: The name of the viewcomponent is case sensitive, but DTGE is helpful enough to look for view components starting both with an uppercase letter and lowercase letter of your alias.
184186

185187
The view component must implement a method called Invoke taking a dynamic model parameter, and a viewPath parameter as a string. The method should return an IViewComponentResult. As an example, the default view component does this:
186188

@@ -192,9 +194,25 @@ public IViewComponentResult Invoke(dynamic model, string viewPath)
192194
```
193195

194196
#### Overriding the default view component
195-
Doc Type Grid Editor comes with a default view component, that simply takes the model of the editor and sends it to the correct view. If you want to override this viewcomponent.
197+
Doc Type Grid Editor comes with a default view component, that simply takes the model of the editor and sends it to the correct view. If you want to override this ViewComponent and replace it with your own, you can do it in your Startup.cs file, in the ConfigureServices method.
198+
199+
Add the following code, to configure DocTypeGridEditor:
200+
201+
```cs
202+
public void ConfigureServices(IServiceCollection services)
203+
{
204+
services.AddUmbraco(_env, _config)
205+
.AddBackOffice()
206+
.AddWebsite()
207+
.AddComposers()
208+
.Build();
196209

197-
TODO: How to implement config?
210+
services.SetDocTypeGridEditorSettings(c =>
211+
{
212+
c.DefaultDocTypeGridEditorViewComponent = typeof(MyDocTypeGridEditorViewComponent);
213+
});
214+
}
215+
```
198216

199217
---
200218

0 commit comments

Comments
 (0)