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

Pass the Value to Controller

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

3 Replies

VA Venkatesh Ayothi Raman Syncfusion Team 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. 

HA haryzad September 11, 2017 01:01 AM UTC

Hi Venkatesh Ayothiraman

Thanks for the support, the solution workable for me.

VA Venkatesh Ayothi Raman Syncfusion Team 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. 

Live Chat Icon For mobile
Up arrow icon