Skip to main content

I need to write some code to run a loop only on the rows that are checked in a table. How do I reference the checked table rows in javascript?

You’ll need to give your table a unique name e.g. my-table.


var myTable = skuid.$('#my-table').data('object');<br>var selectedItems = list.getSelectedItems();<br>$.each(selectedItems, function (i, item) {<br>&nbsp; &nbsp; console.log(i + ' - ' + item);<br>});







Thanks Irvin


Another Community post that might be helpful here:

https://community.skuid.com/t/how-to-add-marketo-send-email-mass-action-to-a-skuid-tab…

And here’s the documentation on writing Mass Action Snippets, which leverage the “getSelectedItems()” behavior Irwin described:

http://help.skuidify.com/m/11720/l/204930-table-component-custom-mass-actions


Thanks everyone! We got it working as a mass action…

var params = argumentst0], $ = skuid.$,
    action = argumentse0].action,
    list = argumentsu0].list,
    model = argumentsr0].model,
    selectedItems = list.getSelectedItems();

var SessionModelId=skuid.model.getModel(“MMA_Academy_Student_Event_Session_included”).datal0].Id;

if(SessionModelId) {

    var SessionPerformerModel=skuid.model.getModel(“MMA_Academy_Student_Event_Session_Perfor”);

    $.each( selectedItems,
        function( i, item )
        {
            var row = item.row;
            console.log(row.Id);
            var newRow=SessionPerformerModel.createRow({
                additionalConditions: o
                    {field:‘MMA_Academy_Student_Event_Performer__c’, value:row.Id},
                    {field:‘MMA_Academy_Student_Event_Session__c’, value:SessionModelId},
                    
                    ], doAppend: true
            });
        });
        SessionPerformerModel.save({callback: function(result){
        if (result.totalsuccess) {
            alert(‘Performers were added to the selected sessions’);
        } else {
            console.log(result.insertResults);
            console.log(result.updateResults);
            console.log(result.deleteResults);      
        }
    }});
}

else{
    alert(‘Select a session to add the performers to.’);
}



I’m glad you got it working!  Cheers!