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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Pass the Value to Controller

Thread ID:





132536 Sep 7,2017 05:46 AM UTC Sep 11,2017 04:00 AM UTC ASP.NET Core 3
Tags: Grid
Asked On September 7, 2017 05:46 AM UTC

Hi Sir

Could you help me on this matters, using the Flatgrid to display the data from database, need to pass the value from primary key to controller/action.
Below is the code that i used currently, JHId not sending to controller

<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.datasource" allow-filtering="true" allow-sorting="true">
        <e-column field="JhId" header-text="JH Id" is-primary-key="true" width="30" tooltip="Click here for Details" template-id="#columnTemplate" ></e-column>
        <e-column field="JHName" header-text="JH Name" is-primary-key="false" width="150"></e-column>
        <e-column field="JHGenderDesc" header-text="Gender" is-primary-key="false" width="75"></e-column>
        <e-column field="JHIdNumber" header-text="Id Number" is-primary-key="false" width="75"></e-column>
        <e-column field="JHPassport" header-text="PMA No" is-primary-key="false" width="75"></e-column>
        <e-column field="JHGroupNo" header-text="Group No" is-primary-key="false" width="75"></e-column>

<script type="text/x-jsrender" id="columnTemplate">
    <a rel='nofollow' href="@Url.Action("ViewJHDetails","PotentialJH", new { JHId = "{{:JhId}}" })">{{:JhId}}</a>

Thanks for the support

Venkatesh Ayothi Raman [Syncfusion]
Replied On September 8, 2017 02:08 PM UTC

Hi Customer, 

Thanks for contacting Syncfusion support. 

We have achieved your requirement using same column template feature in Grid. In this template, we have defined the onClick event for anchor tag to assign the primary key value as parameter, because we can’t set the JSrender syntax as object value in URL action parameter.  
Please refer to the following code example, 

<script type="text/x-jsrender" id="columnTemplate"> 
    <a rel='nofollow' href="@Url.Action("Index","Home", new { OrderID ="OrderID" })" id="{{:OrderID}}" onclick='check({{:OrderID}})'>{{:OrderID}}</a> 
[click event] 
function check(val) { 
        //here we can assign the corresponding primarykey value as additional parameter 
        $("#" + val).attr("rel='nofollow' href", "/?OrderID=" + val); 

We have also prepared a sample for your convenience which can be download from following link, 
Screenshot 1
Screenshot 2

Venkatesh Ayothiraman. 

Replied On September 11, 2017 01:01 AM UTC

Hi Venkatesh Ayothiraman

Thanks for the support, the solution workable for me.

Venkatesh Ayothi Raman [Syncfusion]
Replied On September 11, 2017 04:00 AM UTC

Hi Customer, 

Thanks for the feedback. 

We are very happy to hear that your requirement is achieved. 

Venkatesh Ayothiraman. 


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