Check box Grid

1 Answer 134 Views
Grid
vivek
Top achievements
Rank 1
vivek asked on 04 Aug 2021, 04:17 AM

The ASP.Net Core project is using the Kendo grid.

 

 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

Sort by
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>
function onChange(e) {
  var selectedItem = this.value(); //get the selected DropDownList option
  var gridWidget = $("#grid").data("kendoGrid"); //get an instance of the Grid
  var selectedRows = gridWidget.select(); //get the selected rows
  $(selectedRows).each(function () { //loop through the selected rows
    var selectedRow = $(this);  //the selected table row
    var 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/.

Tags
Grid
Asked by
vivek
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or