Note that there are some explanatory texts on larger screens.

plurals
  1. POTelerik MVC 3 Grid selected row binding to Model property
    primarykey
    data
    text
    <p>I have a Telerik Grid in my View. I want to know if there is a way by which I can bind the Datakey of the selected row to the Model Property -</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site1.Master" Inherits="System.Web.Mvc.ViewPage&lt;Mitek.MobileImagingTest3.Models.JobFileStatisticsModel&gt;" %&gt; </code></pre> <p></p> <p>&lt;% using (Html.BeginForm()) { %><br> </p> <pre><code> &lt;div class="editor-label"&gt; &lt;br /&gt; &lt;label&gt;Select Which Job:&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;%= Html.Telerik().Grid((IEnumerable&lt;Mitek.MobileImagingTest3.Models.JobFileStatisticsModel&gt;)ViewData["JobFilesDataList"]) .Name("JobFileGrid") .EnableCustomBinding(true) //.BindTo((IEnumerable&lt;Mitek.MobileImagingTest3.Models.JobFileStatisticsModel&gt;)ViewData["JobFilesDataList"]) .DataKeys(keys =&gt; keys.Add(o =&gt; o.JobFileId)) .Columns(columns =&gt; { columns.Bound(o =&gt; o.JobFileId).Hidden(true); columns.Bound(o =&gt; o.JobFileName).Title("Job File Name").Width(500); columns.Bound(o =&gt; o.JobFileVersion).Title("Job File Version").Width(200); columns.Bound(o =&gt; o.JobFileDateCreated).Title("Date Created").Format("{0:MM/dd/yyyy}").Width(300); }) .HtmlAttributes(new { style = "width: 1000px; font-family:arial; font-size: .9em;" }) .ClientEvents(events =&gt; events.OnRowSelected("onRowSelected")) .DataBinding(dataBinding =&gt; dataBinding.Ajax().Select("SelectJobFile", "Admin")) .Pageable() .Sortable() .Selectable() .RowAction(row =&gt; { row.Selected = row.DataItem.JobFileId.Equals(ViewData["JobFileId"]); //Model.JobFileId = ViewData["JobFileId"].ToString(); }) %&gt; &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt; &lt;br /&gt; &lt;button type= "submit" name="button" class="t-button" &gt;Run Report&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;% } %&gt; enter code here &lt;script type="text/javascript"&gt; function onRowSelected(e) { var id = e.row.cells[0].innerHTML; alert(id); } &lt;/script&gt; </code></pre> <p></p> <p>My model is -</p> <pre><code> public class JobFileStatisticsModel { public string JobFileId { get; set; } public string JobFileName { get; set; } public string JobFileVersion { get; set; } public string JobFileDateCreated { get; set; } } </code></pre> <p>How do I bind the Datakey of the selected row in the Grid to the Model.JobFileId property? Please help.</p> <p>Thanks, SDD</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload