• san5
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Is there any way to sort datefield[Latest date record first] in page block table without using Controller.
Actually iam getting data in pageblock table from other integrated system .
So is there any possibility to sort table by latest date First.
Any Help appreciated.
 
  • March 22, 2016
  • Like
  • 0

  Any help appreciated. Below is my page and controller.

 

 

PAGE

<apex:page controller="showselectedAccounts" sidebar="false">
<apex:form >
<apex:sectionHeader title="Account"/>
<apex:pageBlock >
<apex:paGeBlockButtons >
<apex:commandButton value="Click here to view selected Accounts" status="status" action="{!showselected}" rerender="spblock,errorMessages" />
<apex:actionstatus startText="please wait......" id="status"/>
<apex:commandButton value="clear" action="{!clear}" rerender="spblock,san,chkbox,errorMessages" />
</apex:pageBlockButtons>
<apex:pageMessages id="errorMessages"/>
<span><b> All Accounts</b></span>
<span style="padding-left:750px;"><b>Selected Accounts</b></span>
<apex:pageBlockSection columns="2" >
<apex:pageBlocktable value="{!lstWrapper}" var="Ewrap" id="san" >
<apex:column headervalue="selected" >
<apex:inputCheckbox value="{!Ewrap.selected}" id="chkbox"/>
</apex:column>
<apex:column headerValue="Account Name">
<apex:outputField value="{!Ewrap.Acc.name}"/>
</apex:column>
</apex:pageBlocktable>
<apex:pageblockTable value="{!selectedAcc}" var="EAcc" id="spblock">
<apex:column headervalue="Account Name">
<apex:outputfield value="{!EAcc.name}"/>
</apex:column>
<apex:column headervalue="phone">
<apex:outputfield value="{!EAcc.phone}"/>
</apex:column>
<apex:column headervalue="fax">
<apex:outputfield value="{!EAcc.fax}"/>
</apex:column>
<apex:column headervalue="Industry">
<apex:outputfield value="{!EAcc.industry}"/>
</apex:column>
<apex:column headervalue="Rating">
<apex:outputfield value="{!EAcc.Rating}"/>
</apex:column>
<apex:column headervalue="type">
<apex:outputfield value="{!EAcc.type}"/>
</apex:column>
<apex:column headervalue="website">
<apex:outputfield value="{!EAcc.website}"/>
</apex:column>
<apex:column headervalue="Description">
<apex:outputfield value="{!EAcc.Description}"/>
</apex:column>
<apex:column headervalue="Account SIC">
<apex:outputfield value="{!EAcc.sic}"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 


CONTROLLER:


public with sharing class showselectedAccounts {
public list<Account> lstAcc{get;set;}
public list<Account> selectedAcc{get;set;}
public list<wrapper> lstWrapper{get;set;}
public boolean noAcc{get;set;}
    public showselectedAccounts(){
lstWrapper=new list<wrapper>();
noAcc=false;
lstAcc=[select id, name, phone,fax,industry,rating,type,website,Description,sic from Account];
wrapper objwrap;
for(Account objA:lstAcc){
objwrap=new wrapper();
objwrap.Acc=objA;
lstWrapper.add(objWrap);
}
}

public void showselected() {
selectedAcc=new list<Account>();
selectedAcc.clear();
for(Wrapper objWrap:lstWrapper){
if(objWrap.selected){
noAcc=true;
selectedAcc.add(objWrap.Acc);
}
}
if(!noAcc){
system.debug('8888888'+noacc);
Apexpages.addMessage(new ApexPages.message(Apexpages.severity.INFO, 'No Account Selected'));
}
}

public pagereference clear() {
selectedAcc=new list<Account>();

if(selectedacc!=null)
{
selectedacc=null;
}
/* lstWrapper=new list<wrapper>();
if( lstwrapper.selected!=null)
{
lstWrapper.selected=null;

}*/
/*for(Wrapper objWrap:lstWrapper){
if(objWrap.selected!=null){
objwrap.selected=null;
}
lstacc.clear();*/

return null;
}

public class Wrapper{
public boolean selected{get;set;}
public Account Acc{get; set;}
}

}

  • August 20, 2013
  • Like
  • 0
Is there any way to sort datefield[Latest date record first] in page block table without using Controller.
Actually iam getting data in pageblock table from other integrated system .
So is there any possibility to sort table by latest date First.
Any Help appreciated.
 
  • March 22, 2016
  • Like
  • 0
Hi,

I'm looking for solution of having as default sorting my records in VF column by date field {!item.SCMC__Planned_Completion_Date__c} in ascending order. i will appreciate any help. Thanks. 

VF page
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No.">
<apex:outputLink value="/{!item.id}" target="_blank">
{!item.Name}
</apex:outputLink>
</apex:column>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:100px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:100px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>

Controller

public class TestExtension {
    public List<SCMC__Production_Order__c> objlist{get;set;}
    public TestExtension(ApexPages.StandardSetController controller) {
    objlist = [SELECT Name, Sales_Order_No__c,Customer__c, Assembly_Name__c, SCMC__Start_Date__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pending Pulling All Items'];
    }
}

Hello Friends,

 

I am trying to create a table where we can show the data by wrapper class.here is my code

public class CLS_LeadPagination {

public List<leadWrapper> leadlist {get;set;}
public list<lead> leads{get;set;}
public list<string> leadString{get;set;}

public CLS_LeadPagination()
{

leadlist= new List<leadWrapper>();
leads=new list<lead>();
leadString=new list<string>();
leads= [select name,Email from lead order by name];
leadWrapper objwrap;
for(lead l:leads)
{
objwrap=new leadWrapper();
objwrap.leadobj=l;
leadlist.add(objwrap);
leadString.add(l.name);
}
}
public ApexPages.StandardSetController con {
get {
if(con == null) {
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM lead Order By Name ]));

con.setPageSize(10);
}
return con;
}
set;
}







public Boolean hasNext {
get {
return con.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return con.getHasPrevious();
}
set;

}

public Integer pageNumber {
get {
return con.getPageNumber();
}
set;
}
public void first() {
con.first();
}

// returns the last page of records
public void last() {
con.last();
}
public void previous() {
con.previous();
}

// returns the next page of records
public void next() {
con.next();
}

// returns the PageReference of the original page, if known, or the home page.


public pageReference SelectRecord()
{

pageReference pr=new pageReference('/apex/VF_LeadNew_Edit_Page');
return pr;
}
public pageReference Cancel()
{

return null;
}

 

public class leadWrapper {

public Boolean checked{ get; set; }
public lead leadobj { get; set;}
public string leadname { get; set;}

public leadWrapper(){
leadobj = new lead();
leadname=leadobj.name;
checked = false;
}
}
}

++++++++++++++++++++++++++++++++
<apex:page controller="CLS_LeadPagination" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!SelectRecord}" value="NewLead"/>

</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="Leads - Page #{!pageNumber}" columns="1">
<apex:pageBlockTable value="{!leadlist}" var="lead">
<apex:column headerValue="Name">
<apex:outputLink value="/{!lead.leadobj.Id}/e">{!lead.leadobj.name} </apex:outputLink>
</apex:column>
<apex:column value="{!lead.leadobj.Email}" headerValue="Email"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
</apex:form>
</apex:page>

but here i dont want to display data using standard variable(!lead.leadobj.name).Is there is any way to take variable in wrapper class and showing the name of lead by that.

 

Any quick reply will be very helpfull

 

  • February 20, 2013
  • Like
  • 0

 

Hi, needed some assistance with removing salesforce footer information from a visualforce page

 

this is what I have written so far:

 

<apex:page standardController="Contact">
    
            <apex:outputField value="{!Contact.name}"/> <br/> <br/>
            <apex:outputField value="{!Contact.Title}"/> <br/> <br/>
            <apex:outputtext value="{!Contact.Account.Name}"/> <br/>
            <apex:outputField value="{!Contact.MailingCity}"/> <br/>
            <apex:outputField value="{!Contact.MailingState}"/> <br/>
            <apex:outputField value="{!Contact.MailingCountry}"/> <br/>
            <apex:outputField value="{!Contact.MailingPostalCode}"/> <br/>
            <apex:outputField value="{!Contact.Fax}"/> <br/>
      
</apex:page>

 

When I select the button that uses the code above, I get the following at the bottom of the page:

 

Copyright © 2000-2012 salesforce.com, inc. All rights reserved. | Privacy Statement | Security Statement | Terms of Use | 508 Compliance
Just need to know how to remove this, thanks