I have a tab with about 6 tables, all with the same mass action. I’d like to create a button that would run the mass action for the selected rows on all the tables.
I could write the javascript to perform the action for each table, but thought it would be much easier to say “get this table, run this mass action.”
Page 1 / 1
Looks like it was easier than I thought to get all the selected rows from all the tables on a page with javascript.
I’m sure this could be written more elegantly, but here’s my code, if anyone’s in a similar situation. this code assumes that all the tables you want to get selections from have the CSS class MyTables.
It also adds the selected records to a new model, preventing duplicates.
'addAll2PRL': function(){ <br />var $ = skuid.$; //Get all selected referrals<br />var selectedElements = $('.nx-skootable.MyTables').map(function(){<br />return $(this).data('object').list.getSelectedItems();<br />});<br />//Get exisitng PRL referrals var model = skuid.$M('PatientCaseReferral');<br />var existingReferrals = a];<br />$.each(model.getRows(),function(){<br />existingReferrals.push(model.getFieldValue(this,'Referral_Id__c'));<br />});//If selected referral is not currently in PRL, add it.<br />$.each(selectedElements,function(){<br />if (existingReferrals.indexOf(this.row.Id) == -1) {<br />model.createRow({additionalConditions:t{field:'Referral_Id__c', value: this.row.Id}]});<br />}<br />});<br />}
Cool. I love it when you guys answer your own questions!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.