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

Dropdown for custom command in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

150810 Jan 21,2020 03:55 AM UTC Jan 23,2020 01:28 PM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
Muhamad Adam Fakhrullah Nik Mohamad
Asked On January 21, 2020 03:55 AM UTC

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

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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 


Muhamad Adam Fakhrullah Nik Mohamad
Replied On 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 


Dhivya Rajendran [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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