get guid in javascript from object in datagrid when only data-id is known

0
Hi, Lets say we have a datagrid with 2 elements: <tbody class="mx-data-grid-body" dojoattachpoint ="gridBodyNode">     <tr class+"mx-name-index-0" data-id="364" tabindex="-1">..</tr>     <tr class+"mx-name-index-1" data-id="365" tabindex="-1">..</tr> </tbody>   How do you get the guids, with  javascript,  from the Mendix Objects shown in this grid, when only the data-id 's are known?  
asked
1 answers
2

I do not have a specific answer right away. I use some snippets from Andries' DataGrid Extension. See below. The first is to find the templategrid / datagrid. The second is my eventhandler on click. This will give you some information on how to find the grid and how to get the uuid. So basically you can use the domData function that is inside the datagrid-widget and uses the domNode of the row.

var domList = document.getElementsByClassName("mx-name-" + this.gridName);

if (domList.length > 0)
    this._grid = registry.byNode(domList[domList.length - 1]);

 

_handleClick: function(e) {

    // Only on mobile stop event bubbling!
    this._stopBubblingEventOnMobile(e);

    var gridItems = dojo.query(e.target).closest(".mx-templategrid-item");

    if (gridItems.length > 0) {
        var gridItem = gridItems[0];

        this._gridItemClicked = gridItem;

        var domData = this._grid.domData(gridItem);

        this._objectClicked = domData.mendixguid;

    }

}
answered