)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set dropdown edit type for the TreeGrid column

Platform: ASP.NET MVC |
Control: TreeGrid |
Published Date: August 3, 2017 |
Last Revised Date: May 27, 2019

It is possible to set the edit type as dropdown for TreeGrid column. We can also customize the data inside drop down with or without checkbox. So that we can choose single or multiple options from the dropdown box. Please find the below code snippet to set dropdown edit type for the TreeGrid column.

CSHTML

@(Html.EJ().TreeGrid("TreeGridContainer")
//…
.Columns(co =>
               {
//…
co.Field("Resource").HeaderText("Resource").EditType(TreeGridEditingType.Dropdown).DropDownData((IEnumerable<object>)ViewBag.resource).Add();
               }
             )
)

C#

public ActionResult Index()
        {
            var DataSource = TreeGridDefaultData.GetData();
            ViewBag.datasource = DataSource;
            ResourceList resource = new ResourceList();
            ViewBag.resource = resource.GetResources();           
            return View();
        }
 
        public class Resource
        {
            public int id { get; set; }
            public string text { get; set; }
            public string value { get; set; }
        }
 
        public class ResourceList
        {
            public List<Resource> GetResources()
            {
                List<Resource> ResourceCollection = new List<Resource>();
                ResourceCollection.Add(new Resource() { id = 1, text = "Project Manager", value = "Project Manager" });
                ResourceCollection.Add(new Resource() { id = 2, text = "Software Analyst", value = "Software Analyst" });
                //…
            }
        }

A sample to define and enable the dropdown data in TreeGrid is available in the following link.

Sample

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon