I have a detail template like this example http://demos.telerik.com/aspnet-mvc/grid/detailtemplate. Hte thing is that i want to send the selected rows values to a controller.
When i have a simple grid i send the selected values like this :
$('#send').click(function () {
var items = {};
var grid = $('#GridMarcaPar').data('kendoGrid');
var selectedElements = grid.select();
for (var j = 0; j < selectedElements.length; j++) {
var item = grid.dataItem(selectedElements[j]);
items['GridMarcaPar[' + j + '].CodMarca'] = item.CodMarca;
}
$.ajax({
url: '@Url.Action("Index", "Busqueda")',
type: "POST",
async: false,
data: items,
success: function (result) {
console.log(result);
}
})
})
But when i try to send the selected values of the detail template like this it never call the action Index:
$('#send').click(function () {
var items = {};
var grid = $('#grid_#=CodMarca#').data('kendoGrid');
var selectedElements = grid.select();
for (var j = 0; j < selectedElements.length; j++) {
var item = grid.dataItem(selectedElements[j]);
items['grid_#=CodMarca#[' + j + '].CodMarca'] = item.CodMarca;
}
$.ajax({
url: '@Url.Action("Index", "Busqueda")',
type: "POST",
async: false,
data: items,
success: function (result) {
console.log(result);
}
})
})
This is my detail template code:
<script id="client-template" type="text/x-kendo-template">
@(Html.Kendo().TabStrip()
.Name("tabStrip_#=CodMarca#")
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text("Más Datos").Content(@<text>
@(Html.Kendo().Grid<TelerikMvcApp4.Models.MarcaParecido>()
.Name("grid_#=CodMarca#")
.Columns(columns =>
{
columns.Bound(o => o.DescMarca).Title("Marca").Width(110);
columns.Bound(o => o.DescTitular).Title("Titular").Width(300);
columns.Bound(o => o.PorcentajeSimilitud).Title("% Similitud").Width(70)
.HtmlAttributes(new { style = "text-align:right" });
columns.Bound(o => o.PorcentajeError).Title("% Error").Width(70)
.HtmlAttributes(new { style = "text-align:right" });
columns.Bound(c => c.EnviarCorreo).ClientTemplate("<input type='checkbox' />").Title("¿Enviar?").Filterable(false).Width(120).HtmlAttributes(new { @onclick = "click" });
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("MarcaParecidoDetalle", "Busqueda", new { codMarca = "#=CodMarca#" }))
)
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.ToClientTemplate())
</text>
);
})
.ToClientTemplate()
)
</script>
I hope someone can help me.