I want to display blank fields if there are no records returned.
Now it is returning null like below -
Apex Class -
public with sharing class wrapper_test_controller {
public list<wrapperclass> wrapperelement_for_account{get;set;}
public list<wrapperclass> wrapperelement_for_contact{get;set;}
public string selectedproductfamily {get;set;}
public list<product2> queryResult{get;set;}
public list<Work_Order_Item__c> queryResult1{get;set;}
public List<wrapperclass> lstobjfields
{
get;
set;
}
public PageReference query() {
system.debug('@@@'+selectedproductfamily);
String qryString = 'SELECT Id,name,family,Measurement_Type__c,Cleaning_Unit_Price__c,Treatment_Unit_Price__c,(select Service__c,Quantity__c,Length__c,Width__c from work_order_items__R) FROM product2 WHERE ' +
'(Family like \'%' + selectedproductfamily + '%\')';
queryResult = Database.query(qryString);
return null;
}
public wrapper_test_controller (ApexPages.StandardController controller) {
}
public class wrapperclass{
public String name { get; set; }
public Integer data { get; set; }
public Product2 account {get;set;}
public Work_Order_Item__c service {get;set;}
public wrapperclass(String Name,Integer data) {
this.name = Name;
this.data = data;
}
public wrapperclass (Work_Order_Item__c record){
this.service = record;
}
public wrapperclass (Product2 record1){
this.account= record1;
}
public wrapperclass (Work_Order_Item__c a, Product2 mh)
{
service = a;
account = mh;
}
}
}
VF Page -
<apex:page standardController="Work_Order__c" extensions="wrapper_test_controller">
<apex:form >
<apex:pageblock id="pb">
</apex:pageblockSection>
<apex:pageblocksection title="Products" >
<apex:outputPanel title="Family">
<apex:outputLabel value="Family:">
<apex:actionRegion >
<apex:selectList value="{!selectedproductfamily}" size="1" label="Family" rendered="true" >
<apex:actionSupport action="{!query}" reRender="pb1" id="fam" event="onchange"/>
<apex:selectOptions value="{!productfamily}" />
</apex:selectList>
</apex:actionRegion>
</apex:outputLabel>
</apex:outputPanel>
</apex:pageblocksection>
<apex:pageblocktable value="{!queryResult}" var="acc" id="pb1">
<apex:column >
<apex:facet name="header">Name</apex:facet>
<apex:outputfield value="{!acc.Name}" />
</apex:column>
<apex:column headervalue="Family">
<apex:outputfield value="{!acc.Family}" />
</apex:column>
<apex:column headervalue="Measurement Type">
<apex:outputfield value="{!acc.Measurement_Type__c}" />
</apex:column>
<apex:column headervalue="Treatment Price">
<apex:outputfield value="{!acc.Treatment_Unit_Price__c}" />
</apex:column>
<apex:column headervalue="Cleaning Unit Price">
<apex:outputfield value="{!acc.Cleaning_Unit_Price__c}" />
</apex:column>
<apex:column headerValue="Service">
<apex:repeatvalue="{!acc.work_order_items__R}" var="b">
<apex:inputfield value="{!b.Service__c}"/>
</apex:repeat>
</apex:column>
<apex:column headerValue="Quantity">
<apex:repeat value="{!acc.work_order_items__R}" var="b">
<apex:inputfield value="{!b.Quantity__c}"/>
</apex:repeat>
</apex:column>
<apex:column headerValue="Length">
<apex:repeat value="{!acc.work_order_items__R}" var="b">
<apex:inputfield value="{!b.Length__c}"/>
</apex:repeat>
</apex:column>
<apex:column headerValue="Width">
<apex:repeat value="{!acc.work_order_items__R}" var="b">
<apex:inputfield value="{!b.Width__c}"/>
</apex:repeat>
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>
[![enter image description here][2]][2]