Hi,
NOTE: removed the clientEvent OnDataBound from current Grid.
I cant get my grid to refresh. Controller Action gets called during ajax request, but grid doesnt refresh. Fiddler shows proper GridModel (Json) data returned. Please help.
Ben
Controller
************************************************************
[GridAction(EnableCustomBinding = true)]
public ActionResult _CompanyIndex(GridCommand command, int? id = 0)
{
var _list = new List<MasterContactCompanyViewModel>();
if(id.Value > 0)
{
var _companies = _contactCompanyRepository.GetByMasterContactId(id.Value);
_list = MasterContactCompanyViewModelFactory.ToMasterContactCompanyViewModel(_companies);
}
var _count = _list.Count();
ViewData["total"] = _count;
ViewData["pageSize"] = command.PageSize;
ViewData["pageTo"] = command.Page;
return View(new GridModel { Data = _list, Total = _count });
}
******************************************************************************
View
*******************************************************************************
@(Html.Telerik().Grid(Model.Companies)
.Name("grdCompanyList")
.DataKeys(keys => keys.Add(o => o.MnetCompanyID))
.ToolBar(commands => commands.Template(@<text>@if (Model.Companies == null || Model.Id > 0 && Model.Companies.Count > 0){<button type="button" title="Edit" onclick="addCompany();" class="t-button">Add new company</button>}</text>))
.Columns(columns =>
{
columns.Bound(o => o.MnetCompanyID).Width(150);
columns.Bound(o => o.CompanyName);
columns.Bound(o => o.CustomerNumbers).Template(o => CustomerNumbersTemplate(this, o.CustomerNumbers)).Sortable(false);
columns.Bound(o => o.MnetCompanyID).Title("").Sortable(false).Width(150)
.Template(@<text>@if (Model.Id > 0 && Model.Companies.Count > 1){<button type="button" title="Delete" onclick="deleteCompany(@item.MnetCompanyID);" class="t-button"> Delete</button>}</text>)
.ClientTemplate("<button type='button' title='Delete' onclick='deleteCompany(<#= MnetCompanyID #>);' <#= Model.Id > 0 && Model.Companies.Count > 1 ? \"style='display:block'\" : \"\" #> class='t-button'>Delete</button>");
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CompanyIndex", "MasterContact", new {id = Model.Id}).Enabled(true))
.NoRecordsTemplate("No Results")
.Pageable(page => page.PageSize(20).Position(GridPagerPosition.Bottom))
.Scrollable()
.Sortable()
.EnableCustomBinding(true)
)
************************************************************************
javascript refresh
**********************************************************************
var grid = $("#grdCompanyList").data("tGrid");
grid.ajaxRequest();