1

I have a pageblock table where in I must be able to select one or multiple rows on clicking the row itself. On clicking a button, these rows must be displayed below the table in another table to show as selected. I am using a wrapper to display the records. Can i have a checkbox kept hidden for the purpose. Is it possible to update the hidden checkbox on row select through javascript or jquery?

2
  • You can definitely add a row click listener in javascript. I don't think you need to worry about checkboxes at all, though you do need a way to track the row ids and probably send them back to the server.
    – Adrian Larson
    Mar 19 '15 at 20:44
  • I am new to javascript and jquery. My code will resemble something like below <script> var lastRow; function highlight(elem){ elem.style.backgroundColor = 'yellow'; } </script> <apex:pageBlock> <apex:pageBlockTable value="{!list1}" var="item" rules="rows" id="myTable1" onRowClick="highlight(this);"> <apex:column value="{!item.id}"/> <apex:column value="{!item.name}"/> </apex:pageBlockTable> </apex:pageBlock> I need to show the highlighted rows in a separate table Mar 20 '15 at 6:55
1

With jQuery you could do something like:

(function ($) {
    "use strict";
    $('body').on('click', 'tr.dataRow', function (event) {
        // do stuff
    }
})(jQuery);

I ended up building out a pretty complicated page using angular for my project with a similar feature, so most of the rest of my code would not apply to your situation. From here you will probably want to maintain (in JS) a collection of ids of record rows you have selected and send them back to the server with an actionFunction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.