This question is locked. New answers and comments are not allowed.
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.
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.