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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can we allow the display of text enum?

Thread ID:

Created:

Updated:

Platform:

Replies:

124756 Jun 28,2016 06:30 AM UTC Jul 4,2016 06:10 AM UTC JavaScript 4
loading
Tags: ejGrid
Irfan Alkan
Asked On June 28, 2016 06:30 AM UTC

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

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 
 


Irfan Alkan
Replied On 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, 


Irfan Alkan
Replied On 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

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;