I am new to ASP.net and trying to modify a page where it shows list of data into html. Due to the fact that bindata being enormous, it takes longer to load this page.
When I think of solution to this, I thought of creating a event for each individual button @item.zone, process bindata, and append to the html. SO if I click on one of header tag/button, It would then process bindata and show the data correspond to it. However, since I can not access c# variable from client side, I wasn't able to do so.
I measured the execution time for the C# code, noticed that the nested forloop is taking most of loading time.
Is there any right? preferable? recommended approach to this issue?
@model ValueDataSet[]
@{
ViewBag.Title = "Bin List View";
Pallet[] ActivePallets = ViewBag.ActivePalletArr;
var bindata = Model.GroupBy(x => new { x.description }).Select(x => new
{
Zone = x.Key.description,
Location = x.Select(s => new
{
PalletItem = ActivePallets.FirstOrDefault(a => a.GetLocation() == s.key),
BIN = s.key,
LOCATION = s.value
}).Select(s => new
{
PalletItem = s.PalletItem,
Aging = (DateTime.Now - (s.PalletItem?.CreatedOn ?? DateTime.Now)).Days,
BIN = s.BIN,
LOCATION = s.LOCATION
})
}).OrderByDescending(x => x.Zone).ToArray();
List<StagingPallets> StagingPalletList = ViewBag.StagingPalletList;
var widthpercent = (100m / (decimal)bindata.Length).ToString("0.00");
}
@{ var zoneidx = 0;}
@foreach (var item in bindata)
{
<h5><b onclick="toggledetails(@(zoneidx))" style="cursor:pointer;">@item.Zone (@(item.Location.Where(x => x.PalletItem != null).Count()) / @(item.Location.Count()))</b></h5>
<div class="zonewidth toggledetail_@zoneidx" style="display:none;">
@foreach (var bin in item.Location)
{
var order = bin.PalletItem?.ContainerItem?.OrderItem ?? new OrderItem();
<div class="binlocation @(bin.Aging > 12 ? "aging2" : bin.Aging > 0 ? "aging1" : "")">
@bin.BIN (@bin.Aging)
<div>
<small>@(bin.PalletItem?.LicensePlate)</small>
<small><a href="/order/edit/@order.ItemKey" target="_blank">@order.OrderNumber</a></small>
</div>
</div>
}
</div>
zoneidx++;
}
bindata? I see you already had a JS event handlertoggledetails(@(zoneidx))to do something, what's the problem with that?toogledetails(@(zoneidx))is just java script to open and unfold selected div. nothing wrong with javascript