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
close icon

How can we allow the display of text enum?

hi,
An example  Personage Type area  enum type and  number is kept in the database. PersonageType  area available for selection is desired to be edited by opening dropdown. But it is not the number  value during imaging, we provide how to display the text enum?
Best Regars
Irfan, 

Attachment: EnumExample_b7e3df98.zip

4 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team June 29, 2016 11:53 AM UTC

Hi Irfan, 

Thanks for contacting Syncfusion support.   
  
We created a sample in enum with Grid column control. In this sample, we have converted enum values to a list of objects.   
  
Find the code example:   
 
 
public ActionResult GridFeatures() 
        { 
            ViewData["EmployeeID"] = EmployeeID; 
            return View(); 
        } 
 
        public List<object> EmployeeID 
        { 
 
            get 
            { 
                var EmployeeID = new List<object>(); 
                Array itemNames = System.Enum.GetNames(typeof(UnitOfMeasure)); 
                foreach (String name in itemNames) 
                { 
                    Int32 value = (Int32)Enum.Parse(typeof(UnitOfMeasure), name); 
                    ListItem listItem = new ListItem(name, value.ToString()); 
                    EmployeeID.Add(new { value = listItem.Value, text = listItem.Text }); 
                } 
                return EmployeeID; 
            } 
        } 
 
        public enum UnitOfMeasure 
        { 
 
            Nr = 0, 
 
            Kg = 1, 
 
            g = 2, 
 
            l = 3 
        } 
 
After converting the list of objects, we have bounded those values as a DataSource for the DropDown column  


<script type="text/javascript"> 
    var data =   @(Html.Raw(Json.Encode(ViewData["EmployeeID"]))); 
    $(function () { 
        ----------------------------------------- 
           allowPaging: true, 
            editSettings: { allowEditing: true }, 
            actionComplete : "complete", 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
            columns: [ 
                     { field: "DropDown", headerText: "Drop Down", textAlign: "center", width: 110, editType: ej.Grid.EditingType.Dropdown, dataSource: data }, 
                     ---------------------------- 
           ] 
        }); 
    }); 
     
</script> 


Regards, 
Prasanna Kumar N.S.V 
 



IA Irfan Alkan replied to Prasanna Kumar Viswanathan July 1, 2016 08:33 AM UTC

Hi Irfan, 

Thanks for contacting Syncfusion support.   
  
We created a sample in enum with Grid column control. In this sample, we have converted enum values to a list of objects.   
  
Find the code example:   
 
 
public ActionResult GridFeatures() 
        { 
            ViewData["EmployeeID"] = EmployeeID; 
            return View(); 
        } 
 
        public List<object> EmployeeID 
        { 
 
            get 
            { 
                var EmployeeID = new List<object>(); 
                Array itemNames = System.Enum.GetNames(typeof(UnitOfMeasure)); 
                foreach (String name in itemNames) 
                { 
                    Int32 value = (Int32)Enum.Parse(typeof(UnitOfMeasure), name); 
                    ListItem listItem = new ListItem(name, value.ToString()); 
                    EmployeeID.Add(new { value = listItem.Value, text = listItem.Text }); 
                } 
                return EmployeeID; 
            } 
        } 
 
        public enum UnitOfMeasure 
        { 
 
            Nr = 0, 
 
            Kg = 1, 
 
            g = 2, 
 
            l = 3 
        } 
 
After converting the list of objects, we have bounded those values as a DataSource for the DropDown column  


<script type="text/javascript"> 
    var data =   @(Html.Raw(Json.Encode(ViewData["EmployeeID"]))); 
    $(function () { 
        ----------------------------------------- 
           allowPaging: true, 
            editSettings: { allowEditing: true }, 
            actionComplete : "complete", 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
            columns: [ 
                     { field: "DropDown", headerText: "Drop Down", textAlign: "center", width: 110, editType: ej.Grid.EditingType.Dropdown, dataSource: data }, 
                     ---------------------------- 
           ] 
        }); 
    }); 
     
</script> 


Regards, 
Prasanna Kumar N.S.V 
 


Hi Prasanna,
Download and run the example you have given.  There are similar problems also in this case. To better understand clearly the problem  the first question we give out samples we expect a similar result in  as attached picture.

Standart HTML.DropDown helper able to produce the result we want.  As can be seen in the picture it should appear in the text of the line in the enum list. User selection via dropdown  value should be set as 1-2   but the text should be displayed again .


Best Regars
Irfan, 



IA Irfan Alkan replied to Irfan Alkan July 1, 2016 08:43 AM UTC

Hi Irfan, 

Thanks for contacting Syncfusion support.   
  
We created a sample in enum with Grid column control. In this sample, we have converted enum values to a list of objects.   
  
Find the code example:   
 
 
public ActionResult GridFeatures() 
        { 
            ViewData["EmployeeID"] = EmployeeID; 
            return View(); 
        } 
 
        public List<object> EmployeeID 
        { 
 
            get 
            { 
                var EmployeeID = new List<object>(); 
                Array itemNames = System.Enum.GetNames(typeof(UnitOfMeasure)); 
                foreach (String name in itemNames) 
                { 
                    Int32 value = (Int32)Enum.Parse(typeof(UnitOfMeasure), name); 
                    ListItem listItem = new ListItem(name, value.ToString()); 
                    EmployeeID.Add(new { value = listItem.Value, text = listItem.Text }); 
                } 
                return EmployeeID; 
            } 
        } 
 
        public enum UnitOfMeasure 
        { 
 
            Nr = 0, 
 
            Kg = 1, 
 
            g = 2, 
 
            l = 3 
        } 
 
After converting the list of objects, we have bounded those values as a DataSource for the DropDown column  


<script type="text/javascript"> 
    var data =   @(Html.Raw(Json.Encode(ViewData["EmployeeID"]))); 
    $(function () { 
        ----------------------------------------- 
           allowPaging: true, 
            editSettings: { allowEditing: true }, 
            actionComplete : "complete", 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
            columns: [ 
                     { field: "DropDown", headerText: "Drop Down", textAlign: "center", width: 110, editType: ej.Grid.EditingType.Dropdown, dataSource: data }, 
                     ---------------------------- 
           ] 
        }); 
    }); 
     
</script> 


Regards, 
Prasanna Kumar N.S.V 
 


Hi Prasanna,
Download and run the example you have given.  There are similar problems also in this case. To better understand clearly the problem  the first question we give out samples we expect a similar result in  as attached picture.

Standart HTML.DropDown helper able to produce the result we want.  As can be seen in the picture it should appear in the text of the line in the enum list. User selection via dropdown  value should be set as 1-2   but the text should be displayed again .


Best Regars
Irfan, 


Hi Prasanna,
I forget upload sample picture. This reply contains picture.
Regards
Irfan,

Attachment: sample_f8a1e126.zip


PK Prasanna Kumar Viswanathan Syncfusion Team July 4, 2016 06:10 AM UTC

Hi Irfan, 

We have modified the sample as per the screenshot were we have displayed the text in the enum list. In dropdown, the value should be set as 1 and 2 and if we select the value then the text will be displayed again according to the value.   

Find the screenshots and sample: 

 

Dropdown values: 

 


Regards, 
Prasanna Kumar N.S.V 
 


Loader.
Live Chat Icon For mobile
Up arrow icon