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

Dropdown for custom command in grid

Hi, 
Is there a way to render command buttons as a dropdown button for asp .net core?
Thank you

5 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team January 21, 2020 10:03 AM UTC

Hi Muhamad, 
 
Thanks for contacting Syncfusion support. 
 
Query: “Is there a way to render command buttons as a dropdown button for asp .net core? 
 
To render the dropdown button we have used template property of EJ2 Grid Column. Please refer the below code example and sample to achieve your requirement. 
 
 
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" queryCellInfo="template" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editSettings> 
   <e-grid-columns> 
        .  .  .  .  .  .  . 
        <e-grid-column headerText="Dropdown Button" template="#columnTemplate" width="150"></e-grid-column> 
        .  .  .  .  .  .  . 
   </e-grid-columns> 
</ejs-grid> 
 
<script type="text/x-jsrender" id="columnTemplate"> 
 
    <button class="List">Ações</button> 
 
</script> 
 
<script type="text/javascript"> 
    var data = [ 
        { text: "Visualizar", iconCss: "fa fa-eye" }, 
        { text: "Editar", iconCss: "fa fa-edit" }, 
        { text: "Excluir", iconCss: "fa fa-trash" }, 
        { text: "Liberar p/ Gerência", iconCss: "fa fa-user" }, 
        { text: "Baixar", iconCss: "fa fa-check" }, 
        { text: "Estornar", iconCss: "fa fa-mail-reply" }, 
        { text: "Pagto Parcelado", iconCss: "fa fa-list-ol" } 
    ]; 
    function template(args) { 
        var ele = args.cell.querySelector('.List'); 
        var drop = new ej.splitbuttons.DropDownButton({ 
            popupHeight: 150, 
            popupWidth: 200, 
            items: data 
        }); 
 
        drop.appendTo(ele); 
    } 
 
</script> 
 
 

 
 
 
Regards, 
Prasanna Kumar N.S.V 



MA Muhamad Adam Fakhrullah Nik Mohamad January 22, 2020 08:42 AM UTC

And can i know how to make child grid appear  when we click the item from dropdown ? for example like this picture 



DR Dhivya Rajendran Syncfusion Team January 23, 2020 01:28 PM UTC

Hi Muhamad, 

Thanks for your update. 
 
Query: “how to make child grid appear  when we click the item from dropdown” 

As per your requirement, we have created a sample. In the below sample, we have rendered dialog component in dataBound event and set visibility false for dialog at initial rendering and shown the dialog whenever we click the dropdown button in grid. Please refer to the below code and modified sample link. 

  var flag = true; 
    var dialogObj; 
    function dataBound(args) { 
        if (flag) { 
            dialogObj = new ej.popups.Dialog({ 
                showCloseIcon: true, 
                target: document.getElementById('e-content'), 
                . . . . 
                visible: false, 
                header: 'Trip Details', 
                content: '<div id="Grid2"></div>', 
                created: function (args) { 
                    var grid = new ej.grids.Grid({ 
                        dataSource: data1, 
                    }); 
                    grid.appendTo('#Grid2'); 
                } 
 
            }); 
            dialogObj.appendTo('#wrapper'); 
            flag = false; 
        } 
    } 
    var data1 = @Html.Raw(Json.Serialize(ViewBag.DataSource));  
     
    function template(args) { 
        var ele = args.cell.querySelector('.List'); 
        var drop = new ej.splitbuttons.DropDownButton({ 
            popupHeight: 150, 
            popupWidth: 200, 
            items: data, 
            select: function (args) { 
                dialogObj.show(); 
            } 
        }); 
        drop.appendTo(ele); 
    } 

Please get back to us, if you need any further assistance. 

Regards, 
R.Dhivya 



YY Yoab Youssoufou replied to Prasanna Kumar Viswanathan September 17, 2022 02:04 PM UTC

Hello,

how can I add click listener to this example? This works fine but clicking the items does nothing. Pls help



RR Rajapandi Ravi Syncfusion Team September 19, 2022 01:37 PM UTC

Hi Yoab,


Thanks for the update.


In our previous shared sample, while clicking in the dropdown item we have displayed the Grid inside the dialog. Please refer the below video demo for more information.


Video demo: https://www.syncfusion.com/downloads/support/directtrac/general/ze/vdclick-264102676.zip


So, before we start providing solution to your query, we need more information for our clarification. Please share the below details that will be helpful for us to provide better solution.


1)          Share your exact requirement scenario with detailed description.


2)          Please share the problem scenario in detailed description.


3)          Please share your problem scenario in video demonstration format.


Regards,

Rajapandi R


Loader.
Live Chat Icon For mobile
Up arrow icon