NeoInJS Posted November 23, 2016 Report Share Posted November 23, 2016 I need assistance to change the background of an element in a gallery or list report when clicked. And get it's reference ID or info as a parameter Quote Link to comment Share on other sites More sharing options...
0 nightowl Posted November 23, 2016 Report Share Posted November 23, 2016 Hi NeoInJS, To create this click highlighting behavior: Please edit the list/gallery report DataPage inside Caspio Bridge. Then on the Search and Report Wizard - Configure Results Page Fields screen, please create a Header and Footer section. Once you've done that, please paste the following code snippet inside the Footer section: <style type="text/css"> .item-highlight { background-color: red; } .item-highlight:hover { background-color: red; } </style> <script> var oddItems = document.getElementsByClassName("cbResultSetListViewTableOddCell"); var evenItems = document.getElementsByClassName("cbResultSetListViewTableEvenCell"); var lastClicked = null; function highlight() { // Remove previously highlighted item if (lastClicked !== null) { lastClicked.classList.remove("item-highlight"); } // Update the lastClicked tracker lastClicked = this; // Add the highlight this.classList.add("item-highlight"); } var attachEvent = function (item, value) { item.addEventListener('click', highlight); }; Array.prototype.forEach.call(oddItems, attachEvent); Array.prototype.forEach.call(evenItems, attachEvent); </script> As for the ID referencing part, I still have to find a way on how to do that. :-) Quote Link to comment Share on other sites More sharing options...
0 nightowl Posted November 23, 2016 Report Share Posted November 23, 2016 Regarding the ID referencing part, here's what worked for me: On the Search and Report Wizard - Configure Results Page Fields screen, add a new HTML block. To insert your own HTML or JavaScript code you must go to the Source view as shown below. Then, inside that HTML block, create a hidden input field that captures the value of the ID field: <input class="record-id" type="hidden" value="[@field:ID]" /> Don't forget to replace [@field:ID] with the actual name of your ID field. For instance, if you're using SS_ID as the table ID, then use [@field:SS_ID] instead. Once you've done that, you can now use the following code snippet to retrieve the ID of the selected item: var lastClickedID = lastClicked.querySelector(".record-id").value; This reference ID (lastClickedID) can now be passed as a parameter value in a JavaScript-generated redirection link. Quote Link to comment Share on other sites More sharing options...
Question
NeoInJS
I need assistance to change the background of an element in a gallery or list report when clicked. And get it's reference ID or info as a parameter
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.