0
I changed the question to make it clearer, it was dirty and now I understand the problem better. When I open the list, I have a Details button. When I click on this button, I open the details screen and on this screen a Dropdownlist. It happens that when I click on Dropdown, a jquery is triggered that should repopulate the grid, already with the new id and etc. This repopulation is a Partialview that should be loaded and is not being, only the complete view and so the Footer is doubling. I cannot identify in Controller when the call is from View and when it is from Jquery. If I could do this, in the controller I would be able to return to View or Partialview("name"). I will post Controller and jquery.
[HttpGet]
public ActionResult Details(AzureDiscountGroupModel model, int id)
{
ViewBag.Indice = id;
var discount = _azureDiscountGroupService.GetAll();
var list = new List<ResellerListModel>();
var resellers = _resellerService.QueryAll()
.Include(r => r.WhiteLabels)
.ToList();
foreach(var item in resellers)
{
list.Add(CreateListModelFrom(item));
}
ViewBag.Desconto = discount.Where(x => x.Id > 0);
ViewBag.DetailReseller = list.Where(x => x.AzureDiscountGroupId == id).ToList();
//aqui deveria fazer um if para uma chamada ou outra
return PartialView();
}
This is my jquery
$(document).ready(function () {
$("#GrupoDescontos").change(function () {
var $div = $('#GridPartial');
$div.html('');
$.ajax
({
url: '' + $(this).val(),
type: 'GET',
success: function (dados) {
$div.html(dados);
},
error: function (erro) {
}
});
});
});
How do I identify a View call or if it’s from Jquery?
The following, I can resolve by passing a parameter from the View Index call. Well, that works, but Partialview is just a table and when I call from jquery, there is no more header and dropdown. If I put these details in Partialview, in the first load coming from Index, then everything is duplicated.
– pnet
I solved in part. I step one parameter and remove all the View. I left only the div where the partialview would be populated. This has solved itself, the problem is that I can not make more than one call by Dropdownlist. I do an ok, but from there it does not run more
– pnet
When you ask about a problem in your code, you’ll get better answers if you give people code that they can use to reproduce the problem. See how to create a minimum, complete and verifiable example to use in your question.
– Sorack