We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

public bool HasErrors is showing in the form

Hi, thanks for reading. Please help a newbie...
How do I set this property so it doesn't show in the form? How can I annotate to say do not show??
Thanks,
B


5 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team May 6, 2019 08:49 AM UTC

Hi Brian, 
 
Thank you for contacting Syncfusion support. 
 
Your requirement of disabling or cancel the specific DataFormItem adding to the data by handling the AutoGeneratingDataFormItemevent or by defining display attribute to avoid the particular data field being displayed. You can set AutoGenerateField to false for cancelling the DataForm item.

Please refer the following code example, 
 
[C#] 
[private int id;  
[Display(AutoGenerateField = false)]  
public int ID  
{  
          get { return id; }  
          set { id = value; RaisePropertyChanged("ID"); }  
} 
 

You can refer our User Guide documentation regarding the same by the following link, 
 
 
Regards,
Subburaj Pandian V
 



BA Brian Adams May 7, 2019 11:07 PM UTC

Hi, This is what I thought too but no matter what fields I tag this with they still show up.   This is the POCO and you can see I've put this annotation a few properties and yet they still show up.  Am I referring to the correct libraries? 

Thank you,




using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;



namespace GohfrAPI.Extentions
{
    public class CustomerAddress : INotifyDataErrorInfo, INotifyPropertyChanged
    {
        private string locationName;
        private string pointOfContact;
        private string phoneNumber;
        private string address;
        private string address2;
        private string city;
        private string state;
        private string zip;
        private string e;

        public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;

        public CustomerAddress()
        {
        }


        [Required(AllowEmptyStrings = false, ErrorMessage = "Name is required.")]
        public string LocationName { get => locationName; set => locationName = value; }


        public string PointOfContact { get => pointOfContact; set => pointOfContact = value; }


        public string PhoneNumber { get => phoneNumber; set => phoneNumber = value; }

        [Required(AllowEmptyStrings = false, ErrorMessage = "Address is required.")]
        public string Address { get => address; set => address = value; }


        public string Address2 { get => address2; set => address2 = value; }

        [Required(AllowEmptyStrings = false, ErrorMessage = "City is required.")]
        public string City { get => city; set => city = value; }

        [Required(AllowEmptyStrings = false, ErrorMessage = "State is required.")]
        public string State { get => state; set => state = value; }

        [Display(AutoGenerateField = false)]
        public string Zip { get => zip; set => zip = value; }


         
        [Display(AutoGenerateField = false)]
        public bool HasErrors
        {
            get {    

                if(string.IsNullOrEmpty(Zip))
                {
                    return true;
                }
            return false;
            } 

        }
        [Display(AutoGenerateField = false)]
        public object MyProperty
        {
            get;
            private set;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        [Display(AutoGenerateField = false)]
        public IEnumerable GetErrors(string propertyName)
        {
            List<string> errors = new List<string>(); 


            return errors;
        }

    }
}



SP Subburaj Pandian Veluchamy Syncfusion Team May 8, 2019 09:10 AM UTC

Hi Brian, 
  
Thank you for the update. 
  
We have analyzed the reported issue “The Display attributes in DataForm doesn’t work as expected” and you have used the System.ComponentModel.DataAnnotation assembly to get the Display attributes which doesn’t work with DataForm. We have implemented these attributes with DataForm control itself, hence you need to refer the Syncfusion.SfDataForm.XForm assembly to use the Display attributes in DataForm.  
 
We have prepared a sample based on the shared code snippet, 
  
Sample link: DataForm 
  
Kindly refer our UG documentation for more information about the Display attributes in DataForm, by referring the following link, 
  
  
We hope that this helps. Kindly revert us if you have any concern. 
 
Regards,
Subburaj Pandian V  



BA Brian Adams May 10, 2019 06:39 AM UTC

Hello, thank you! Yes, makes sense now but thank you for helping with such a simple fix.  My POCO's are in a model project and did not have any SF assemblies in NuGet so VS suggested the Component assembly and I didn't know better.   

Thanks again!
B




SP Subburaj Pandian Veluchamy Syncfusion Team May 10, 2019 09:27 AM UTC

Hi Brian,  
   
Thank you for the update. 

For implementing this support, we need to provide .Net standard 2.0 support, now it is referring from SfDataForm .Net standard 1.0. We have considered provide this support and it will be included along with .Net standard 2.0 support. We will let you know once it is implemented and appreciate your patience until then. 
 
You can now track the status of this by the following feedback link, 
 
 
Regards,
Subburaj Pandian V   


Loader.
Live Chat Icon For mobile
Up arrow icon