Copied to clipboard

Flag this post as spam?

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


  • Carlos 1 post 21 karma points
    Oct 26, 2022 @ 10:54
    Carlos
    0

    umb-table selectItem Undefined

    Hello everyone, I am using a custom AngularJs controller to make calls to an api, I get the data correctly and I need the Id to be returned when I click on the row, but the function selectItem(selectedItem, $index, $event) returns me undefined. I need to get the Id field of the row. Can someone help me? Thank you!

    "use strict";
     angular.module("umbraco").controller("customTestController", function ($scope, $http, $location, umbRequestHelper) {
    
    var vm = this;
    vm.items = [];
    vm.options = {
        includeProperties: [
            { alias: "Id", header: "Id" },
            { alias: "AttachedDocs", header: "AttachedDocs" },
            { alias: "Comments", header: "Comments" },
            { alias: "MarketName", header: "MarketName" },
            { alias: "OrderId", header: "OrderId" },
            { alias: "Products", header: "Products" },
            { alias: "RubiPoints", header: "RubiPoints" },
            { alias: "UmbracoMemberName", header: "UmbracoMemberName" }
        ]};
    
        vm.selectItem = selectItem;
        vm.clickItem = clickItem;
        vm.selectAll = selectAll;
        vm.isSelectedAll = isSelectedAll;
        vm.isSortDirection = isSortDirection;
        vm.sort = sort;
    
        getData();       
    
    
        function selectItem(selectedItem, $index, $event) {
            console.log("Item seleccionado: ", selectedItem)            
        }
    
        function clickItem(item) {
            alert("clickItem", item);
        }
    
        function selectAll($event) {
            alert("select all", $event);
        }
    
        function isSelectedAll() {
            alert("isSelectedAll")
        }
    
        function isSortDirection(col, direction) {
            alert("IsSortDirection", col, direction)
        }
        function sort(field, allow, isSystem) {
            alert("sort", field, allow, isSystem)
        }
    

    edit.html:

    <umb-table
    ng-if="vm.items"
    items="vm.items"
    item-properties="vm.options.includeProperties"
    allow-select-all="vm.allowSelectAll"
    on-select="vm.selectItem(selectedItem, $index, $event)"
    on-click="vm.clickItem"
    on-select-all="vm.selectItem(selectedItem, $index, $event)"
    on-selected-all="vm.isSelectedAll"
    on-sorting-direction="vm.isSortDirection"
    on-sort="vm.sort"
    

    > enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft