How do I set the default date

Hi,

If a date field has no value and the user enters it the date picker shows but defaults to year one. How do I get it to default to today with out using minimum date?

Thanks
Richard

13 Replies

JN Jayaleshwari N Syncfusion Team August 30, 2018 11:53 AM UTC

Hi Richard,  
  
We have checked your requirement for displaying current date time (today) without setting value to the DatePicker. In SfDataForm, DateTime will be displayed based on the value given in DateTime property type or based on the selected date in the date picker header.  
You can set null value to DateTime (instead of DateTime default value) such that current date will be displayed in the date picker.  
  
Code snippet  
  
  
  private DateTime? displayDate;  
       
        public DateTime? DisplayDate  
        {  
            get { return displayDate; }  
            set { displayDate = value; }  
        }  
  
  
Sample:  DatePickerSample
  
Please let us know provided solution meets your requirement. 
 
Regards, 
Jayaleshwari N. 



BE Ben September 4, 2018 02:30 AM UTC

Hi,

If I use the below in a data model tied to SQLLite

 public DateTime? SomeDate { get; set; }

The date picker in Android is still set to 01/01/01 when it pops up.

Thanks 
Richard


JN Jayaleshwari N Syncfusion Team September 5, 2018 12:18 PM UTC

Hi Richard,  
  
We have checked your requirement for displaying current date time (today) without setting value to the DatePicker with SQLite in sample level for Xamarin Forms Android. We are not able to reproduce the issue from our side. We have set null value to DateTime (instead of DateTime default value) as mentioned by you and current date is displayed in the date picker as expected.  
  
   public int ID { get; set; }  
   public string Name { get; set; }  
   public DateTime? SomeDate { get; set; }  
  
  ViewModel = new ViewModel();  
  dataForm.DataObject = ViewModel.OrderItemCollection[0];  
  
    public class ViewModel  
    {  
        SQLiteConnection database;  
        ObservableCollection<OrderItem> orderItemCollection;  
        ObservableCollection<OrderItem> OrderList;  
        public ObservableCollection<OrderItem> OrderItemCollection  
        {  
            get  
            {  
                if (orderItemCollection == null)  
                {  
                    GetItems();  
                    orderItemCollection = OrderList;  
                }  
                return orderItemCollection;  
            }  
        }  
         
        public ViewModel()  
        {  
  
            database = DependencyService.Get<ISQLite>().GetConnection();  
            // Create the table  
            database.CreateTable<OrderItem>();  
            database.Query<OrderItem>("INSERT INTO OrderItem (ID,Name,SomeDate)values (1002,'Blake',null)");  
            database.Query<OrderItem>("INSERT INTO OrderItem (ID,Name,SomeDate)values (1003,'Catherine',null)");  
            database.Query<OrderItem>("INSERT INTO OrderItem (ID,Name,SomeDate)values (1004,'Jude',null)");  
        }  
  
        public async void GetItems()  
        {  
            // Changing the database table items as ObservableCollection  
            var table = (from i in database.Table<OrderItem>() select i);  
  
            OrderList = new ObservableCollection<OrderItem>();  
  
            foreach (var order in table)  
            {  
                OrderList.Add(new OrderItem()  
                {  
                    ID = order.ID,  
                    Name = order.Name  
                });  
            }  
            await Task.Delay(2000);  
             
        }  
    }  
  
  
Sample: DataForm_SampleDemo
 
 
  
Screenshot:  
   

Kindly check with the provided sample and if still issue prevails, could you please revert us back with modifying the provided sample with more information and issue reproducing scenario. It will be helpful for us to analyze on it and provide you better solution. 
 
 
Regards, 
Jayaleshwari N. 



BE Ben September 27, 2018 09:03 AM UTC

