nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.19k stars 5.28k forks source link

Admin Tables Footer not rendering on Child Table #5284

Closed purplepiranha closed 3 years ago

purplepiranha commented 3 years ago

nopCommerce version: 4.30

Steps to reproduce the problem: Add 'FooterCallback' to a ChildTable within the admin section

The footer is never rendered as the child table does not have a 'tfoot' section. As stated in Table.cshtml you need to add the footer before the table is created as DataTables doesn't provide a method for creating a footer.

Workaround: In Table.cshtml after

        if (curModel.ChildTable != null)
        {

insert

            var footerHtml = "";
            if (curModel.ChildTable.FooterColumns > 0)
            {
                @for (int i = 0; i < curModel.ChildTable.FooterColumns; i++)
                {
                    footerHtml = string.Concat(footerHtml, "<td></td>");
                }

                footerHtml = string.Concat("<tfoot><tr>", footerHtml, "</tr></tfoot>");
            }

and then change return childTable = '<table id="child' + d.@(curModel.PrimaryKeyColumn) + '" class="table table-bordered table-hover dataTable" width="100%" style="padding-left:2%;"></table>'; to return childTable = '<table id="child' + d.@(curModel.PrimaryKeyColumn) + '" class="table table-bordered table-hover dataTable" width="100%" style="padding-left:2%;">@(Html.Raw(footerHtml))</table>';

purplepiranha commented 3 years ago

There also seem to be other issues with child tables. For example the Inline Edit doesn't seem to display the input box when the EditType is EditType.String. Also the parent table refreshes when a delete is performed, rather than just the child table.

DmitriyKulagin commented 3 years ago

@purplepiranha We have made some changes to improve this functionality, you can find them in the develop branch. Please, check this commit -https://github.com/nopSolutions/nopCommerce/commit/4de48951e224c1c203568d5f77dca86c016d2707

purplepiranha commented 3 years ago

Thanks @DmitriyKulagin. Unfortunately it doesn't appear to address those specific issues.

DmitriyKulagin commented 3 years ago

@purplepiranha Then describe the problems in more detail so that we can investigate them. Alternatively, you can submit a pull request if you already have a solution.

purplepiranha commented 3 years ago

@DmitriyKulagin - the fix for the footer (as detailed above) is currently in an Azure repo, but when I get a chance I'll add it to a fork here and submit a pull request.

The other problems (with child tables) are to do with inline editing/deleting:

  1. Any fields with EditType.String don't show the edit 'input' control when the edit button is clicked. EditType.Number works fine. I cannot find a reason why this doesn't work with child tables as it works well on the main table.

image

  1. When the inline delete is used, the parent table refreshes (therefore the child table becomes collapsed). Not a major issue, but slightly frustrating from a user perspective.
DmitriyKulagin commented 3 years ago

@purplepiranha I have not been able to reproduce the issue of editing inline values with the type EditType.String. Judging by the screenshot, your solution is customized and we are trying to reproduce the problem on different settings.

And as for updating the child table after deletion. There can be different usage scenarios, and the most common approach would be to update the parent table after modifying the child.