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

how to pass the id from main grid to another grid in pop up window

2 Answers 713 Views
Grid
This is a migrated thread and some comments may be shown as answers.
umamaheshwari
Top achievements
Rank 1
umamaheshwari asked on 11 Mar 2021, 04:30 AM

thia my index.cshtml
@(Html.Kendo().Grid<empdepkendo.Models.Employee>
    ()
    .Name("persons")
    .DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(m => m.ID))
    .Read(read => read.Action("GetAllEmployees", "Employees"))
    .Update(up => up.Action("UpdateEmployee", "Employees"))
    )

    .Columns(columns =>
    {
        columns.Bound(c => c.ID).Width(200);
        columns.Bound(c => c.FirstName);
        columns.Bound(c => c.LastName);
         columns.Command( cmd => cmd.Edit());

    })

    .Pageable()
    .Sortable()
     .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Person"))
    )

/

this EditorTemplat/Person.cshtml

@model empdepkendo.Models.Employee

@(Html.Kendo().Grid<empdepkendo.Models.Employee>
    ()
    .Name("EmpGrid")

    .Columns(columns =>
    {
        columns.Bound(c => c.ID).Width(200);
        columns.Bound(c => c.FirstName);
        columns.Bound(c => c.LastName);
        columns.Command(cmd => cmd.Edit()
                   );
    })
    .DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(m => m.ID))

    .Read(read => read.Action("Editer", "Employees", new { ID  }))      ///i want to pass the id here
    .Update(update=>update.Action("UpdateEmployee","Employees"))
    )
    )

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Denchev
Telerik team
answered on 15 Mar 2021, 10:29 AM

Hi,

You could use the Edit event of the main grid and call the read method of the editor grid with an additional parameter:

// Main grid
.Events(e => e.Edit("onEdit"))
<script>
    function onEdit(e) {
        let editorGrid = $("#EmpGrid").data("kendoGrid");
        let id = e.model.ID;
        editorGrid.dataSource.read({ id: id });
    }
</script>
// Editor grid.
.Name("EmpGrid")
.AutoBind(false)
// Editor grid action
public ActionResult Editer([DataSourceRequest] DataSourceRequest request, int? id)

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
umamaheshwari
Top achievements
Rank 1
answered on 15 Mar 2021, 10:32 AM
it was helpful , thank you
Tags
Grid
Asked by
umamaheshwari
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
umamaheshwari
Top achievements
Rank 1
Share this question
or