Copied to clipboard

Flag this post as spam?

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


  • iNETZO 133 posts 496 karma points c-trib
    Jun 26, 2018 @ 14:03
    iNETZO
    0

    Sortable inside a grid editor

    Hi,

    I'm creating a poll-editor for the grid. I want to make it possible to sort the answers. enter image description here

    It works but my problem is that when sorting, the item that has to move gets invisible and the bluegreen block show up.

    enter image description here

    I would like to use the "regular" way of sorting form jQuery UI, without hiding the item that moves: https://jqueryui.com/sortable/#default

    I use this code in my editor controller:

    $scope.sortableOptions = {
        axis: 'y',
        containment: 'parent',
        cursor: 'move',
        items: '> div.control-group',
        tolerance: 'pointer',
        stop: function (ev, ui) {
            angularHelper.safeApply($scope, function () {
                angular.forEach($scope.control.answers, function (val, index) {
                    val.index = index;
                });
    
            });
        }
    };
    

    And my view looks like:

    <umb-control-group label="Antwoorden" description="">
        <div ui-sortable="sortableOptions" ng-model="control.answers">
            <div class="control-group" ng-repeat="answer in control.answers">
                <i class="icon icon-navigation handle"></i>
                <input ng-show="true" ng-change="ChangeContent()" ng-model="answer.answertext" type="text" />
                <button class="btn btn-danger" ng-click="removeAnswer(answer.id)">
                    <i class="icon icon-trash"></i>
                </button>
            </div>
        </div>
        <button class="btn btn-default" type="button" ng-click="AddRow()">+</button>
    </umb-control-group>
    

    Do you have a suggestion how i can make the "default" sorting working in inside a grid-editor?

    Kind regards, iNETZO

  • Frans de Jong 548 posts 1840 karma points MVP 3x c-trib
    Jun 26, 2018 @ 20:04
    Frans de Jong
    0

    Hi iNetzo,

    For these tasks I always use DoctypeGridEditor. It takes care of all the angular logic and you have IPublishedContent or a strongly typed model when using modelsbuilder. This combined with nested content takes up only 15 minutes to setup exactly what you are looking for.

    Not the answer you asked for but maybe saves some time and frustration in the future?

    Doctype grid editor

    Frans

Please Sign in or register to post replies

Write your reply to:

Draft