getSelectedItems in a custom button

  • 1
  • Question
  • Updated 4 years ago

So I have my row(s) highlighted in/on model using a row action to addClass() and that part works great.

The next thing is to pull the selected row or rows from any given model so what script do I need to use to get the <anyModel>.list.getSelectedItems()


Photo of Jerry Neppl

Jerry Neppl

  • 130 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
If you mean using a mass action, you can use this to get the Ids :

var Ids = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){    
return item.row.Id;
});


Photo of Jerry Neppl

Jerry Neppl

  • 130 Points 100 badge 2x thumb
I almost called the post pseudo mass action however the trick is doing multiple different models on a page so looking to get to the list(s) from possibly various sources 

Perhaps understanding how the list gets built would be beneficial ??
(Edited)
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Jerry,

There could me multiple lists attached to a particular model, so you'd have to iterate over each one.

Check out the registeredLists property on the model described here.

http://help.skuidify.com/m/11720/l/205447-skuid-model-model

Here is a code snippet that should log each of the selected items on all lists for a model.

skuid.$.each(myModel.registeredLists,function(){
    console.log(this.getSelectedItems());
});

(Edited)