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

[Solved] Get the Id of row selected

0 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ahmed
Top achievements
Rank 1
Ahmed asked on 28 Feb 2012, 12:30 PM
Hi 
i have a datagrid as below 

@(Html.Telerik().Grid(Model)
        .Name("Grid").Localizable("fr-FR")
            .DataBinding(dataBinding => dataBinding.Ajax().Select("IndexAjax", "PointsCoupures"))
        .Resizable(resizing => resizing.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Width(100);
            columns.Bound(o => o.LatitudeDecimal).Title("Longitude");
            columns.Bound(o => o.LongitudeDecimal).Title("Latitude");
        })
         
                .Sortable(sort => sort.SortMode(GridSortMode.MultipleColumn))
                .Pageable()
                .Scrollable(scrolling => scrolling.Height(250))
                .Scrollable()
                .Groupable()
             .Selectable()
            .ClientEvents(events => events.OnRowSelect("onRowSelected"))
                        .RowAction(row => row.Selected = row.DataItem.Id.Equals(ViewData["Id"]))
    )

Script
<script type="text/javascript">
    var Id;
    var Latitude;
    var Longitude
 
 
    function onRowSelected(e) {
        var window = $("#Window").data("tWindow");
        window.refresh();
         
        window.open();
 
        Id = e.row.cells[0].innerHTML;
        // update ui text
        $('#Id').text(Id);
 
    }
 
</script>

When i select a row i have a label that change properly  

Id: <span id="Id">@ViewData["Id"]</span>


and a window wich takes the id in parameter and displays a partial view

@{
    if(ViewData["Id"] != null){
 Html.Telerik().Window()
        .Name("Window").ClientEvents(t => t.OnLoad("Window_onLoad"))
        .Title("Map")
        .LoadContentFrom("EssaiMap", "PointsCoupures", new { id = ViewData["Id"] })
        .Draggable(true)
        .Scrollable(false)
        .Resizable()
        .Width(870)
        .Height(800)
        .Visible(false).Modal(true)
        .Render();
}
}
 
 public ActionResult EssaiMap(int? id)
        {
            var model = locRepo.PCGetByID(id);
            System.Diagnostics.Debug.WriteLine("iddddddddddd--->{0}", id);
            return PartialView("_GoogleMap", model);
        }


My problem is that the window doesnt send the new { id = ViewData["Id"] } to my controller
when i put a static id that works fine.
Tags
Grid
Asked by
Ahmed
Top achievements
Rank 1
Share this question
or