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

Editing Columns with Dropdown

Hello!

I want to be able to edit some columns in my Gantt Chart with a Dropdown.
However, I seem to be unable to find any documentation on how to do that.
I've found a forum post on how to do that with the Grid Control, but that doesn't seem to work for the Gantt Column,
the Dropdown just stays empty if I follow the syntax in the forum post.
If I try different syntax, the Dropdown fills with all the different values that are present in the Gantt Tasks for that specific column.

Here's a condensed Version of one of the things I tried:

<e-gantt-column field="@nameof(TermineModel.Name)"
headerTemplate="#nameTemplate"
width="100"
editType="dropdownEdit"
edit="@(new { @params = new {
                                                  dataSource = new List<object>() { new { value = "test", text = "test" },new { value = "test2", text = "test2" } },
                                                  fields = new { text = "text", value = "value" }
                                                       } })">
</e-gantt-column>

Please Advise.

Thank you




14 Replies

LK Lukas Knapp December 17, 2019 01:39 PM UTC

Update:

Found out that the method I was using is actually working.... Sort of.
Thing is, the Dropdown only works in the Edit Modal, not when trying to inline-edit in the columns.
I do want inline-editing though, so help is still appreciated.


PP Pooja Priya Krishna Moorthy Syncfusion Team December 18, 2019 08:55 AM UTC

Hi Lukas, 
 
We can load the custom data in dropdown by using the edit.params property. While setting the data source using edit params, it is necessary to initialize the query property also. 
Please find the below code example. 
 
 
@{ 
 
    var DropDownList = new Syncfusion.EJ2.DropDowns.DropDownList() { 
        DataSource = new List<object>() { new { value = "test", text = "test" }, new { value = "test2", text = "test2" } }, 
        Query = "new ej.data.Query()", 
        Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Text = "text", Value = "value" }, 
    }; 
} 
<ejs-gantt id='Gantt' dataSource="ViewBag.DataSource" > 
    //... 
   <e-gantt-columns> 
        //... 
        <e-gantt-column field="Custom" editType="dropdownedit" 
                        edit="new {@params = DropDownList }"> 
        </e-gantt-column> 
    </e-gantt-columns> 
</ejs-gantt> 
 

Please get back to us if you require further assistance on this. 
Note: For security purpose, we have removed bin and obj folder in the shared sample. 

Regards, 
Pooja Priya K. 



LK Lukas Knapp December 18, 2019 09:48 AM UTC

Hi!

After Setting the Query and explicitly creating instances of DropDownList and DropDownListFieldSettings instead of using anonymous types, it worked.

Thanks for the help!

Kind Regards

Lukas


PP Pooja Priya Krishna Moorthy Syncfusion Team December 19, 2019 04:40 AM UTC

Hi Lukas, 
We are happy that your issue has been resolved. Please get back to us if you require further assistance on this. 
As always we will be happy to assist you. 

Regards, 
Pooja K. 



JM Jesús Mostajo June 29, 2022 05:14 PM UTC

In relation with this thread, I would like add some question. I have this dropdownlist:

var DropDownList = new Syncfusion.EJ2.DropDowns.DropDownList()
    {
        DataSource = new List<object>() { new { value = "0", text = "Pendiente" }, new { value = "25", text = "Iniciado" }, new { value = "50", text = "Activo" }, new { value = "100", text = "Completado" }, new { value = "0", text = "Cancelado" } },
        Query = "new ej.data.Query()",
        Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Text = "text", Value = "value" },
    };

and

<e-gantt-column field="progress" editType="dropdownedit" edit="new {@params = DropDownList }"></e-gantt-column>

In dialog mode, I change the dropdownlist and collect the value correctly on handler, but when the dialog shows the dropdownlist doesn't show the text equivalent to the value. For example value 50 generates this html:

<div class="e-float-input e-control-wrapper e-input-group e-ddl e-lib e-keyboard" tabindex="0" aria-disabled="false" aria-owns="projectGanttprogress_options" role="listbox" aria-haspopup="true" aria-expanded="false" aria-activedescendant="null" aria-labelledby="label_projectGanttprogress" aria-describedby="projectGanttprogress" style="width: 100%;">
<select aria-hidden="true" tabindex="-1" class="e-ddl-hidden" name="progress" id="projectGanttprogress_hidden">
<option selected="" value="50">null</option>
</select>
...



Any Idea?



MS Monisha Sivanthilingam Syncfusion Team July 6, 2022 01:12 PM UTC

