function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gonzalo Lazzaroni 1Gonzalo Lazzaroni 1 

sortable doesn't work

Hello everyone, I'm new in salesforce
I want to use drag and drop in my pageblock but I can't. I've created a custom field in Accounts and display data by customfield (level__c). I want to group the accounts by groups (level 1, level 2, level 3).

This is my code:

Controller:
public with sharing class TheController {
    
    public List<Account> accounts {get;set;}
    public String[] levels {get;set;}
    
    public void load(){
        accounts = [SELECT Id, Name, level__c FROM Account WHERE level__c IN ('level 1', 'level 2', 'level 3')];
        
        Set<String> levelSet = new Set<String>();
        for (Account a : accounts)
            levelSet.add(a.level__c);
        
        levels = new String[levelSet.size()];
        Integer i = 0;
        for (String level : levelSet){
            levels[i] = level;
            i++;
        }
    }
}
 
<apex:page controller="TheController" action="{!load}">
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"/>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"/>

    <apex:stylesheet value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css"/>

    <script>
    	$(document).ready(function(){
            implementSortable();
            });
    
    	function implementSortable(){
        	$( "#sortable" ).sortable();
            $( "#sortable" ).disableSelection();
        }
    </script>

    	<apex:repeat value="{!levels}" var="level">
            <apex:pageBlock title="{!level}">
            		<apex:repeat value="{!accounts}" var="account">
                    	<apex:outputPanel id="sortable" rendered="{!IF(level=account.level__c,true,false)}">
                    		{!account.Name} - {!account.level__c}<br/>         
                    	</apex:outputPanel>                                                                      
                	</apex:repeat>
            </apex:pageBlock>
        </apex:repeat>   
</apex:page>

Thank you, greetings
ALEJO CARPENZANOALEJO CARPENZANO
hi, try importing the library with this code:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>

hope will help you!
Gonzalo Lazzaroni 1Gonzalo Lazzaroni 1
Hello, thanks for your reply. I tried but it's doesn't work.