You need to sign in to do that
Don't have an account?
Vempally
not able to display selected list values into data table of VF
Iam trying to display the selected list of records into the data table. there is no error invoked but still the data is not visible...
here is the code
<apex:page standardController="Product__c" extensions="prosearch">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Select Department</apex:outputLabel>
<apex:selectList value="{!selecteddept}" size="1">
<apex:selectOptions value="{!deptitems}" rendered="true" />
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:commandButton id="search" Value="search" action="{!search}"/>
<apex:outputPanel >
<apex:outputtext value="{!selecteddept}"></apex:outputtext>
<apex:datatable value="{!searchlist}" var="a" id="theTable" title="Iam HERE" >
<apex:facet name="retrieved">We Have The Following Products</apex:facet>
<apex:column >
<apex:facet name="ProductName">Product Name</apex:facet>
<apex:outputtext value="{!a.Product_Name__c}"/>
</apex:column>
<apex:column >
<apex:facet name="ProductPrice">Product Price</apex:facet>
<apex:outputText value="{!a.Price__c}"/>
</apex:column>
</apex:datatable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
here is the apex code
public with sharing class prosearch {
public prosearch(ApexPages.StandardController controller) {
}
public List<Product__c> searchlist{set; get;}
public string selectedDept{set;get;}
public string productname{ set; get;}
public decimal productprice{ set;get;}
public string productimage{ set;get;}
public string getselectedDept(){
return selecteddept;
}
public void setselecteddept() {
this.selecteddept = selecteddept;
}
public string deptItems{set; }
public List<SelectOption> getdeptItems() {
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =Product__c.Product_department__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return Options;
}
public pagereference search(){
return null;
}
public List<Product__c> searchproduct(){
List<Product__c> searchlist = new List<Product__c>();
searchlist = [select Product_Name__c,Price__c,Product_Image__c from Product__C where product_department__C =: selecteddept];
return searchlist;
}
}
here is the code
<apex:page standardController="Product__c" extensions="prosearch">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Select Department</apex:outputLabel>
<apex:selectList value="{!selecteddept}" size="1">
<apex:selectOptions value="{!deptitems}" rendered="true" />
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:commandButton id="search" Value="search" action="{!search}"/>
<apex:outputPanel >
<apex:outputtext value="{!selecteddept}"></apex:outputtext>
<apex:datatable value="{!searchlist}" var="a" id="theTable" title="Iam HERE" >
<apex:facet name="retrieved">We Have The Following Products</apex:facet>
<apex:column >
<apex:facet name="ProductName">Product Name</apex:facet>
<apex:outputtext value="{!a.Product_Name__c}"/>
</apex:column>
<apex:column >
<apex:facet name="ProductPrice">Product Price</apex:facet>
<apex:outputText value="{!a.Price__c}"/>
</apex:column>
</apex:datatable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
here is the apex code
public with sharing class prosearch {
public prosearch(ApexPages.StandardController controller) {
}
public List<Product__c> searchlist{set; get;}
public string selectedDept{set;get;}
public string productname{ set; get;}
public decimal productprice{ set;get;}
public string productimage{ set;get;}
public string getselectedDept(){
return selecteddept;
}
public void setselecteddept() {
this.selecteddept = selecteddept;
}
public string deptItems{set; }
public List<SelectOption> getdeptItems() {
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =Product__c.Product_department__c.getDescribe();
List<Schema.picklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.picklistEntry f:ple)
{
options.add(new selectOption(f.getLabel(),f.getValue()));
}
return Options;
}
public pagereference search(){
return null;
}
public List<Product__c> searchproduct(){
List<Product__c> searchlist = new List<Product__c>();
searchlist = [select Product_Name__c,Price__c,Product_Image__c from Product__C where product_department__C =: selecteddept];
return searchlist;
}
}
call controller method in your VF page...
Thanks,
Rockzz
All Answers
try below code...
Thanks,
Rockzz
thanks for your respone...
but the searchlist should contain the products based on the department selected.
In such a case we cannot avoid the where clause...
call controller method in your VF page...
Thanks,
Rockzz
THANKS A LOT......