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

[Solved] update grid using ajax

0 Answers 171 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
david
Top achievements
Rank 1
david asked on 30 Sep 2010, 11:46 AM
hi, i wonder if anyone here can assist with what i'm trying to achieve.
I have a ajax databound grid which works...updating a single line row after edit works using the following:

                .DataBinding(dataBinding => dataBinding.Ajax()
                    .Select("_SelectAjaxDataBinding", "Home")
                    .Update("_Update", "Home"))
                .Columns(columns =>
etc.

but i've created a column with checkboxes on which stores the row id in (see example posted here http://www.telerik.com/community/forums/aspnet-mvc/grid/in-search-of-mvc-grid.aspx).  this allows the user to select multiple rows and apply changes using the UI to update a batch amount of values for all selected rows. 

I do this by using jscript, i create a copy of the json object which is stored in the grid and create a temp json object which holds all selected items from the telerik grid:
        var OnCheckBoxChanged = function () {

            var $checkedRow = $(this);
            var itemid = $checkedRow.attr('value');
            if ($checkedRow.is(':checked')) {
                $.each(myOb, function () {

                    if (this.Id === itemid) {
                        tempOb[this.Id] = this;
                    }
                });
                console.log(tempOb);
            }
            else {
                delete tempOb[itemid];
                console.log(tempOb);
            }
        };

this allow me to update my temp json object with updated values. 
but i need to write those files back into the telerik grid..
so how can i manually call the .update method defined on in the telerik grid and pass my new model back to the controller?
So ideally, i want the values i've just updated in my temp object to be displayed back into the grid..and using an input button i would write the changes back into the database.
thanks,
Tags
Grid
Asked by
david
Top achievements
Rank 1
Share this question
or