Hi Jesús,


We suspect that you are saying that after selecting a value for the Progress field using the dropdown list, then the selected value is not shown in the edit dialog. Please correct us if we are wrong in our understanding of your issue. We can resolve that issue by applying the valueAccessor to the Progress field. The below code snippets demonstrate the solution.


Index.cshtml

 

<e-gantt-column field="Progress" editType="dropdownedit" edit="new {@params = DropDownList }" valueAccessor="progressFormat"></e-gantt-column>

 


 

@{

    var DropDownList = new Syncfusion.EJ2.DropDowns.DropDownList()

    {

        DataSource = new List<object>() {

          new { value = "0", text = "Pendiente" },

          new { value = "25", text = "Iniciado" },

          new { value = "50", text = "Activo" },

          new { value = "100", text = "Completado" },

          new { value = "0", text = "Cancelado" }

        },

        Query = "new ej.data.Query()",

        Fields = new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings() { Text = "text", Value = "value" },

    };

    Object progressFormat = "progressFormat";

}

 


 

<script>

    function progressFormat(field, data, column) {

        return data[field];

    }

</script>

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/F1499861947734527


Please get back to us with further details if this is not the issue you reported.


Regards,

Monisha.



JM Jesús Mostajo July 7, 2022 09:55 AM UTC

Thanks for your quickly response but the issue remains the same. 

You can testing with your example, when you load at first time, open any gantt task and you can view that dorpdownlist doesn't show text corresponding with its value.


Captura de pantalla 2022-07-07 115257.png

Captura de pantalla 2022-07-07 115329.png


Regards

Jesús Mostajo




MS Monisha Sivanthilingam Syncfusion Team July 13, 2022 12:18 PM UTC

Hi Jesús,


We were able to replicate the issue you reported. We can resolve it by setting the value property for the dropdown list. We have achieved it by using the cell edit template. The below code snippets demonstrate the solution.


Index.cshtml

 

<e-gantt-column field="Progress" edit="@(new {create = "create", read = "read", destroy = "destroy", write = "write"})"></e-gantt-column>

 


<script>

  var elem;

   var dropdownlistObj;

   var progressData = [{ value: "0", text:"Pendiente" },{ value:"25", text: "Iniciado" }, { value:"50", text:"Activo" }, { value: "100", text: "Completado" }, { value: "0", text: "Cancelado" }];

   function create(args) {

      elem = document.createElement('input');

      return elem;

   }

   function write(args) {

      dropdownlistObj = new ej.dropdowns.DropDownList({

         dataSource: progressData,

         fields: { text: 'text', value: 'value' },

         value: args.rowData[args.column.field],

         floatLabelType: 'Auto',

      });

      dropdownlistObj.appendTo(elem);

   }

   function destroy() {

      dropdownlistObj.destroy();

   }

   function read(args) {

      return dropdownlistObj.value;

   }

</script>

 


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/149986-847357406


Online Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/gantt/managing-tasks#cell-edit-template


Regards,

Monisha.



JM Jesús Mostajo replied to Monisha Sivanthilingam July 14, 2022 07:28 AM UTC

Hi Monisha,


Thanks for your response. This is applicable in cell editing mode but we also need it to work in Dialog editing. 

Is it possible?


Sorry for inconvenience



MS Monisha Sivanthilingam Syncfusion Team July 15, 2022 11:49 AM UTC

Hi Jesús,


We have logged a bug report for the issue you have reported. You can track its status from the below feedback link.


Feedback: https://www.syncfusion.com/feedback/36354/unable-to-use-dropdown-edit-in-progress-column


The fix will be provided in the patch release scheduled for August 3, 2022.


We appreciate your patience until then.


Regards,

Monisha.



JM Jesús Mostajo July 18, 2022 06:43 AM UTC

Thanks...



MS Monisha Sivanthilingam Syncfusion Team July 20, 2022 05:19 AM UTC

Hi Jesús,


You are welcome.


We will intimate you once the issue is fixed.


Regards,

Monisha.



JM Jesús Mostajo September 13, 2022 05:18 PM UTC

Hi Monisha,

I have updated to Syncfusion.EJ2AspNet.Core 20.2.0.43 and now it works well.

Thanks !!



MS Monisha Sivanthilingam Syncfusion Team September 14, 2022 09:49 AM UTC

Hi Jesús,


You are welcome.


Please contact us if you require any further assistance.


Regards,

Monisha.


Loader.
Live Chat Icon For mobile
Up arrow icon