asp.net mvc - how to get values of checked rows in kendo ui grid? -


I am trying to get the values ​​of rows of selected rows in a condo grid. Please see, for example, on a button click, I have to get all the names or IDs of names selected as an array or a comma separated string. How can I do that? Thank you.

Kando Grid

  $ ('# getNames'). Click (function () {// How to get all the names of the selected rows? Warning ('You have selected these people:')}); $ ("# Grid"). Kendo Grid ({Data Source: {Type: "Odata", Transport: {read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"}, page: size: 10} Groupable: True, Sortable: Correct, Page Eligible: {Fresh: Right, Page Size: Right, ButtonCount: 5}, Columns: [[Field: "", Title: "", Template: "& lt; Input Type = 'checkbox' name = 'selectcandidate' / & gt;}, {Region: "ContactName", Title: "Contact Name", Width: 200}, {Field: "ContactTitle", Title: "Contact Title", Width : 250}, {field: "company name", title: "Company name"}, {field: "country", width: 150}]});    

You should: Get the selected rows of reference

  // Grid object var grid = $ (" # grid "). Var sel = grid.select (); // Receive data items for each var item = []; $ .each (sel, function (idx, line) {var item = grid.dataItem (line), item Push (item);}); // View results console.log ("item", item);   

The only question is that you have to retrieve the data items at one time and then have to create an array with all of them if you need it.

Check it out here:

Edit If you want to get the rows in which the checkbox is clicked, you should: / P>

  // get reference var grid = $ ("# grid") in grid object. Data ("candrog"); // View selected rows var sel = $ ("Input: checked", grid.tbody) .closest ("tr"); // Receive data items for each var item = []; $ .each (sel, function (idx, line) {var item = grid.dataItem (line), item.push (item);}); Warning ("Selected:" + JSON.stringify (item));   

See it here:

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -