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

ASP.NET Core - Razor Page - Open EJ2 Dialog from custom Command inside grid and pass record/row information

Thread ID:

Created:

Updated:

Platform:

Replies:

144071 Apr 17,2019 07:27 AM UTC Apr 29,2019 04:37 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
moez
Asked On April 17, 2019 07:27 AM UTC

Hello

How can I open an EJ2 (Modal) Dialog when the user clicks on a custom command inside a grid AND pass the selected row information to the Dialog ?

Thanks 1

Pavithra Subramaniyam [Syncfusion]
Replied On April 18, 2019 06:53 AM UTC

Hi moez, 
 
Thanks for contacting Syncfusion support. 
 
Based on your requirement we have prepared a sample in which we have opened the EJ2 dialog component inside the click event of custom command button and shown the row data in the dialog content. Please refer to the below code example and sample link for more information. 
 
[index.cshtml] 
 
@{ 
    List<object> commands = new List<object>(); 
    commands.Add(new { type = "userstatus", buttonOption = new { click="click",content = "Details", cssClass = "e-flat e-details" } }); // custom 
} 
<div id="dialog"></div> 
<ejs-grid id="Grid" allowPaging="true" load="onLoad"> 
    <e-data-manager url="/Index?handler=DataSource" insertUrl="/Index?handler=Insert" updateUrl="/Index?handler=Update" removeUrl="/Index?handler=Delete" adaptor="UrlAdaptor"></e-data-manager> 
    <e-grid-editSettings allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column> 
         .  .  . 
        <e-grid-column headerText="Manage Records" width="120" commands=commands> 
        </e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 
<script> 
     
    
    function onLoad() { 
        document.getElementsByClassName('e-grid')[0].addEventListener("click", (args) => { 
            if (args.target.classList.contains("e-details")) { 
                var grid = ej.grids.parentsUntil(args.target, 'e-grid').ej2_instances[0]; 
                var rowObj = grid.getRowObjectFromUID(ej.grids.parentsUntil(args.target, 'e-row').getAttribute('data-uid'));      // getting row data 
                var data = rowObj.data; 
                var dialog = new ej.popups.Dialog({ 
                    showCloseIcon: true, 
                    content: 'OrderID:'+data.OrderID, 
                    header: "Show ID", 
                    target: document.getElementsByClassName("e-grid")[0], 
                    width: '250px' 
                }); 
                // Render initialized Dialog 
                dialog.appendTo('#dialog'); 
                dialog.show(); 
            } 
 
        }) 
 
        this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]; 
 
    } 
</script> 
 
  
 
 
Regards, 
Pavithra S. 
 


moez
Replied On April 26, 2019 06:13 PM UTC

That worked, Thank you Pavithra !

Pavithra Subramaniyam [Syncfusion]
Replied On April 29, 2019 04:37 AM UTC

Hi moez,  

Thanks for your update. 

We are happy to hear that your problem has been solved. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Regards,  
Pavithra S. 


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