+ Start a Discussion
Kota Uday 6Kota Uday 6 

swap records in vf page using up and down buttons

i have custom setting object ,with Name and numebr fields, i want to shuffle number up and down using button s, can any one hlpe me with code
Eswar Prasad@Sfdc11Eswar Prasad@Sfdc11
HI Kota Uday
pls see below code Is it possible to move pageblocktable rows up and down? i think we are asking same requirement is it right


<apex:page standardController="Contact" extensions="extContactList" showHeader="false">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"/>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css"/>
#sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }
#sortable li span { position: absolute; margin-left: -1.3em; }

$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();

    <ul id="sortable" >
        <li class="ui-state-default"> First Name - Last Name - Id</li>
    <apex:repeat value="{!ContactList}" var="c">
        <li class="ui-state-default"> {!c.FirstName} - {!c.LastName} - {!c.Id} </li>


public class extContactList {

    public extContactList(ApexPages.StandardController controller) {

    public List <Contact> getContactList(){
    List <Contact> c = [select id, FirstName, LastName from Contact Limit 10];
    return c;


If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.

Eswar Prasad.
Kota Uday 6Kota Uday 6
Hi Eswar Prasad,

I have one custom setting object with Name and number as fields,based on numbers my records are disply in VF page .
So by using button in VF page i want to change the records postion like [ 1 =2,2=3,3=1]

For this i need logic is needed,

Would you please help me out .

[User-added image]
Kota Uday 6Kota Uday 6
User-added image