webdrawer change DateCreated format in detailsview page

How change the "DateCreated" field format in detailsview page. Currently it shows like "Thursday, 21 November 2024 at 5:05 PM", but i want to show like "dd/MM/yyyy" only. 

Thanks,

Sarath.

Parents Reply Children
  • Verified Answer

    +1   in reply to 

    Hi Sarath,

    Apologies - I missed that as part

    Yep you can do it my modifying the underlying Razor page (Below is from my 23.4 demo machine)

    Open up the file ..\Content Manager\WebDrawer\Views\Shared\propertyRow.cshtml in your favourite notepad editor

    Scroll down to the below block of code (around line 40 something)

    else if (searchClause != null)
    {
    	<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    		<span class="prop-val">@valString</span>
    	</a>                
    }

    and change it to

    else if (searchClause != null)
    {
    	if (Model.pfdef.PFFormat == PropertyOrFieldFormat.Datetime)
    	{
    		// Remove the word "at" from the string
    		string cleanedValString = valString.Replace(" at ", " ");
    	
    		DateTime parsedDate;
    		if (DateTime.TryParse(cleanedValString, out parsedDate))
    		{
    			<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    				<span class="prop-val">@parsedDate.ToString("dd/MM/yyyy")</span>
    			</a>
    		}
    		else
    		{
    			<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    				<span class="prop-val">Invalid Date</span>
    			</a>
    		}    
    	}
    	else
    	{
    		<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    			<span class="prop-val">@valString</span>
    		</a>                
    	}							
    }

    This should then update any 'clickable' DateValues (those bound to searches) showing in the details pane in WebDrawer from

    to

    You can update the bottom 'else' clause to handle 'Non Clickable' dates as well (Eg. Date Due for Destruction in the Archiving slider)

    else
    {
    	<span class="prop-val">@valString</span>              
    }

    becomes

    else
    {
    	if (Model.pfdef.PFFormat == PropertyOrFieldFormat.Datetime)
    	{
    		// Remove the word "at" from the string
    		string cleanedValString = valString.Replace(" at ", " ");
    	
    		DateTime parsedDate;
    		if (DateTime.TryParse(cleanedValString, out parsedDate))
    		{
    			<span class="prop-val">@parsedDate.ToString("dd/MM/yyyy")</span>
    		}
    		else
    		{
    			<span class="prop-val">Invalid Date</span>
    		}    
    	}
    	else
    	{
    		 <span class="prop-val">@valString</span>              
    	}	            
    }

    which changes

    to

    Haven't thoroughly checked with all properties so your mileage may vary slightly.

    -Scotty