Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Tag helper Admin-Tabstrip - further improvements

KrzysztofPajak86bf00609356
diff --git a/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js b/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js
index e0a3a4a56..ca22c9043 100644
--- a/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js
+++ b/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js
@@ -72,6 +72,7 @@ function tabstrip_on_tab_show(e) {
var grid = $(this).data('kendoGrid');
grid.dataSource.page(1);
});
+
}
diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
index c6ef64bb7..6420cbd8f 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
@@ -44,6 +44,8 @@ namespace Grand.Web.Common.TagHelpers.Admin
if (_detectionService.Device.Type == Device.Mobile || _detectionService.Device.Type == Device.Tablet)
SetTabPos = false;
+ var selectedTabIndex = GetSelectedTabIndex();
+
output.TagName = "div";
output.Attributes.SetAttribute("id", Name);
output.Attributes.SetAttribute("style", "display:none");
@@ -56,7 +58,7 @@ namespace Grand.Web.Common.TagHelpers.Admin
sb.AppendLine($" tabPosition: '{(SetTabPos ? "left" : "top")}',");
sb.AppendLine($" animation: {{ open: {{ effects: 'fadeIn'}} }},");
sb.AppendLine(" select: tabstrip_on_tab_select,");
- if(BindGrid)
+ if (BindGrid)
sb.AppendLine(" show: tabstrip_on_tab_show");
sb.AppendLine(" }).data('kendoTabStrip');");
@@ -72,10 +74,21 @@ namespace Grand.Web.Common.TagHelpers.Admin
sb.AppendLine("});");
}
+
+ if (BindGrid && selectedTabIndex > 0)
+ {
+ sb.AppendLine("$(window).load(function() {");
+ sb.AppendLine($" var selectedtab_{rnd} = $('#{Name}').data('kendoTabStrip').select(); ");
+ sb.AppendLine($" tabstrip_on_tab_show(selectedtab_{rnd}); ");
+ sb.AppendLine("});");
+ }
+
sb.AppendLine("})");
+
+
sb.AppendLine("</script>");
- sb.AppendLine($"<input type='hidden' id='selected-tab-index' name='selected-tab-index' value='{GetSelectedTabIndex()}'>");
+ sb.AppendLine($"<input type='hidden' id='selected-tab-index' name='selected-tab-index' value='{selectedTabIndex}'>");
output.PostContent.AppendHtml(string.Concat(list));
@@ -84,8 +97,6 @@ namespace Grand.Web.Common.TagHelpers.Admin
private int GetSelectedTabIndex()
{
- //keep this method synchornized with
- //"SetSelectedTabIndex" method of \Administration\Controllers\BaseGrandController.cs
int index = 0;
string dataKey = "Grand.selected-tab-index";
if (ViewContext.ViewData[dataKey] is int)