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

ejGrid How to do show enum types in model?

hi ,
i have problem with enum types pull model in ejgrid.

BudgetTypes = [ { value: 0, text: "Cost" }, { value: 1, text: "Revenue" }, ];

columns: [

{field: "Type", headerText: "Type", width:"50",editType: ej.Grid.EditingType.Dropdown , dataSource:BudgetTypes, fields: { id: "value", text: "text"}},

as you see an example i get local data but i want to get model data. how i do?  I'd like you to answer this question
Best Regards 

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team June 23, 2016 09:24 AM UTC

Hi Emir, 

Thank you contacting Syncfusion support.  

We have achieved your requirement using columnTemplate feature and TemplateRefresh event. HTML templates can be specified in templateproperty of the particular column as a string (HTML element) or ID of the template’s HTML element. TemplateRefresh event triggers when we refresh the template column element in Grid.  
In the templateRefresh event, we have bound DataSource for the DropDown list.    
Please refer to the below Help document, code example and sample.    

<script type="text/x-jsrender" id="columnTemplate"> 
    <input class="data" type="text" /> 
<div id="Grid"></div> 
<script type="text/javascript"> 
    $(function () { 
            // the datasource "window.gridData" is referred from jsondata.min.js 
            dataSource: window.gridData, 
            allowPaging: true, 
            templateRefresh : "templaterefresh", 
            columns: [ 
                     { headerText: "Drop Down", template: "#columnTemplate", textAlign: "center", width: 110 }, 
    var data =   @(Html.Raw(Json.Encode(ViewData["EmployeeID"]))); 
    function templaterefresh (args) { 
            dataSource: data, 
            text: "Nr", 
Grid Controller 

public ActionResult GridFeatures() 
            ViewData["EmployeeID"] = EmployeeID; 
            return View(); 
        public class DMSerial : IDataSourceSerializer 
            public string Serialize(object obj) 
                var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj); 
                return str; 
        public List<object> EmployeeID 
                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()); 
                    SerializeObject serialize = new SerializeObject(); 
                    var list = serialize.SerializeToJson(listItem.Text, listItem.Value); 
                    EmployeeID.Add(new { value = listItem.Value, text = listItem.Text }); 
                return EmployeeID; 
        public class EmployeeDetails 
            public UnitOfMeasure Unit { get; set; } 
        public enum UnitOfMeasure 
            Nr = 0, 
            Kg = 1, 
            g = 2, 
            l = 3 

Help Documents: 

Prasanna Kumar N.S.V 

Live Chat Icon For mobile
Up arrow icon