This is a migrated thread and some comments may be shown as answers.

Kendoui Grid Get Selected Row Id when Edit Button is clicked

2 Answers 1735 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DD101
Top achievements
Rank 1
DD101 asked on 24 Jul 2015, 07:27 PM

I have a simple grid  and I'm having a lot of  trouble collecting the PersonID when the edit button is clicked using JQuery. I need the  PersonID because I'm going to add a file upload to the inline edit column and i want to upload a file and associate it with the PersonID. All help welcome :)

 

Here's my simple grid:

@(Html.Kendo().Grid<GridCustomPopupTemplate.Models.Person>().Name("Grid")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(m => m.PersonID))
            .Read(read => read.Action("GetPersons", "Home"))
            .Update(up => up.Action("UpdatePerson", "Home"))
    )

    .Columns(columns =>
    {
        columns.Bound(c => c.PersonID).Width(200);
        columns.Bound(c => c.Name);
        columns.Command(cmd => cmd.Edit());
    })

    .Pageable()
    .Sortable()
    .Editable(ed => ed.Mode(GridEditMode.InLine))
   .Events(ev => ev.Edit("doOnRowSelect"))  
)

 

<script type="text/javascript">

    function doOnRowSelect(e) {

         alert(The #PersonID# of the row which we are going to edit here....)

    }

</script>

2 Answers, 1 is accepted

Sort by
0
DD101
Top achievements
Rank 1
answered on 24 Jul 2015, 08:17 PM
I should say that I think this issue is specific to the MVC wrapper :(
0
Radoslav
Telerik team
answered on 28 Jul 2015, 01:50 PM
Hi Damien,

Thank you for contacting us.

To achieve the desired functionality you can try using the following code snippet:
function doOnRowSelect(e) {
 
        var PersonID =  e.sender.dataItem(e.container).PersonID;
 
        alert("The " + PersonID + " of the row which we are going to edit here....");
 
    }

Additionally I am sending you a simple example which demonstrates this approach.

If you need further assistance, do not hesitate to contact us again.


Regards,
Radoslav
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
DD101
Top achievements
Rank 1
Answers by
DD101
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or