This is a migrated thread and some comments may be shown as answers.

Sending multilpe record ID's to the Controller from Kendo Grid

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PAUL
Top achievements
Rank 1
PAUL asked on 12 Sep 2012, 09:41 PM
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>

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Sep 2012, 08:10 AM
Hi PAUL,

Could you please check your other forum thread on this matter where we have already answer  your question.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
PAUL
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or