Copied to clipboard

Flag this post as spam?

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


  • Mov3nforward 118 posts 320 karma points
    Feb 26, 2020 @ 21:34
    Mov3nforward
    0

    Listview Values

    We have a situation where we are trying to show in a list view the text of a radio button instead of a number. Why on earth Umbraco shows the radio button id instead of the label text in a list view is beyond me and is useless for clients.

    We have made a change in the past by getting the radio button list and pulling the label text that way. We are now in a situation where we have something like this to populate a list view for members.

    $scope.model.config = {
    pageSize: 100,
    orderBy: 'Name',
    orderDirection: 'asc',
    includeProperties: [
        { alias: 'email', header: 'Email', isSystem: 1 },
        { alias: 'memberGroups', header: 'Group', isSystem: 1 },
        { alias: 'hasTableau', header: 'Tableau', isSystem: 0 },
        { alias: 'organization', header: 'Org', isSystem: 0 },
    ],
    layouts: [
        { name: 'List', path: 'views/propertyeditors/listview/layouts/list/list.html', icon: 'icon-list', isSystem: 1, selected: true }
    ],
    bulkActionPermissions: {
        allowBulkDelete: true,
        allowExport: true
    }
    };
    

    This works, but the "Organization" is showing the radiobutton id. In the past we did something like this:

    //Prevalue Variables
    var prevaluesOrg = null;
    
    getOrgPrevalues();
    
    function getOrgPrevalues() {
        dataTypeResource.getPreValues("Umbraco.RadioButtonList", 1428).then(function (prevalues) {
            prevaluesOrg = prevalues;
            console.log("prevaluesOrg" + JSON.stringify(prevaluesOrg));
            setPrevalues();
        });
    
    }
    function setPrevalues() {
            angular.forEach($scope.items, function (item) {
                console.log("item: " + JSON.stringify(item));
                item.organization = prevaluesOrg[0].value[item.organization].value;
            });
        }
    

    I am not sure how we would do the same thing with the $scope.model.config. Any ideas?

    -Lee

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Feb 26, 2020 @ 22:07
    Robert Foster
    0

    Hi Lee,

    You should call your getOrgPrevalues() method in initView; and then you can update the data coming from the controller in the setPropertyValues method.

    An alternative to this would be to pad the Member Index with a resolved value for organization, which will give you the benefit of being able to retrieve the value as part of the dataset without having to look up the prevalues.

  • Mov3nforward 118 posts 320 karma points
    Feb 27, 2020 @ 16:10
    Mov3nforward
    100

    What I ended up doing is first getting all of the organizations.

    First I needed to add "dataTypeResource" to the memberListViewController function.

    I added my custom column to the includeProperties around line 39.

    includeProperties: [
            { alias: 'email', header: 'Email', isSystem: 1 },
            { alias: 'memberGroups', header: 'Group', isSystem: 1 },
            { alias: 'organization', header: 'Org', isSystem: 0 }
    

    I added this to the initView method to get the organizations.

    dataTypeResource.getPreValues("Umbraco.RadioButtonList", 1428).then(function (prevalues) {
            prevaluesOrg = JSON.parse(JSON.stringify(prevalues));
            console.log("prevaluesOrg: " + JSON.stringify(prevaluesOrg));
    
        });
    

    Then I followed what you did to change the "Approved" column text by added this line to the setPropertyValues function.

    if (alias === "organization") {
                value = getOrganizationPropertyValue(alias, result.properties);
                //console.log("value: " +value);
            }
    

    I used your getCustomPropertyValue function to retrieve the organization value from the 'prevaluesOrg' variable containing the JSON data.

    function getOrganizationPropertyValue(alias, properties) {
        var value = '';
        var index = 0;
        var foundAlias = false;
        for (var i = 0; i < properties.length; i++) {
            if (properties[i].alias === alias) {
                foundAlias = true;
                break;
            }
            index++;
        }
    
        if (foundAlias) {
            value = newvalue[0].value[properties[index].value].value;
        }
    
        return value;
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies