You need to sign in to do that
Don't have an account?
Mohan Raj 33
Can any one known a dynamic query for the datatable of Accounts and Contacts and I want a dynamic query for the make a mouse click to that column it's give an order of "ascending" and the double click it gives "descending"order
Already I have a controller for the task as below:
public class ContactListController {
public List<Contact> ContactList {
get {
If(Contact.Account.Name != Null) {
If(ContactList == Null) {
ContactList = [SELECT Name, Account.Name, Phone, Email, MailingCity, MailingState, MailingPostalCode FROM Contact WHERE Account.Name != Null
ORDER BY Account.Name ASC];
}
}
return ContactList;
}
set;
}
}
the page for this controller is:
<apex:page controller="ContactListController"> <apex:form > <apex:pageBlock > List Of Contacts with Accounts: <apex:pageBlockTable value="{!ContactList}" var="contact" cellpadding="0" cellspacing="0" width="50%"> <apex:column value="{!contact.Account.Name}" onclick="ascending" ondblclick="descending"/> <apex:column value="{!contact.Name}"/> <apex:column value="{!contact.Phone}"/> <apex:column value="{!contact.Email}"/> <apex:column value="{!contact.MailingCity}"/> <apex:column value="{!contact.MailingPostalCode}"/> <apex:column value="{!contact.MailingState}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
But now i want to dynamic query to the if I click the mouse to the column of each in the table it's give the ascending order and then I click the double click it's give the descending order for the table data.
thank you
Mohan Raj
public class ContactListController {
public List<Contact> ContactList {
get {
If(Contact.Account.Name != Null) {
If(ContactList == Null) {
ContactList = [SELECT Name, Account.Name, Phone, Email, MailingCity, MailingState, MailingPostalCode FROM Contact WHERE Account.Name != Null
ORDER BY Account.Name ASC];
}
}
return ContactList;
}
set;
}
}
the page for this controller is:
<apex:page controller="ContactListController"> <apex:form > <apex:pageBlock > List Of Contacts with Accounts: <apex:pageBlockTable value="{!ContactList}" var="contact" cellpadding="0" cellspacing="0" width="50%"> <apex:column value="{!contact.Account.Name}" onclick="ascending" ondblclick="descending"/> <apex:column value="{!contact.Name}"/> <apex:column value="{!contact.Phone}"/> <apex:column value="{!contact.Email}"/> <apex:column value="{!contact.MailingCity}"/> <apex:column value="{!contact.MailingPostalCode}"/> <apex:column value="{!contact.MailingState}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
But now i want to dynamic query to the if I click the mouse to the column of each in the table it's give the ascending order and then I click the double click it's give the descending order for the table data.
thank you
Mohan Raj
This link can give you an idea. Check the comments section which has code example of how to make use of ASC and DESC on any column.
https://developer.salesforce.com/forums/?id=906F00000008z8TIAQ