How to scroll to the row clicked using jquery?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mdfaisalpapa
User
Posts: 84

How to scroll to the row clicked using jquery?

Post by mdfaisalpapa »

I have a master table with many detail tables and have enabled Use button dropdown for links . It works fine. The problem is if the user clicks on options for the record near the bottom of the page , all the items in the dropdown are not visible as some of them get hidden below the page bottom. Is it possible to move the page up or to display the options as dropup(riseup to be precise) instead of dropdown if there are links in the options that are hidden so that they are visible to the user


danielc
User
Posts: 1601

Post by danielc »

Use jQuery to find the last row (see api.jquery.com/last-selector/) and add class dropup to <div class="btn-group">. This will make the dropdown menu become dropup. View the page source to find the element that you want to add "dropup". The jQuery code need to put into Client Scripts->Table-Specific->List Page->Startup Script.


mdfaisalpapa
User
Posts: 84

Post by mdfaisalpapa »

By last row i meant the last visible row on the screen. there may be more rows if one scrolls down. what i required was that when the user clicks on the options dropdown the list should be down or up depending on the space available on the screen.or the scrollbar can be moved to accomodate the options


danielc
User
Posts: 1601

Post by danielc »

If that's the case, you may write your javascript to add dropup class if approaching the bottom of the page.


mdfaisalpapa
User
Posts: 84

Post by mdfaisalpapa »

The following code in the Global Client script will scroll the row clicked to the top of the page.

$(function(){

$("table tr").click(function(){
$('html, body').animate({
scrollTop: ($('#'+this.id).offset().top)
},500);
});
});


Post Reply