Jump to content
  • 0

custom button for Next Record on Details datapage


DesiLogi

Question

Hello,

I have a Details datapage set up so when Update is clicked it goes to the next record. I need to figure out how to create a custom button (to put in either the Footer or an HTML block) to go to the Next Record (and a button for Previous, as well) so that the user can cycle through without clicking Update. The standard record navigation arrows at the bottom will not work for UI reasons (I need to make the custom 'Next Record' button relabeled and hidden in various scenarios). Does anyone know how to create a custom button for Next Record? 

As well, I also need to know how to hide that button (if it's in its own Section in an HTML block) when the Details form is at the 'last record' of the series (because there will be no 'Next Record' at that point). Any help would be greatly appreciated- 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

@DesiLogi

You can implement this functionality using additional HTML/CSS/JS

Please find the application with the same implemented buttons attached - CaspioData_2019-Jun-20_1117.zip

The logic is that you hide the standard navigation block, create your buttons and as soon as you click your button, custom event clicks the appropriate button in the hidden navigation block.
Here is the code from the footer of the Details result page:

<style>

#prev, #next {
 display: inline-block;
 padding: 10px 15px;
 background-color: lightgray;
 border: 1 px solid gray;
 cursor: pointer;
}

#current {
 display: inline-block;
 padding: 10px;
}

#prev:hover, #next:hover {
 background-color: gray;
 color: white;
}

.cbFormNavigationTableCellspacing {
 display: none;
}

</style>

<div>
 <div id="prev">Previous</div>
 <p id="current"></p>
 <div id="next">Next</div>
</div>


<script type="text/javascript">
document.addEventListener('DataPageReady', function () {

 let re = /(\d+)/;
 let currentPage = document.querySelector('.cbFormJumpToTextField').value;
 let allPages = document.querySelector('.cbFormNavigationMessage').innerText.match(re)[0];

 let nextBtn = document.getElementById('next');
 let prevBtn = document.getElementById('prev');
 let current = document.getElementById('current');

 current.innerHTML = currentPage + ' of ' + allPages ;

 nextBtn.addEventListener("click", function() {
  if(currentPage != allPages) {
   document.querySelector('a[data-cb-name="JumpToNext"]').click();
  } else {
   nextBtn.style.backgroundColor = "red";
   return false;
  }
 });

 prevBtn.addEventListener("click", function() {
  if(currentPage != 1) {
   document.querySelector('a[data-cb-name="JumpToPrev"]').click();
  } else {
   prevBtn.style.backgroundColor = "red";
   return false;
  }
 });

});
</script>

 

Link to comment
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...