You need to sign in to do that
Don't have an account?

Problems with data binding.
I have a list on whose columns I have applied sorting.The functionality works perfectly well.The problem arises when I try to sort on the columns regularly sometimes they loose values and sometimes they work well without any problems.
I had logged a case in Salesforce but,the reply was:->
"
Currently Salesforce does not support the VisualForce. For assistance with this you would need to go to www.Salesforce.com/Developers for assistance with this issue.
"
Please advise.
Message Edited by iceberg4u on 01-20-2009 10:29 PM
Hi,
I have done sorting on lists without problems...
Please post some of the code to see if there are any problems.
{
SetSortDirection(m_COLCompanyWebsite); //for setting direction
List<ActionAlertsDetailBO> tempList = new List<ActionAlertsDetailBO>(); //temporary List of the original or sorted data
List<String> sortStringfield = new List<String>(); //the string list that will store all the values
//Populating temporary list of records for sorting
for(Integer i = 0 ; i < m_ActionAlertsDetailBO.size() ; i++)
{
tempList.add(m_ActionAlertsDetailBO[i]);
}
//Populating temporary list of values for sorting
for(Integer j = 0 ; j < m_ActionAlertsDetailBO.size() ; j++)
{
sortStringfield.add(tempList[j].AgreementStatusStringVal);
System.debug('tempList[j].CompanyWebsite:::::::'+tempList[j].AgreementStatusStringVal);
}
//Sort the list of values
//this.SortDir=false;
sortStringfield = sortData(sortStringfield,this.SortDir);
for(Integer j = 0 ; j < m_ActionAlertsDetailBO.size() ; j++)
{
System.debug('tempList[j].CompanyWebsite:::::::'+sortStringfield[j]);
}
m_ActionAlertsDetailBO.clear();
//Populate list of records according to sorted list of values
for(Integer i = 0 ; i < sortStringfield.size() ; i++)
{
for(Integer j = 0 ; j < tempList.size() ; j++)
{
if(sortStringfield[i].equals(tempList[j].AgreementStatusStringVal))
{ //for duplicate names there are problems coming up One will have to verify some primary key as well
m_ActionAlertsDetailBO.add(tempList[j]);
tempList.remove(j);
break;
}
}
}
for(Integer i = 0 ; i < sortStringfield.size() ; i++)
{
System.debug('The website sorted is:' + m_ActionAlertsDetailBO[i].AgreementStatusStringVal);
}
return null;
}
Hi,
I have few comments about your code
1)Actually I removed some System.debugs.The method is being called when the column header of the list is clicked.The sorting occurs properly but the values are lost in the main list as soon as it reaches the function itself.I do not understand what is occuring here.I get a lot of nulls.
2) I tried using Map but the same thing occurred.
3)Most people advised removing the "remove" portion from the "for" loop but I need to use it.Therefore I modelled the function in such a way so that it breaks immediately after a remove operation occurs.
Hi,
public pagereference sortbyCompanyWebsite() { SetSortDirection(m_COLCompanyWebsite); Map<String, ActionAlertsDetailBO> tempMap = new Map<String, ActionAlertsDetailBO>(); List<String> sortStringfield = new List<String>(); for(Integer i = 0 ; i < m_ActionAlertsDetailBO.size() ; i++) { // Populating temporary list of records for sorting tempMap.put(tempList[i].AgreementStatusStringVal, m_ActionAlertsDetailBO[i]); //Populating temporary list of values for sorting sortStringfield.add(tempList[i].AgreementStatusStringVal); System.debug('tempList[i].CompanyWebsite:::::::'+tempList[i].AgreementStatusStringVal); } //Sort the list of values // I assume you use something like List<>.sort()? sortStringfield = sortData(sortStringfield,this.SortDir); for(Integer j = 0 ; j < m_ActionAlertsDetailBO.size() ; j++) { System.debug('tempList[j].CompanyWebsite:::::::'+sortStringfield[j]); } m_ActionAlertsDetailBO.clear(); //Populate list of records according to sorted list of values for (String sortKey : sortStringfield) { m_ActionAlertsDetailBO.add(tempMap.get(sortKey)); } /* for(Integer i = 0 ; i < sortStringfield.size() ; i++) { System.debug('The website sorted is:' + m_ActionAlertsDetailBO[i].AgreementStatusStringVal); } */ for (String sortKey : sortStringfield) { System.debug('The website sorted is:' + tempMap.get(sortKey).AgreementStatusStringVal); } return null; }
This is not an accurate statement. There are varying degrees of support based on your agreements with salesforce.com but there is no policy that would make the above statement true. We are taking steps to rectify this inconsistency.
Apologies,
Hi,
As promised, I just posted the sorter class (Link) I started building this morning... Hopefully it helps.