Hi, I've a page with 2 grids. Both of them has buttons to add elements, moreover I can pass data from one to the other. The problem that I've is that the grids data it's not reloaded. Once I try to reload the grids get empty and the function to load the data in the controller it's not called, also the code is showing I'm passing throught the dataSource.read(), the console.logs() are printed correctly. This was working 5 days ago, since then any change has been done on the cshtml and on the controller files.
Any help will be appreciated.
Thanks in advance.
These are my functions to reload the grids (javascript)
**************************************************************************************************
function reloadOrigenDestino(reloadALL = false) {
if (esOrigen == true || esOrigen == 'True' || reloadALL ) reload(true);
if (esOrigen == false || esOrigen == 'False' || reloadALL ) reload(false);
}
function reload(_esOrigen) {
if (_esOrigen) {
console.log('**** reload es origen');
$("#listaOrigen").data("kendoGrid").dataSource.read();
}
else {
console.log('*** reload es destino');
$("#listaDestino").data("kendoGrid").dataSource.read();
}
}
**************************************************************************************************
This is my html whith the 2 grids (both of them with different ids)
*************************************************************************************************
<!-- ************** GRID ORIGEN************** -->
<div class="bt_col_4">
<h3>@Estudios.labelForOrigen</h3>
@(Html.Kendo().Grid<Bogem.Areas.Estudios.Models.EstudiosOrigenDestinoVM>()
.Name("listaOrigen")
.Columns(columns =>
{
columns.Bound(c => c.IdOrigenDestino).Hidden(true);
columns.Bound(c => c.EsOrigen).Hidden(true);
columns.Bound(c => c.CodigoPostal).Visible(true);
columns.Bound(c => c.Poblacion).Visible(true);
columns.Bound(c => c.Alias).Visible(true);
columns.Bound(c => c.Punto).Visible(true);
columns.Bound(o => o.IdOrigenDestino).Title(Resources.Editar).Width(45).MinResizableWidth(45).Sortable(false).Filterable(false)
.ClientTemplate("<a href='javascript:(showAddEditOrigenDestino(#= IdOrigenDestino #, #= EsOrigen #));'><i class='k-icon k-i-edit k-icon-22'></i></a>")
.HtmlAttributes(new { style = "text-align: center" })
.Visible((bool)ViewData["canEdit"]).ToString();
columns.Bound(o => o.IdOrigenDestino).Title(Resources.Eliminar).Width(45).MinResizableWidth(45).Sortable(false).Filterable(false)
.ClientTemplate("<a href='javascript:(showDialogDeleteOrigenDestino(#= IdOrigenDestino #, #= EsOrigen #));'><i class='k-icon k-i-trash k-icon-22'></i></a>")
.HtmlAttributes(new { style = "text-align: center" })
.Visible((bool)ViewData["canDelete"]).ToString();
})
.ToolBar(toolbar =>
{
if ((bool)ViewData["canAdd"]) toolbar.Custom().IconClass("k-icon k-i-add k-icon-22").Text(Estudios.titleForAddOrigen).Url("#").HtmlAttributes(new { onclick = "showAddEditOrigenDestino(-1, '" + true + "');" });
})
.HtmlAttributes(new { style = "text-align: right" })
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.MultipleColumn);
})
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains(Resources.filtroContains)
.IsEqualTo(Resources.filtroEqualTo)
.IsNotEqualTo(Resources.filtroNotEqualTo)
)
)
)
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.Editable(edit => edit.Mode(GridEditMode.PopUp))
.Scrollable()
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.IdOrigenDestino))
.Read(read => read.Action("CargaListadoNuevo", "OrigenDestino", new { esOrigen = true }))
)
)
</div>
<!-- ************** GRID DESTINO ************** -->
<div class="bt_col_4">
<h3>@Estudios.labelForDestino</h3>
@(Html.Kendo().Grid<Bogem.Areas.Estudios.Models.EstudiosOrigenDestinoVM>()
.Name("listaDestino")
.Columns(columns =>
{
columns.Bound(c => c.IdOrigenDestino).Visible(false);
columns.Bound(c => c.EsOrigen).Visible(false);
columns.Bound(c => c.CodigoPostal).Visible(true);
columns.Bound(c => c.Poblacion).Visible(true);
columns.Bound(c => c.Alias).Visible(true);
columns.Bound(c => c.Punto).Visible(true);
columns.Bound(o => o.IdOrigenDestino).Title(Resources.Editar).Width(45).MinResizableWidth(45).Sortable(false).Filterable(false)
.ClientTemplate("<a href='javascript:(showAddEditOrigenDestino(#= IdOrigenDestino #, #= EsOrigen #));'><i class='k-icon k-i-edit k-icon-22'></i></a>")
.HtmlAttributes(new { style = "text-align: center" })
.Visible((bool)ViewData["canEdit"]).ToString();
columns.Bound(o => o.IdOrigenDestino).Title(Resources.Eliminar).Width(45).MinResizableWidth(45).Sortable(false).Filterable(false)
.ClientTemplate("<a href='javascript:(showDialogDeleteOrigenDestino(#= IdOrigenDestino #, #= EsOrigen #));'><i class='k-icon k-i-trash k-icon-22'></i></a>")
.HtmlAttributes(new { style = "text-align: center" })
.Visible((bool)ViewData["canDelete"]).ToString();
})
.ToolBar(toolbar =>
{
if ((bool)ViewData["canAdd"]) toolbar.Custom().IconClass("k-icon k-i-add k-icon-22").Text(Estudios.titleForAddOrigen).Url("#").HtmlAttributes(new { onclick = "showAddEditOrigenDestino(-1, '" + false + "');" });
})
.HtmlAttributes(new { style = "text-align: right" })
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.MultipleColumn);
})
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains(Resources.filtroContains)
.IsEqualTo(Resources.filtroEqualTo)
.IsNotEqualTo(Resources.filtroNotEqualTo)
)
)
)
.Editable(edit => edit.Mode(GridEditMode.PopUp))
.Scrollable()
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.IdOrigenDestino))
.Read(read => read.Action("CargaListadoNuevo", "OrigenDestino", new { esOrigen = false }))
)
)
</div>
**************************************************************************************************
My read function from server
*************************************************************************************************
[BogemAuthorization(Option = OpcionesModulo.ESTU_G_ORGDEST, NivelAcceso = new TipoAcceso[] { TipoAcceso.Lectura })]
public ActionResult CargaListado([DataSourceRequest]DataSourceRequest request, bool esOrigen)
{
List<EstudiosOrigenDestinoBO> estudios = new List<EstudiosOrigenDestinoBO>();
if (esOrigen) estudios = _origenDestinoBL.GetOrigenes(GetCurrentEstudio()).ToList().Where(x => x.IdSysState == (int)SystemState.Active).ToList();
else estudios = _origenDestinoBL.GetDestinos(GetCurrentEstudio()).ToList().Where(x => x.IdSysState == (int)SystemState.Active).ToList();
foreach (EstudiosOrigenDestinoBO item in estudios)
{
item.Poblacion = _poblacionBL.GetPoblacion(item.IdPoblacion).Poblacion;
item.CodigoPostal = _codigoPostalBL.GetCodigoPostal(item.IdCP).CP;
}
DataSourceResult result = estudios.ToDataSourceResult(request, _estudios => new
{
IdOrigenDestino = _estudios.IdOrigenDestino,
IdEstudio = _estudios.IdEstudio,
EsOrigen = _estudios.EsOrigen,
IdCP = _estudios.IdCP,
IdPoblacion = _estudios.IdPoblacion,
Alias = _estudios.Alias,
Punto = _estudios.Punto,
IdSysState = _estudios.IdSysState,
CodigoPostal = _estudios.CodigoPostal,
Poblacion = _estudios.Poblacion
});
return Json(result);
}