Skip to main content

Easy way to display alias in Grid?

Comments

1 comment

  • Dapfor Team

    Hello,

    The best way is to create your custom format:

     

    class MyFormat : IFormat
    {
        public string Format(IDataField dataField)
        {
            int value = (int) dataField.Value;
            switch(value)
            {
                case 1: return "Male";
                case 2: return "Female";
                case 3: return "Not set yet";
                default: return "Undefined case";
            }
        }

        public bool CanParse(string text, IDataField dataField)
        {
            return false;
        }

        public void Parse(string text, IDataField dataField)
        {
            //Implement this method if you want to use editors
        }
    }

     

    There are multiple ways to apply this format:

    public class MyCustomObject
    {
    [Format(typeof(MyFormat))]
        public int Gender { get; set; }
    }

    or

    column.Format = new MyFormat();

     

    Best regards,

    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk