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

[Solved] Rebind grid issue

1 Answer 54 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.
Adrian
Top achievements
Rank 1
Adrian asked on 30 Oct 2011, 10:16 AM
I am testing telerik controls and i have to say they are great , i have a bit of an issue with the grid though.
I have this grid declaration:

@( Html.Telerik().Grid<csec.Models.SchoolInfo>()
        .Name("schoolsGrid")
        .DataBinding(dataBinding => dataBinding.Ajax().OperationMode(GridOperationMode.Client).Select("SchoolsGridDataSource", "Schools"))
        .Columns(columns =>
            {
                columns.Bound(r => r.Id).Hidden(true);
                columns.Bound(r => r.Name);
                columns.Bound(r => r.Address);
                columns.Bound(r => r.Phone);
            })
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .Selectable()
        .Scrollable(c=>c.Height("255px"))
        .Pageable()        
        //.ClientEvents(e => e.OnDataBinding("OnDataBinding"))
        .ToolBar(toolBar => toolBar.Template(
            @<text>
                <div id="schTb">
                    @Html.ActionLink("Add", "Add", "Schools", new { @class = "t-button" })
                    <input type="button" value="Delete" onclick="Delete()" class="t-button" />
                </div>
            </text>
        ))
)

function Delete() {
        var selRows = $("#schoolsGrid table tbody tr.t-state-selected");
        var selId = (selRows.length != 1) ? -1 : selRows[0].children[0].innerHTML;
        if (selid == -1) {
            alert('Select something');
            return;
        }
        $.ajax({
            url: '@Url.Action("HandleSchoolsDelete")',
            type: 'POST',
            dataType: 'json',
            data: { idSchool: selId },
            success: function (data) {
                if (data.Deleted == 0) {
                    $("#schoolsGrid").data("tGrid").rebind();
                }
            }
        });
    }

The grid action is this:
      [GridAction]
       public ActionResult SchoolsGridDataSource()
        {
            return View(new GridModel<csec.Models.SchoolInfo>
            {
                Data = new Ss().GetSchools()
            });
        }

The school is deleted from the database, data.Deleted = 0 on the callback but the grid does not rebind, i have to hit f5 to see the changes.
What am i missing in here?
Thanks.

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 01 Nov 2011, 03:59 PM
Hi Adrian,

Make sure that you are using SP1 - we've had a similar problem fixed there. If this doesn't help, please send us a sample project so we can investigate further.


Kind regards,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Adrian
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or