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.

Improve tag helper - admin-tabstrip - param BindGrid - if you enable this setting bind for grid data will be after show tab - kendo grid must have set property autoBind = false

KrzysztofPajak9fd32266d534
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 580012fda..e0a3a4a56 100644
--- a/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js
+++ b/src/Web/Grand.Web.Admin/wwwroot/administration/admin.common.js
@@ -63,11 +63,18 @@ function checkOverriddenStoreValue(obj, selector) {
}
function tabstrip_on_tab_select(e) {
- //we use this function to store selected tab index into HML input
- //this way we can persist selected tab between HTTP requests
$("#selected-tab-index").val($(e.item).index());
}
+
+function tabstrip_on_tab_show(e) {
+ $('.k-state-active').find('[data-role="grid"]').each(function (x) {
+ var grid = $(this).data('kendoGrid');
+ grid.dataSource.page(1);
+ });
+}
+
+
function display_kendoui_grid_error(e) {
if (e.errors) {
if ((typeof e.errors) == 'string') {
diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
index 85b3c3ff6..c6ef64bb7 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminTabStripTagHelper.cs
@@ -27,6 +27,9 @@ namespace Grand.Web.Common.TagHelpers.Admin
[HtmlAttributeName("SetTabPos")]
public bool SetTabPos { get; set; } = false;
+ [HtmlAttributeName("BindGrid")]
+ public bool BindGrid { get; set; } = false;
+
[HtmlAttributeName("Name")]
public string Name { get; set; }
@@ -50,9 +53,11 @@ namespace Grand.Web.Common.TagHelpers.Admin
sb.AppendLine("$(document).ready(function () {");
sb.AppendLine($"$('#{Name}').show();");
sb.AppendLine($"var tab_{rnd} = $('#{Name}').kendoTabStrip({{ ");
- sb.AppendLine($" tabPosition: '{(SetTabPos ? "left" : "top")}',");
- sb.AppendLine($" animation: {{ open: {{ effects: 'fadeIn'}} }},");
- sb.AppendLine(" select: tabstrip_on_tab_select");
+ sb.AppendLine($" tabPosition: '{(SetTabPos ? "left" : "top")}',");
+ sb.AppendLine($" animation: {{ open: {{ effects: 'fadeIn'}} }},");
+ sb.AppendLine(" select: tabstrip_on_tab_select,");
+ if(BindGrid)
+ sb.AppendLine(" show: tabstrip_on_tab_show");
sb.AppendLine(" }).data('kendoTabStrip');");
var eventMessage = new AdminTabStripCreated(Name);