On selection of a dropdown's, item needs to perform a action on all the selected rows (using checkbox checked) .
how to accomplish it.
1 Answer, 1 is accepted
0
Mihaela
Telerik team
answered on 06 Aug 2021, 11:20 AM
Hi Vivek,
The desired result could be achieved as per the following approach:
Subscribe to the "change" event of the DropDownList and get the selected option through the value() method;
Get the selected Grid's rows by using the select() method;
Loop through the selected rows and access the data item of each row.
Here is an example:
@(Html.Kendo().DropDownList()
.Name("dropdownlist")
.BindTo(new string[] { "Item1", "Item2", "Item3" })
.Events(e => e.Change("onChange"))
)
@(Html.Kendo().Grid<Model>()
.Name("grid")
.Columns(columns =>
{
columns.Select().Width(50);
...
})
...
)
<script>
functiononChange(e) {
var selectedItem = this.value(); //get the selected DropDownList optionvar gridWidget = $("#grid").data("kendoGrid"); //get an instance of the Gridvar selectedRows = gridWidget.select(); //get the selected rows
$(selectedRows).each(function () { //loop through the selected rowsvar selectedRow = $(this); //the selected table rowvar rowDataItem = gridWidget.dataItem($(this));
//do the action
});
}
</script>
Hopefully, this example will be helpful to your case.
If any questions arise, feel free to share them.
Regards,
Mihaela
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/.