I have a WebGrid, which I can load without problems through the past model in sight (MVC C # .net). Until there is no problem.
But the need arises to be able to load another WebGrid control, but for that I need as parameter the Id of the selected registry in the previous WebGrid. and to get the data I have a call to the controller through ajax, but I can not pass the data to the second webgrid even though I have specified the ajaxUpdateCallback parameter giving it the name of the function that makes the ajax call.
this is my code
definition of the webgrid that I want to load through ajax
WebGrid gridProcesosKam = new WebGrid(null, null, null, 8, true, true, ajaxUpdateCallback: "GetProcesosKam", ajaxUpdateContainerId: "DivProcesosKam");
In this case, the promer parameter corresponding to the model is null.
here is the function JS that calls brings the data
<script>
function GetProcesosKam() {
var KamId = 12; // dato de pruebas
var parametrosAjax = {
"sKamId": KamId
};
$.ajax({
type: 'POST',
async: false,
data: JSON.stringify(parametrosAjax),
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: '@Url.Action("GetProcesosKam", "Proceso")',
success: function (lstProcesosKam) {
},
error: function (error) {
var msgError = 'Error en el procesamiento de los proceso...';
$('#DivProcesosKam').html(msgError);
}
});
this is the body of the webgrid
<div id="DivProcesosKam" class="display">
@gridProcesosKam.GetHtml(
fillEmptyRows: true,
alternatingRowStyle: "fila-alternativa",
headerStyle: "encabezado-grid",
footerStyle: "pie-grid",
mode: WebGridPagerModes.All,
firstText: "<< Primera",
previousText: "< Anterior",
nextText: "Siguiente >",
lastText: "Última >>",
columns: new[] {
gridProcesosKam.Column("ProcesoId"),
gridProcesosKam.Column("Cliente"),
gridProcesosKam.Column("Proceso"),
gridProcesosKam.Column("Fecha", format: p=>p.Fecha.ToShortDateString()),
gridProcesosKam.Column("Cargados"),
gridProcesosKam.Column("Validados"),
gridProcesosKam.Column("Erroneos"),
gridProcesosKam.Column("Estado"),
gridProcesosKam.Column(
"",
header: "Acciones",
format: @<text>
@Html.ActionLink("Cargar", "UploadFile", new { sProcesoId=item.ProcesoId } )
|
@Html.ActionLink("Ver", "GetFichasProceso", new { sProcesoId=item.ProcesoId} )
</text>)
})
When I run, a message appears telling me that I need a data source.
Can someone give me a hand with this? What am I doing wrong? is this how data is loaded in a webgrid through ajax?
Greetings and thanks for reading.