Copied to clipboard

Flag this post as spam?

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


  • Clickfarm 77 posts 161 karma points
    Aug 11, 2015 @ 18:24
    Clickfarm
    0

    using custom data type in custom section

    I have a custom section which allows me to edit data in a custom table.

    I have created a custom Umbraco.Dropdown data type for which I have added a number of prevalues.

    How do I configure and insert this custom dropdown into my custom section edit view and save the value to the database?

    I have added this to my edit.html:

    <umb-control-group label="Category" description="Required - Select a category">
       <select ng-options="item.id as item.value for item in model.categories" ng-model="person.categoryId" name="dropDownList"></select>
    </umb-control-group>
    

    Can someone tell me what i need to do to hook up the custom dropdown?

    Thanks!

  • Clickfarm 77 posts 161 karma points
    Aug 12, 2015 @ 14:10
    Clickfarm
    0

    bump.

    Anybody with experience building custom sections?

  • Clickfarm 77 posts 161 karma points
    Aug 12, 2015 @ 18:06
    Clickfarm
    0

    OK, i've gotten so far as to having access to the dropdown in my edit.controller.js file but i'm not sure how to get it into my edit.html view.

    this code:

    datatypeResource.getByName('Our People Category').then(function (result) {
        $scope.categoryDropdown = [
        {
            alias: 'categoryDropdown',
            label: 'Text',
            view: result.data.view,
            config: result.data.config,
            value: $scope.person.categoryName
        }
    ];});
    

    will populate the $scope.categoryDropdown object with the following JSON:

    [{"alias":"categoryDropdown","label":"Text","view":"dropdown","config":{"items":{"1038":{"value":"Board of Directors","sortOrder":1},"1039":{"value":"Field Support","sortOrder":2},"1040":{"value":"Customer Service","sortOrder":3},"1041":{"value":"Laboratory","sortOrder":4},"1042":{"value":"Sustainability","sortOrder":5}}}}] 
    

    but i'm not sure how to get that data to populate a select element as well as save to the database.

    can someone get me across the finish line here?

  • Clickfarm 77 posts 161 karma points
    Aug 12, 2015 @ 19:26
    Clickfarm
    0

    well it's definitely a hack and i really wish someone would respond with the recommended approach to do this, but this worked for me:

                        <umb-control-group label="Category" description="Required - Select a category">
                        <select class="umb-editor umb-dropdown" ng-model="person.categoryName" required>
                            <option value="">-- Select a Category --</option>
                            <option ng-selected="person.categoryName == obj.value" value="{{obj.value}}" ng-repeat="obj in categoryDropdown[0].config.items">{{obj.value}}</option>
                        </select>
                    </umb-control-group>
    

    Would be nice if Umbraco actually had documentation for building custom sections... i'm stuck with Googling things for hours to see how people "hack' the cms to make it work. disappointing.

Please Sign in or register to post replies

Write your reply to:

Draft