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

value from cellselected

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;

    }

1 Reply

PS Pavithra Subramaniyam Syncfusion Team 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. 


Loader.
Up arrow icon