How to set a string message when DateTime is default.

Hello,

I have a tablle with columns like startDate and finishedDate of some service. If Service is not finnished I received default DateTime - 01/01/0001 from the database. I would like to display a string like "in progress" or "not finished" etc. Insted Of 01/01/0001.


With best regards Jarosalaw


5 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team August 27, 2021 09:32 AM UTC

Hi Jaroslaw, 
 
Greetings from Syncfusion support. 
 
We have checked your query but we are quite unclear about your exact requirement. So kindly share us the below details, 
 
  1. Kindly share more information about your query.
  2. If the service is not completed then how will it return the default datetime?
  3. Share us a video demo showing the problem you are facing.
  4. Kindly share us the sample if possible.
 
The above requested details will be helpful for us to validate your query and to provide you with a better solution as early as possible. 
 
Regards. 
Jeevakanth SP. 



JB Jaroslaw Bolejko August 27, 2021 11:26 AM UTC

Hello,


Thank you for your quick reply.

1.In the table two of the columns are DateTime  - ReceivedDate and IssuedDate. When a new comission is being opend the value in  ReceiveDate is DateTime.Now and in IssuedDate is null. 

On the front-end (blazor) I would like to display a string value (e.g. "In Progress")  instead of blank space.

How I could do it?

2. A default value it was my mistake, I was paasing default value  to the back-end. Now its null value.

4.

<SfGrid DataSource="@Laundries" AllowPaging="true">

    <GridPageSettings PageSize="10" PageCount="5" PageSizes="@pagerDropdown"></GridPageSettings>

    <GridColumns>

        <GridColumn Field=@nameof(LaundryService.Id) HeaderText="ID"></GridColumn>

        <GridColumn Field=@nameof(LaundryService.Name) HeaderText="Service Name"></GridColumn>

        <GridColumn Field=@nameof(LaundryService.Number) HeaderText="Number"></GridColumn>

        <GridColumn Field=@nameof(LaundryService.RecievedDate) Format="d" HeaderText="Recieved Date"></GridColumn>

        <GridColumn Field=@nameof(LaundryService.IssuedDate) Format="d" HeaderText="Issued Date*"></GridColumn>

        <GridColumn Field=@nameof(LaundryService.IsFinished) HeaderText="Is Finished"></GridColumn>

    </GridColumns>

</SfGrid>


With best regards Jarosław


Attachment: blazor_ec614da3.rar


JP Jeevakanth Palaniappan Syncfusion Team August 30, 2021 09:50 AM UTC

Hi Jaroslaw, 
 
Thanks for sharing the details. You can achieve your requirement by using the column template feature of the grid. Please refer the below code snippet and the documentation for your reference. 
 
 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"> 
            <Template> 
                @{  
                    var con = context as Order; 
                    if (con.OrderDate == null) 
                    { 
                    <span>Inprogress</span> 
                    } 
                    else { 
                    <span>@(String.Format("{0:d}", con.OrderDate))</span>                         
                    } 
                } 
            </Template> 
        </GridColumn> 
 
Get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



Marked as answer

JB Jaroslaw Bolejko August 30, 2021 10:24 AM UTC

Thank you! It works perfectly.


With best regards

Jarosław Bolejko



JP Jeevakanth Palaniappan Syncfusion Team August 31, 2021 05:44 AM UTC

Hi Jaroslaw, 
 
We are glad that the provided solution achieved your requirement Get back to us if you have any other queries. 
 
Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon