Here is the scenario. I have a Kendo grid of a VIEW(3 joined tables) not of a table. I have created a checkbox that is bound to the primary key field. After hours of searching I figured out how to select and deselect all of the checkboxes by clicking the header. I cannot however figure out how to send multibple ID's to the controller so that I can validate and update the records.
My idea is to have javasciprt iterate through the list and compile a delimited string of ID's which would be stored in a hidden field. Easy peasy right? No of course not. I have tried and searched high and low and nothing works. Very frustrating.
I did find some javascript code that doesnt do what I want but I tried to modify it and make it work. Can't do it. Can anybody help me out there? The code I found is below... I don't need the last part of it because I am not doing any updating on the client side. I just need to get the values to the controller... any help is appreciated.
<script>
$(document).ready(function () {
$("#update").click(function() {
var grid = $("#Grid").data("kendoGrid");
var value = $("#Name").data("kendoDropDownList").value();
var models = [];
//find the selected models
grid.tbody
.find(":checked")
.closest("tr")
.each(function () {
models.push(grid.dataItem(this));
});
//update the models value
for (var i = 0, length = models.length; i < length; i++) {
models[i].set("Name", value);
}
//submit the value to the server
grid.dataSource.sync();
});
});
</script>
My idea is to have javasciprt iterate through the list and compile a delimited string of ID's which would be stored in a hidden field. Easy peasy right? No of course not. I have tried and searched high and low and nothing works. Very frustrating.
I did find some javascript code that doesnt do what I want but I tried to modify it and make it work. Can't do it. Can anybody help me out there? The code I found is below... I don't need the last part of it because I am not doing any updating on the client side. I just need to get the values to the controller... any help is appreciated.
<script>
$(document).ready(function () {
$("#update").click(function() {
var grid = $("#Grid").data("kendoGrid");
var value = $("#Name").data("kendoDropDownList").value();
var models = [];
//find the selected models
grid.tbody
.find(":checked")
.closest("tr")
.each(function () {
models.push(grid.dataItem(this));
});
//update the models value
for (var i = 0, length = models.length; i < length; i++) {
models[i].set("Name", value);
}
//submit the value to the server
grid.dataSource.sync();
});
});
</script>