New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Creating Nested Hierarchy of Components Using Grid Selections
Environment
Product | Telerik UI for ASP.NET MVC Grid |
Progress Telerik UI for ASP.NET MVC version | Created with the 2022.3.913 version |
Description
How can I use the selection of a Grid in a hierarchy of components?
Solution
To achieve the desired scenario:
- Implement a custom command button in the Toolbar.
- Handle the
Click
event of the custom command button. - In the
Click
event handler, get the selected rows of the main Grid. Use theselect
method for the case. - Create a collection of the
dataItems
by using the selected rows. - Open the Window.
- For the content part of the Window, implement a div element for the Telerik UI for ASP.NET MVC Wizard component. Now you can initialize it.
- Implement the desired steps in the Wizard: Grid, Percent Input, and Stored Procedure.
- Use the collection from step 4 as a DataSource for the newly created Grid.
The following sample code represents the steps described above.
Index.cshtml
@(Html.Kendo().Grid<TelerikMvcApp50.Models.OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Custom().Text("Adjust Multiple Standard Prices").HtmlAttributes(new { id = "customCommand" }))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
columns.Bound(p => p.ShipName);
columns.Bound(p => p.ShipCity);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)
@(Html.Kendo().Window()
.Name("window")
.Title("About Alvar Aalto")
.Content(@<text><div id="wizard"></div></text>)
.Draggable()
.Resizable()
.Width(600)
.Visible(false)
.Modal(true)
.Position(p => p.Top(200).Left(200))
.Actions(actions => actions.Pin().Minimize().Maximize().Close())
.Events(e => e.Close("onWindowClose"))
)