Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Kirschner 323 posts 611 karma points
    May 26, 2017 @ 17:48
    Matthew Kirschner
    0

    How do I show the document type label in the grid?

    When adding content to the grid using the DTGE, I want the name of my document type to appear on the grid instead of just 'DocType' for everything.

    Is this not a current feature or am I just missing something?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    May 29, 2017 @ 13:51
    Lee Kelleher
    0

    Hi Matthew,

    Out of the box, DTGE will use the "name" from the entry in the "grid.editors.config.js" file. Our docs gives an example of "Doc Type", (which I guess you are using?), so that's what it will show.

    You can create custom previews for the DTGE cells. You could try this...

    1. Set the enablePreview to true.

    2. In the folder (that the previewViewPath is pointing at), create a Razor .cshtml file, with the filename of what your alias value would be. If you're following our docs, then it could be docType.cshtml (This is case-insensitive, if you want to call it DocType.cshtml).

    3. For the contents of the Razor file...

    Try this as an example:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        var ct = ApplicationContext.Current.Services.ContentTypeService.GetContentType(Model.DocumentTypeAlias);
    }
    <i class="icon @ct.Icon"></i>
    <div class="help-text">@Model.DocumentTypeAlias.ToFirstUpper().SplitPascalCasing()</div>
    

    I hope this helps?

    Cheers,
    - Lee

  • Matthew Kirschner 323 posts 611 karma points
    May 30, 2017 @ 14:06
    Matthew Kirschner
    0

    Thanks, Lee.

    I wasn't able to get previews to work with your example. Below is the config I'm using:

    {
            "name": "Features",
            "alias": "docType",
            "view": "/App_Plugins/DocTypeGridEditor/Views/doctypegrideditor.html",
            "render": "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
            "icon": "icon-folder-outline",
            "config": {
                "allowedDocTypes": [
                    "button",
                    "card",
                    "googleMap",
                    "imageBanner",
                    "imageGallery",
                    "localistEventsList",
                    "personnelList",
                    "slider"
                ],
                "nameTemplate": "",
                "enablePreview": true,
                "viewPath": "/Views/Partials/",
                "previewViewPath": "/Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/",
                "previewCssFilePath": "",
                "previewJsFilePath": ""
            }
        }
    

    I created the file: /Views/Partials/Grid/Editors/DocTypeGridEditor/Previews/docType.cshtml with your sample code, but all my DTGE properties in the backoffice still say Features in the header.

    Could you please explain what the "nameTemplate" property does? I don't see any mention of it in the Developer Guide.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    May 30, 2017 @ 14:25
    Lee Kelleher
    0

    The nameTemplate is for if you want to use any of the doctype's property values in the name/label. e.g. you could do "Blah {{propertyAlias}}".

    Yeah, our docs need updating, (same old reason, there's not enough hours in the day).

    If that makes sense?

    Cheers,
    - Lee

  • Daniel Bardi 927 posts 2562 karma points
    Aug 18, 2017 @ 10:12
    Daniel Bardi
    0

    nameTemplate doesn't appear to do anything. When I change it to "Widget: {{propertyAlias}}" it still shows the name value How do I get this to work?

    As a workaround, I have the following in the preview /Previews/docType.cshtml

    @{icon = ApplicationContext.Current.Services.ContentTypeService.GetContentType(Model.DocumentTypeAlias).Icon; }
    
    <div style="text-align: left; align-items: center; padding: 5px; margin-bottom: 10px; background: #f3f3f5; border: 1px solid #bbbabf;">
    <i class="icon @icon" style="vertical-align: middle"></i>
    <div class="help-text" style="vertical-align: middle">@Model.DocumentTypeAlias.ToFirstUpper().SplitPascalCasing() Widget</div>
    

  • Richard Hamilton 79 posts 169 karma points
    Jan 10, 2019 @ 09:56
    Richard Hamilton
    0

    That didn't work for me either, just literally outputs the text xxxx {{propertyAlias}}

Please Sign in or register to post replies

Write your reply to:

Draft