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

new post
Hi Guys,
I should create a Visualforce page by using SLDS with a dropdown list having all the custom list view names and a table which display the record's of the selected list view.
I have created the basics of VF page with SLDS but, not able to append the List view to dropdown and display the related list view records in a table.
Below is my code. Your help is highly appreciated.
VF Page:
<apex:page controller="example" showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
<apex:form>
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="{!URLFOR($Resource.SLDS100, 'styles/salesforce-lightning-design-system.css')}" />
</head>
<body>
<!-- REQUIRED SLDS WRAPPER -->
<div class="slds">
<!-- MASTHEAD -->
<p class="slds-text-heading--label slds-m-bottom--small">Salesforce Lightning Design System Module</p>
<!-- / MASTHEAD -->
<!-- PAGE HEADER -->
<div class="slds-page-header" role="banner">
<!-- LAYOUT GRID -->
<div class="slds-grid">
<!-- GRID COL -->
<div class="slds-col">
<!-- HEADING AREA -->
<p class="slds-text-heading--label">Accounts</p>
<h1 class="slds-text-heading--medium">My Accounts</h1>
<!-- /HEADING AREA -->
</div>
<!-- GRID COL -->
<div class="slds-col slds-no-flex slds-align-middle">
<div class="slds-button-group" role="group">
<button class="slds-button slds-button--neutral">
New Account
</button>
<button class="slds-button slds-button--neutral">
More
</button>
</div>
</div>
<!-- / GRID COL -->
</div>
<!-- / LAYOUT GRID -->
<p class="slds-text-body--small slds-m-top--x-small">COUNT items</p>
</div>
<!-- / PAGE HEADER -->
<!-- PRIMARY CONTENT WRAPPER -->
<div class="slds-form-element">
<label class="slds-form-element__label">Account Type</label>
<div class="slds-form-element__control">
<div class="slds-select_container">
<apex:selectList value="{!selectedVal}" size="1">
<apex:selectOption value="{!list}" />
</apex:selectList>
</div>
</div>
</div>
<!-- / PRIMARY CONTENT WRAPPER -->
<!-- FOOTER -->
<footer role="contentinfo" class="slds-p-around--large">
<!-- LAYOUT GRID -->
<div class="slds-grid slds-grid--align-spread">
<p class="slds-col">Salesforce Lightning Design System Example</p>
<p class="slds-col">© Your Name Here</p>
</div>
<!-- / LAYOUT GRID -->
</footer>
<!-- / FOOTER -->
</div>
<!-- / REQUIRED SLDS WRAPPER -->
</body>
<!-- JAVASCRIPT -->
<!-- / JAVASCRIPT -->
</html>
</apex:form>
</apex:page>
APEX Controller:
Public class example {
public String selectedVal{get;set;} // This will hold the selected value, the id in here
public List<SelectOption> getlist(){
List<SelectOption> optns = new List<SelectOption>();
// before getting here you must populate your queryResult list with required fields
for(SelectOption lstObj : [SELECT Id, Name FROM Listview WHERE SobjectType = 'Request__C' order by name ASC]){
optns.add(new SelectOption (lstObj.Name));
}
return optns;
}
}
Please Note : The requirement is creating the VF ONLY with SLDS.
I should create a Visualforce page by using SLDS with a dropdown list having all the custom list view names and a table which display the record's of the selected list view.
I have created the basics of VF page with SLDS but, not able to append the List view to dropdown and display the related list view records in a table.
Below is my code. Your help is highly appreciated.
VF Page:
<apex:page controller="example" showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
<apex:form>
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="{!URLFOR($Resource.SLDS100, 'styles/salesforce-lightning-design-system.css')}" />
</head>
<body>
<!-- REQUIRED SLDS WRAPPER -->
<div class="slds">
<!-- MASTHEAD -->
<p class="slds-text-heading--label slds-m-bottom--small">Salesforce Lightning Design System Module</p>
<!-- / MASTHEAD -->
<!-- PAGE HEADER -->
<div class="slds-page-header" role="banner">
<!-- LAYOUT GRID -->
<div class="slds-grid">
<!-- GRID COL -->
<div class="slds-col">
<!-- HEADING AREA -->
<p class="slds-text-heading--label">Accounts</p>
<h1 class="slds-text-heading--medium">My Accounts</h1>
<!-- /HEADING AREA -->
</div>
<!-- GRID COL -->
<div class="slds-col slds-no-flex slds-align-middle">
<div class="slds-button-group" role="group">
<button class="slds-button slds-button--neutral">
New Account
</button>
<button class="slds-button slds-button--neutral">
More
</button>
</div>
</div>
<!-- / GRID COL -->
</div>
<!-- / LAYOUT GRID -->
<p class="slds-text-body--small slds-m-top--x-small">COUNT items</p>
</div>
<!-- / PAGE HEADER -->
<!-- PRIMARY CONTENT WRAPPER -->
<div class="slds-form-element">
<label class="slds-form-element__label">Account Type</label>
<div class="slds-form-element__control">
<div class="slds-select_container">
<apex:selectList value="{!selectedVal}" size="1">
<apex:selectOption value="{!list}" />
</apex:selectList>
</div>
</div>
</div>
<!-- / PRIMARY CONTENT WRAPPER -->
<!-- FOOTER -->
<footer role="contentinfo" class="slds-p-around--large">
<!-- LAYOUT GRID -->
<div class="slds-grid slds-grid--align-spread">
<p class="slds-col">Salesforce Lightning Design System Example</p>
<p class="slds-col">© Your Name Here</p>
</div>
<!-- / LAYOUT GRID -->
</footer>
<!-- / FOOTER -->
</div>
<!-- / REQUIRED SLDS WRAPPER -->
</body>
<!-- JAVASCRIPT -->
<!-- / JAVASCRIPT -->
</html>
</apex:form>
</apex:page>
APEX Controller:
Public class example {
public String selectedVal{get;set;} // This will hold the selected value, the id in here
public List<SelectOption> getlist(){
List<SelectOption> optns = new List<SelectOption>();
// before getting here you must populate your queryResult list with required fields
for(SelectOption lstObj : [SELECT Id, Name FROM Listview WHERE SobjectType = 'Request__C' order by name ASC]){
optns.add(new SelectOption (lstObj.Name));
}
return optns;
}
}
Please Note : The requirement is creating the VF ONLY with SLDS.
I am not sure but what i think is we cannot query all the records that belongs to a specific list view.
What i can suggest you is , you can render whole list view using following code -
VF page -
Apex class-
May be this can help you further -
https://salesforce.stackexchange.com/questions/167009/can-we-access-all-listview-records-of-any-object-using-listview-id
I am able to render the list view to dropdown. But, when i am using the beow code with VF page, getting an error saying "'apex:enhancedList' component cannot be nested within form tags". Is ther anyway to overcome this.?
Apologies, I am newbie to salesforce, thats the reason asking so many questions.
<apex:outputPanel id="LeadList">
<apex:enhancedList type="Lead" height="300" rowsPerPage="25" customizable="False" listId="{!selectedVal}"/>
</apex:outputPanel>
Below is the code I am using.
<apex:page controller="TextVFPDFController" showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
<apex:form>
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="{!URLFOR($Resource.SLDS100, 'styles/salesforce-lightning-design-system.css')}" />
</head>
<body>
<!-- REQUIRED SLDS WRAPPER -->
<div class="slds">
<!-- MASTHEAD -->
<p class="slds-text-heading--label slds-m-bottom--small">Salesforce Lightning Design System Module</p>
<!-- / MASTHEAD -->
<!-- PAGE HEADER -->
<div class="slds-page-header" role="banner">
<!-- LAYOUT GRID -->
<div class="slds-grid">
<!-- GRID COL -->
<div class="slds-col">
<!-- HEADING AREA -->
<p class="slds-text-heading--label">Accounts</p>
<h1 class="slds-text-heading--medium">My Accounts</h1>
<!-- /HEADING AREA -->
</div>
<!-- GRID COL -->
<div class="slds-col slds-no-flex slds-align-middle">
<div class="slds-button-group" role="group">
<button class="slds-button slds-button--neutral">
New Account
</button>
<button class="slds-button slds-button--neutral">
More
</button>
</div>
</div>
<!-- / GRID COL -->
</div>
<!-- / LAYOUT GRID -->
<p class="slds-text-body--small slds-m-top--x-small">COUNT items</p>
</div>
<!-- / PAGE HEADER -->
<!-- PRIMARY CONTENT WRAPPER -->
<div class="slds-form-element">
<label class="slds-form-element__label">Request Type</label>
<div class="slds-form-element__control">
<div class="slds-select_container">
<apex:selectList value="{!selectedVal}" size="1">
<apex:selectOptions value="{!list}" >
</apex:selectOptions>
<apex:actionSupport event="onclick" reRender="LeadList"/>
</apex:selectList>
</div>
</div>
</div>
<!-- / PRIMARY CONTENT WRAPPER -->
<!-- FOOTER -->
<footer role="contentinfo" class="slds-p-around--large">
<!-- LAYOUT GRID -->
<div class="slds-grid slds-grid--align-spread">
<p class="slds-col">Salesforce Lightning Design System Example</p>
<p class="slds-col">© Your Name Here</p>
</div>
<!-- / LAYOUT GRID -->
</footer>
<!-- / FOOTER -->
</div>
<!-- / REQUIRED SLDS WRAPPER -->
</body>
<!-- JAVASCRIPT -->
<!-- / JAVASCRIPT -->
</html>
</apex:form>
<apex:outputPanel id="LeadList">
<apex:enhancedList type="Lead" height="300" rowsPerPage="25" customizable="False" listId="{!selectedVal}"/>
</apex:outputPanel>
</apex:page>
Do this -
Keep other items out of apex form so that you can put outputpanel anywhere.
Are you still getting any issue? isnt it working for you? what exactly are you getting? can you share apex class too?
As you mentioned, I have changed the FORM tag.
Now I am facing error as "<apex:enhancedList> component cannot be included when <apex:page> 'showHeader' attribute is false". After I have turned the attribute of 'showheader' and 'applyHtmlTag' to true, VF page displays "Invalid selectOptions found. Use SelectOption type in Apex. "
VF page coding:
<apex:page controller="TextVFPDFController" showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="{!URLFOR($Resource.SLDS100, 'styles/salesforce-lightning-design-system.css')}" />
</head>
<body>
<!-- REQUIRED SLDS WRAPPER -->
<div class="slds">
<!-- MASTHEAD -->
<p class="slds-text-heading--label slds-m-bottom--small">Salesforce Lightning Design System Module</p>
<!-- / MASTHEAD -->
<!-- PAGE HEADER -->
<div class="slds-page-header" role="banner">
<!-- LAYOUT GRID -->
<div class="slds-grid">
<!-- GRID COL -->
<div class="slds-col">
<!-- HEADING AREA -->
<p class="slds-text-heading--label">Accounts</p>
<h1 class="slds-text-heading--medium">My Accounts</h1>
<!-- /HEADING AREA -->
</div>
<!-- GRID COL -->
<div class="slds-col slds-no-flex slds-align-middle">
<div class="slds-button-group" role="group">
<button class="slds-button slds-button--neutral">
New Account
</button>
<button class="slds-button slds-button--neutral">
More
</button>
</div>
</div>
<!-- / GRID COL -->
</div>
<!-- / LAYOUT GRID -->
<p class="slds-text-body--small slds-m-top--x-small">COUNT items</p>
</div>
<!-- / PAGE HEADER -->
<!-- PRIMARY CONTENT WRAPPER -->
<div class="slds-form-element">
<label class="slds-form-element__label">Request Type</label>
<div class="slds-form-element__control">
<div class="slds-select_container">
<apex:form>
<apex:selectList value="{!selectedVal}" size="1">
<apex:selectOption value="{!list}" />
</apex:selectList>
</apex:form>
<apex:actionSupport event="onclick" reRender="LeadList"/>
</div>
</div>
</div>
<!-- / PRIMARY CONTENT WRAPPER -->
<!-- FOOTER -->
<footer role="contentinfo" class="slds-p-around--large">
<!-- LAYOUT GRID -->
<div class="slds-grid slds-grid--align-spread">
<p class="slds-col">Salesforce Lightning Design System Example</p>
<p class="slds-col">© Your Name Here</p>
</div>
<!-- / LAYOUT GRID -->
</footer>
<!-- / FOOTER -->
</div>
<!-- / REQUIRED SLDS WRAPPER -->
</body>
<!-- JAVASCRIPT -->
<!-- / JAVASCRIPT -->
</html>
<apex:outputPanel id="LeadList">
<apex:enhancedList type="Lead" height="300" rowsPerPage="25" customizable="False" listId="{!selectedVal}"/>
</apex:outputPanel>
</apex:page>
Apex Class:
public class TextVFPDFController {
public String selectedVal{get;set;} // This will hold the selected value, the id in here
public List<SelectOption> getlist(){
List<SelectOption> optns = new List<SelectOption>();
// before getting here you must populate your queryResult list with required fields
for(Listview lstObj : [SELECT Id, Name FROM Listview WHERE SobjectType = 'Lead' order by name ASC]){
String listId = lstObj.Id;
listId = listId.subString(0,15);
if(selectedVal == null){
selectedVal = listId;
}
optns.add(new SelectOption (listId,lstObj.Name));
}
return optns;
}
}
Though, if its possible with lightning component instead VF page. Please help me out with process.
You can use this. inside lightning component. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_listView.htm
Is it possible to show all the list view and related records with the lightinng componet?
once user choose anything in picklist, change "listName" in <lightning:listView > to show its records.
Thanks for your help so far. But I havent completed the requirement.
Currently I am using the lightning component to display the listview and record details. But, not able to perform inline editing to the records and also view the lighting component in app. It throws an error "You don't have access to this record. Ask your administrator for help or to request access.".
I am just wondering, what acces I dont have and where I look into. Below is my code.
Lightning Component
<aura:component controller="Request_Inline_Edit" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
<ltng:require styles="/resource/slds0121/assets/styles/salesforce-lightning-design-system.min.css"/>
<ltng:require styles="{!$Resource.SLDS +
'/assets/styles/salesforce-lightning-design-system.css'}"/>
<aura:dependency resource="markup://force:navigateToList" type="EVENT"/>
<aura:handler name="init" value="{!this}" action="{!c.gotoList}"/>
</aura:component>
Component Controller:
({
gotoList : function (component, event, helper) {
var action = component.get("c.getListViews");
action.setCallback(this, function(response){
var state = response.getState();
console.log('clicked');
if (state === "SUCCESS") {
var listviews = response.getReturnValue();
var navEvent = $A.get("e.force:navigateToList");
navEvent.setParams({
"listViewId": listviews.Id,
"listViewName": null,
"scope": "Request__C"
});
navEvent.fire();
}
});
$A.enqueueAction(action);
},
})
Apex Class:
public class Request_Inline_Edit {
@AuraEnabled
public static List<ListView> getListViews() {
List<ListView> listviews =
[SELECT Id, Name FROM ListView WHERE SobjectType = 'Request__C' limit 5];
return listviews;
}
}