You need to sign in to do that
Don't have an account?
ezdhanhussain
Is it possible to move pageblocktable rows up and down?
Hi i have a requirement to re-order by pageblocktable rows as needed by using mouse drag functionality ? Can any one suggest possible methods to achieve this ?
Yes it is possible,
You have to change it in the sequence that you want.
<apex:pageblock1>
</apex:pageblock1>
<apex:pageblock2>
</apex:pageblock2>
etc.
If you have anything specific post your visualforce code as well.
Regards,
Ashish
vf page:-
<apex:pageBlockTable value="{!contactList}" var="item" title="Contact List" styleClass="vfFloatingHeaders">
<apex:column value="{!item.firstname}"/>
<apex:column value="{!item.lastname}"/>
<apex:column value="{!item.email}"/>
<apex:column value="{!item.phone}"/>
</apex:pageBlockTable>
controller class:-
public list<contact> contactList
{
get
{
if (contactList == null)
{
contactList = [select firstname, lastname, email, phone from contact];
}
return contactList;
}
set;
}
How do you wish to re order?
Can you share a pic ? explaing how it looks currently and what changes you are expecting?
Regards,
Ashish
The first table is a jquery example which displays <li></li>
The next image is after sorting rows
I want the same functionality to be implemented with our native pageblock table
How did you sort the items in the 2nd image?
How do you want to sort in the 3rd Image?
can you also share the visualforce code for these images?
Regards,
Ashish
http://jqueryui.com/sortable/
Then what you would do next is to add your page block within the jquery.
So your code might look like this:
<ul id="sortable">
<li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Insert Page Block 1</li>
<li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Insert Page Block 2</li>
<li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Insert Page Block 3</li>
</ul>
does this make sense? If not let me know and i'll see if i can create a simple POC for you.
Cheers
<apex:page standardController="Contact" extensions="extContactList">
<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"/>
<style>
#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; }
</style>
<script>
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
});
</script>
<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>
</apex:repeat>
</ul>
</apex:page>
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;
}
}
1. Create your own Data Table not using apex page block
2. Create a Custom Jquery or Use some type of Jquery Plug in that will accomplish your requirement.
Also, what is your use case for moving records up and down? Are you saving the order using the sortable feature?