Skip to content

Commit

Permalink
Fix: Excel Download: Row count to hide Excel download not always corr…
Browse files Browse the repository at this point in the history
…ect #1046
  • Loading branch information
geofranzi committed Feb 10, 2023
1 parent f32503f commit 33c9fc3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public ActionResult ShowData(long id, int version = 0, string versionName = "")
if (dsv.Dataset.DataStructure.Self.GetType().Equals(typeof(StructuredDataStructure)))
{
dataStructureType = DataStructureType.Structured.ToString();
ViewData["gridTotal"] = dm.RowCount(dsv.Dataset.Id, null);
}
else
{
Expand Down Expand Up @@ -373,6 +374,7 @@ public ActionResult Reload(long id, int version = 0)
if (dsv.Dataset.DataStructure.Self.GetType().Equals(typeof(StructuredDataStructure)))
{
dataStructureType = DataStructureType.Structured.ToString();
ViewData["gridTotal"] = dm.RowCount(dsv.Dataset.Id, null);
}
else
{
Expand Down Expand Up @@ -617,12 +619,12 @@ public ActionResult ShowPrimaryData(long datasetID, int versionId)
ModelState.AddModelError(string.Empty, "The data is not available, please ask the administrator for a synchronization.");
}

Session["gridTotal"] = dm.RowCount(dsv.Dataset.Id, null);
ViewData["gridTotal"] = dm.RowCount(dsv.Dataset.Id, null);
}
else
{
table = dm.GetDatasetVersionTuples(versionId, 0, 10);
Session["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
ViewData["gridTotal"] = dm.GetDatasetVersionEffectiveTuples(dsv).Count;
}

sds.Variables = sds.Variables.OrderBy(v => v.OrderNo).ToList();
Expand Down Expand Up @@ -713,7 +715,7 @@ public ActionResult _CustomPrimaryDataBinding(GridCommand command, string column
}

model = new GridModel(table);
model.Total = Convert.ToInt32(Session["gridTotal"]); // (int)Session["gridTotal"];
model.Total = Convert.ToInt32(Session[versionId + "gridTotal"]); // (int)Session["gridTotal"];
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions Console/BExIS.Web.Shell/Areas/DDM/Views/Data/ShowData.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
}

int total = 0;
if (Session["gridTotal"] != null)
if (ViewData["gridTotal"] != null)
{
total = Convert.ToInt32(Session["gridTotal"]); // (int)Session["gridTotal"];
total = Convert.ToInt32(ViewData["gridTotal"]); // (int)Session["gridTotal"];
}


Expand Down Expand Up @@ -61,7 +61,6 @@

@if (Model != null && ((Model.IsPublic == true || User.Identity.Name != "") || check_public_metadata == "false"))
{

<div id="showData">
<div id="showData">
<h1>@Model.Title</h1>
Expand Down Expand Up @@ -114,10 +113,11 @@
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" style="z-index:100000; margin-top:10px;">
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsm", version = Model.VersionId })">... with Template</a></li>

@if (@total < 1048576) // hide Excel download for bigger datasets, which exceed the max number of rows in excel
{
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsx", version = Model.VersionId })">... with Excel</a></li>
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsm", version = Model.VersionId })">... with Template</a></li>
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "application/xlsx", version = Model.VersionId })">... with Excel</a></li>
}
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/csv", version = Model.VersionId })">... with CSV</a></li>
<li><a href="@Url.Action("DownloadZip", "Data", new { id = @Model.Id, format = "text/tsv", version = Model.VersionId })">... with TSV</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
pagerStyles |= GridPagerStyles.Numeric;

int total = 0;
if (Session["gridTotal"] != null)
if (ViewData["gridTotal"] != null)
{
total = Convert.ToInt32(Session["gridTotal"]); // (int)Session["gridTotal"];
total = Convert.ToInt32(ViewData["gridTotal"]); // (int)Session["gridTotal"];
}

string compareValues = String.Join(";", Model.CompareValuesOfDataTypes.ToArray());
Expand Down

0 comments on commit 33c9fc3

Please sign in to comment.