Grid Column pass value to link

I am using a custom column with a link. I have a value tool ID that I need to pass into the link. 

Here is my code:

<e-grid-columns>
             
                <e-grid-column field = "ToolID" headerText="Test" template="#temp" width="50" ></e-grid-column> 
            </e-grid-columns>

I have tried this:
<script id="temp" type="text/x-template">
    <a rel='nofollow' href="@Url.Action("AddTest", "Home", new {toolID = "${ToolID}"})">&nbsp; <span class="bi-plus-circle-fill" aria-hidden="true" title="Create new Test"></span>&nbsp;</a>
    </script>

 and this:

<h4 title="Create New Test"> @Html.ActionLink("", "AddTest","Home", "${ToolID}",new {@class= "bi-plus-circle-fill" }) </h4>


They both go to the page but the ToolID value is always 0.

Homecontroller.ccs
public IActionResult AddTest(int toolID)
        {
            return View();
        }

1 Reply 1 reply marked as answer

MS Manivel Sellamuthu Syncfusion Team March 16, 2021 10:51 AM UTC

Hi Danyelle, 

Greetings from Syncfusion support. 

We have validated your requirement and you want to pass the toolID while clicking the column cell. While checking the provided code example we found that the toolID value was not passed to the request. So the in the server side method it always showing as ‘0’. 

You can achieve your requirement using customHelper and template data. Please refer the below code example and screenshot for more information. 

<div> 
    <ejs-grid id="Grid" dataSource="ViewBag.DataSource" allowFiltering="true" allowPaging="true"> 
. . . 
        <e-grid-columns> 
            <e-grid-column field="CustomerID" headerText="Customer Name" template="#temp" width="150"></e-grid-column> 
. . . 
        </e-grid-columns> 
    </ejs-grid> 
</div> 
 
<script id="temp" type="text/x-template"> 
    <a rel='nofollow' rel='nofollow' href='${customHelper(data)}'>&nbsp; <span class="bi-plus-circle-fill" aria-hidden="true" title="Create new Test"></span>&nbsp;</a> 
    </script> 
 
<script> 
    function customHelper(args) { 
        return 'Home/addTest?toolID=' + args.OrderID; 
    } 
</script> 

 

 

Please let us know, if you need further assistance. 

Regards, 
Manivel 


Marked as answer
Loader.
Up arrow icon