2
I’m returning a data list of an object type (GAR) function actualizarGARs
controller’s:
var listaGARTratadas = db.GAR.ToList();
return Json(listaGARTratadas);
And in javascript I wanted to send this list of objects again to another function (carregaGARsCriadas
):
$.getJSON("/GAR/actualizarGARs", { carimbo: carimbo, CaixaFisicaGAR: $("#CaixaFisicaGAR").val() },
function (result) {
$("#divListagemGARActualizadas").empty();
$("#divListagemGARActualizadas").load("/GAR/carregaGARsCriadas", {garsCriadas: result});
}
Where do I get this list of objects passed on result
:
public ActionResult carregaGARsCriadas(List<GAR> garsCriadas) {
return PartialView("listaGARsCriadas");
}
The problem is that I receive the variable garsCriadas
with the correct number of elements in the object (for example 5), but the content of each element is null
Knows the
BeginCollectionItem
? http://answall.com/questions/15804/d%C3%Bavida-em-constru%C3%A7%C3%A3o-de-view-e-controller-with-entity-dependent-of-cardinalide/15809#15809– Leonel Sanches da Silva
What’s in the
result
?– Sergio
The
result
has a list of data of typeGAR
. If I make one.each
with theresult
, the data is there. What I wanted was to pass this list to the functioncarregaGARsCriadas
– CesarMiguel
@Ciganomorrisonmendez, I’ve been taking a look but I think it’s not what I want. I
.getJson
for the function/GAR/actualizarGARs
I’m processing data, I justvar listaGARTratadas = db.GAR.ToList();
to simplify the question– CesarMiguel
@Cesarmiguel Se is producing 5 objects with null values of properties, means that the
ModelBinder
is getting lost in creating the objects with the values. That’s why theBeginCollectionItem
. He solves exactly this part.– Leonel Sanches da Silva
@Ciganomorrisonmendez, I’m still not putting the data in partial. Soon in my function
carregaGARsCriadas
I check that the list of objects passed on.load
wrong way. For example, instead of receiving an item with the data:["idGAR: 12", "SerieGAR:19", etc etc]
receiving["idGAR: 0", "SerieGAR:null", etc etc]
– CesarMiguel
I get it. I already tell you that there is no easy answer, because you need to serialize an object that has already been dehydrated.
– Leonel Sanches da Silva
Yes, it even makes sense that the object has been dehydrated
– CesarMiguel