I have finally had a chance to revisit this issue and it is working as you described (I could have sworn it wasn't earlier).




JN Jayaleshwari N Syncfusion Team September 27, 2018 11:42 AM UTC

Hi Richard 

Thanks for the update. Please get in touch if you would require further assistance. 

Regards, 
Jayaleshwari N 



AD Anibal de Deus February 6, 2019 09:41 PM UTC

Hey, I'm having a similar issue, but on iOS. In Android it works ok, suggesting today's date, but on iOS, the default date when null is 01/01/0001.

Another issue I'm having is that using SfDataForm inside an SfTabView as the third tab, whenever I try to edit a field, the selected tab goes back to the first. This problem happens only in Android (Motorola Z2 Force - 8.0.0)

I'm using latest version as today: 16.4.0.52


SG Swathi Gopal Syncfusion Team February 7, 2019 12:09 PM UTC

Hi Anibal, 
 
Thanks for contacting Syncfusion Support.  
 
Currently we are analyzing your below queries related to SfDataForm. 
 
1.       The default date when null is 01/01/0001 in Xamarin Forms iOS. 
2.       Including SfDataForm inside an SfTabView as the third tab, and when try to edit a field, the selected tab goes back to the first in Xamarin Forms Android. 
 
 We will analyze and update you the complete details in two business days (Feb 11th,2019). We appreciate your patience until then. 
 
Regards, 
Swathi G 



SG Swathi Gopal Syncfusion Team February 11, 2019 01:04 PM UTC

Hi Anibal, 
 
Regarding query : The default date when null is 01/01/0001 in Xamarin Forms iOS.  
 
We have validated the defect you have initiated with us. Thank you for taking the time to report this issue with the default date when null is 01/01/0001 in Xamarin Forms iOS and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our subsequent Volume 1,2019 release, which is expected to be available by mid of March, 2019.If you wish to receive this fix in a specific prior release product version please contact  Syncfusion Support (backwards compatibility  subject to technological feasibility and our Support SLA).You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link   
  
 
Regarding query: Including SfDataForm inside an SfTabView as the third tab, and when try to edit a field, the selected tab goes back to the first in Xamarin Forms Android.  
 
We have checked your query with Including SfDataForm inside an SfTabView as the third tab, and when try to edit a field, the selected tab goes back to the first in Xamarin Forms Android. We suspect that the issue is related with SfTabView control and not with SfDataForm control. We are checking this from our side and have forwarded it internally to the concerned team also. We will analyze and update you the details in two business days (Feb 13,2019) We appreciate your patience until then. 
 
Regards,
Swathi G
 




JN Jayaleshwari N Syncfusion Team February 12, 2019 06:23 AM UTC

Hi Anibal,  
  
Sorry for the inconvenience caused.  
  
Could you please check this link, whether it is accessible for you now?   
  
Regards 
Jayaleshwari N. 



AD Anibal de Deus February 12, 2019 11:33 AM UTC

It still present 404 to me.


JN Jayaleshwari N Syncfusion Team February 13, 2019 11:39 AM UTC

Hi Anibal,   
   
Sorry for the inconvenience caused.   
   
We have modified the settings of feedback link to access. Could you please check this link, whether it is accessible for you now?    
 
# Regarding query: Including SfDataForm inside an SfTabView as the third tab, and when try to edit a field, the selected tab goes back to the first in Xamarin Forms Android.   
 
The reported issue has been fixed and it will eb included in our coming weekly nuget release which is expected to be available within this weekend (February 2nd week, 2019). We will let you know once the nuget is published. 
 
Regards  
Jayaleshwari N.  



JN Jayaleshwari N Syncfusion Team February 14, 2019 06:22 AM UTC

Hi Anibal, 
  
We are glad to announce that our latest weekly NuGet package update version 16.4.0.53 has been rolled out with the fix included for the issue “Including SfDataForm inside an SfTabView as the third tab, and when try to edit a field, the selected tab goes back to the first in Xamarin Forms Android” and is available for download. 
 
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance. 
  
Regards, 
Jayaleshwari N 


Loader.
Up arrow icon