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

value from cellselected

Thread ID:

Created:

Updated:

Platform:

Replies:

150176 Dec 23,2019 07:29 PM UTC Dec 24,2019 04:51 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Patrick King
Asked On December 23, 2019 07:29 PM UTC

I have a grid with images displayed based on paths included in the datasource.  When clicking on the cell, I simply want to access the path value.  I've attempted several ways to accomplish this and found a few samples in the forums.  However, I only seem to be able to return the field name and not the associated value.  In the example below, if the second column (index 1) cell is selected, I am attempting to access the value from the hidden cell at the 0 index.

<ejs-grid id="Gridpic" allowtextwrap="true" allowSelection="true" dataSource="@ViewBag.datasourcepic" cellSelected="BigPic">
    <e-grid-selectionsettings mode="Cell"></e-grid-selectionsettings>
    <e-grid-textwrapsettings wrapmode="Header" />
    <e-grid-columns>

        <e-grid-column field="picpath" visible="false"></e-grid-column>
        <e-grid-column template="#picTemplate"></e-grid-column>
        <e-grid-column template="<img src='${picpath1}'>"></e-grid-column>
        <e-grid-column template="<img src='${picpath2}'>"></e-grid-column>
        <e-grid-column template="<img src='${picpath3}'>"></e-grid-column>
    </e-grid-columns>
</ejs-grid>


<script type="text/x-jsrender" id="picTemplate">
    <img src="${picpath}&thumb=t" />

</script>

<script type="text/javascript">

    function BigPic(args)
    {
        var grid = document.getElementById("Gridpic").ej2_instances[0];
        var field = grid.columns[args.cellIndex.cellIndex - 1].field;
        location.rel='nofollow' href = field;

    }

Pavithra Subramaniyam [Syncfusion]
Replied On December 24, 2019 04:51 AM UTC

Hi Patrick, 

Greetings from Syncfusion. 

You can get the required cell data from the field name using the “args.data” value. Please refer to the below code example for more information. 

[Script] 
function BigPic(args) { 
  var grid = document.getElementById("Gridpic").ej2_instances[0]; 
  var field = grid.columns[args.cellIndex.cellIndex - 1].field; 
  console.log(args.data[field]); 
  location.rel='nofollow' href = field; 
} 

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

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