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

Show different information in Dropdown depending of the level of the row??

How can I display other information in the Dropdown when I start editing the cell?

Here is my code:

    var opt = new Syncfusion.JavaScript.Models.DropDownListProperties();
    opt.DataSource = ViewBag.Types;
    opt.DropDownListFields.Text = "Name";
    opt.DropDownListFields.Value = "Name";

           .Datasource(ds => ds.Json(ViewBag.DomainAccess)
           .FilterSettings(filter => filter.FilterType(TreeGridFilterType.Menu))
           .ToolbarSettings(tool =>
               tool.ToolbarItems(new List<TreeGridToolBarItems>()
               TreeGridToolBarItems.Add, TreeGridToolBarItems.Edit,
               TreeGridToolBarItems.Delete, TreeGridToolBarItems.Update,
               TreeGridToolBarItems.Cancel, TreeGridToolBarItems.ExpandAll,
           .EditSettings(edit =>
           .Columns(column =>
               column.Field("IdParent").HeaderText("ID Parent").Visible(false).Add();
       .ContextMenuSettings(cms => cms.ShowContextMenu(true)
            .ContextMenuItems(new List<TreeGridContextMenuItems>()

Any ideas on how to do that?

3 Replies

JD Jayakumar Duraisamy Syncfusion Team March 10, 2017 12:43 PM UTC

Hi Alberto, 
Thanks for contacting Syncfusion support. 
We can load different data source for dropdown control on editing the dropdown columns. This can be achieved this by using “BeforePopShown” client side event in dropdown list control. 
We can bind this event by using “DropDownEditOptions” in TreeGrid column property. 
In handler function we can update the data source of dropdown list control by using setModel method. 
Please refer following code snippet, 
    var opt = new Syncfusion.JavaScript.Models.DropDownListProperties(); 
    opt.DataSource = ViewBag.dropData; 
    opt.DropDownListFields.Text = "text"; 
    opt.DropDownListFields.Value = "value"; 
    opt.BeforePopupShown = "beforeOpen"; // Client side event 
    <script type="text/javascript"> 
        function beforeOpen(args) { 
            var treegridObj = $("#TreeGridContainer").data("ejTreeGrid"); 
            record = treegridObj.model.selectedItem, 
            dataSource = args.model.dataSource; 
            data = [];            
            if (record.level == 0) 
                data = dataSource.slice(0, 4); 
            else if (record.level == 1) 
                data = dataSource.slice(4, 8); 
            else if (record.level == 2) 
                data = dataSource.slice(8, 12); 
            this.setModel({"dataSource": data}); // Update new data in the dropdown list 
We have prepared a sample for your reference, In this sample we have modified the dropdown data with respect to level of TreeGrid record. 
Please find the sample from below location. 
Please let us know if you require more assistance on this. 
Jayakumar D 

AB Alberto Barrera March 11, 2017 12:54 AM UTC

It worked correctly!

Thanks for your quick support.

JD Jayakumar Duraisamy Syncfusion Team March 13, 2017 08:36 AM UTC

Hi Alberto,  
We are glad to know that your issue has resolved. 
Please let us know if you require further assistance on this. 
Jayakumar D 

Live Chat Icon For mobile
Up arrow icon