Copied to clipboard

Flag this post as spam?

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


  • Dibs 202 posts 991 karma points
    Oct 27, 2015 @ 16:03
    Dibs
    0

    Custom Grid Editor issue

    Dear Umbraco Team

    Created a custom Grid Editor as per numerous tutorials on web. Able to render content as normal on Grid layout.

    but unable to insert pre set values within grid editor fields in Back Office to help content editors i.e textbox in back office to have pre value = 'type in this box'

    here is code from Grid Editor

    Editor.html

     <div ng-controller="faqs.controller">
    <textarea umb-auto-resize umb-auto-focus ng-model="control.value.text2" ng-style="control.config"></textarea>
    

    Editor.controller.js

     angular.module('umbraco').controller('faqs.controller'), function ($scope) {
         $scope.text2 = 'Please Type Here';
    });
    

    Editor.cshtml

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
    @{
        var random = umbraco.library.GetRandom();
        var randomNumber = random.Next();
    }
    <div class="row">
        <div class="col-md-9">
            <div>
                <h3 data-toggle="collapse" data-parent="#accordion" href="#@randomNumber">
                    @Model.value.text2
                </h3>
            </div>
            <div id="@randomNumber" class="collapse answers"> 
                @Html.Raw(@Model.value.rte1)
            </div>
        </div>
    </div>
    

    Thanks Dibs

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Oct 28, 2015 @ 07:30
    David Brendel
    100

    Hi Dibs,

    not quite sure if i get you right, but if you want to show a placeholder i think you can add it to controller.config. this can be an object and there you add it as a string. And then print it out with a placeholder attribute in your textarea.

    Regards David

  • Dibs 202 posts 991 karma points
    Oct 28, 2015 @ 12:02
    Dibs
    0

    Cheers David

    For the advice, but my mistake on code i provided. I have corrected the Editor.controller.js code, the line $scope.text2 = 'Please Type Here'; should populate the field in back office with the text.

    An example is the built in Headline grid editor that has 'Write here' when you insert the editor into the layout.

    I am new to Umbraco/Angluar & Razor, just working my way through examples when i hit an issue with my project.

    Thanks Dibs

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Oct 28, 2015 @ 16:09
    David Brendel
    0

    Hi Dibs,

    you have to store the value in $scope.control.value.text2 in your controller. That should work.

    Regards David

  • Dibs 202 posts 991 karma points
    Oct 28, 2015 @ 16:50
    Dibs
    0

    Hi David

    I have tried $scope.control.value.text2 it didnet work : (

    Dibs

  • Dibs 202 posts 991 karma points
    Nov 03, 2015 @ 22:39
    Dibs
    0

    Hi David

    Clearing cache fixed issue and able to to see pre values in text. Now issue is that once you save real content into textbox to overwrite pre values, the pre values are stilr rendered in back office and real content rendered on front end within Grid layout.

    I think your right by using a placeholder.

    Cheers Dibs

Please Sign in or register to post replies

Write your reply to:

Draft