[SalesForce] Visualforce input type date picker field

I am using date type field as Input type where serviceAssetItem is an instance of a wrapper class as follows:

<apex:pageBlockTable value="{!ServiceAsset}" var="serviceAssetItem" id="assetListTable">
<apex:column headerValue="Sales Date">
    <apex:input type="date" value="{!serviceAssetItem.SalesDate}"/>
</apex:column>
</apex:pageBlockTable>

Sales Date field is displaying as follows:

Sales Date

If I have SObject like objServiceAsset, then using below code 'Sales Date` is showing like this.

<apex:pageBlock title="Add Item">
<apex:pageBlockSection>
    <apex:inputField value="{!objServiceAsset.Sales_Date__c}"/>
</apex:pageBlockSection>

SFDC Date Picker

How can I have this SFDC date picker to be displayed in my first example where the object instance is not of SOBject.

Best Answer

You might go to jQuery UI path as mentioned Adrian, but quite a bit of work to be honest. It's a bit ugly, but you could maybe use an existing custom object in your wrapper class that have a date field then populate that to your serviceAssetItem.SalesDate in the get method. So in the page you would use inputField as per normal sobject but you don't use serviceAssetItem.SalesDate you would use the date of your custom object in your warepper class.

Controller

public class MyWrapperClass{
   public String Name {get; set;}
   public Date SalesDate {get{ return dummy.My_Date__c;} set;}
   public MyObject__c dummy {get; set;}
}

Page

<apex:inputField value="{!serviceAssetItem.dummy.My_Date__c}"/>
Related Topic