SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 298 forks source link

ColumnResizer won't resize columns on the second row when using subRows #415

Open npadgen opened 11 years ago

npadgen commented 11 years ago

When using subRows, ColumnResizer behaves strangely when trying to resize columns not on the top row. Resizing the first column causes all the columns to resize; resizing any other column has no effect. Tested using a table with one subrow on Firefox ESR 10.0.12 on Linux and Chrome 21.0.1180.89 m on Windows 7.

npadgen commented 11 years ago

This code illustrates the issue, using hof-batting.json from the dgrid tutorials.

require([
            "dojo/request",
            "dojo/store/Memory",
            "dgrid/OnDemandGrid",
            "dojo/_base/declare",
            "dgrid/extensions/ColumnReorder",
            "dgrid/extensions/ColumnResizer"
        ],
        function(request, Memory, OnDemandGrid, declare, ColumnReorder, ColumnResizer){
            request("hof-batting.json", {
                handleAs: "json"
            }).then(function(response) {
                var CustomGrid = declare([OnDemandGrid, ColumnReorder, ColumnResizer]),
                    grid = new CustomGrid({
                        store: new Memory({data: response}),
                        subRows: [
                            [
                                {field: "nickname", label: "Nickname", colSpan: 15}
                            ],
                            [
                                {field: "first", label: "First"},
                                {field: "last", label: "Last"},
                                {field: "bats", label: "Bats"},
                                {field: "throws", label: "Throws"},
                                {field: "totalG", label: "G"},
                                {field: "totalAB", label: "AB"},
                                {field: "totalR", label: "R"},
                                {field: "totalRBI", label: "RBI"},
                                {field: "totalBB", label: "BB"},
                                {field: "totalK", label: "K"},
                                {field: "totalGAB", label: "Games as Batter"},
                                {field: "totalH", label: "H"},
                                {field: "total2B", label: "2B"},
                                {field: "total3B", label: "3B"},
                                {field: "totalHR", label: "HR"}
                            ]
                        ]

                    }, "grid");

                    grid.startup();
            });
ghost commented 11 years ago

After some testing and debugging, we managed to isolate the error, but even upon resolving it, resizing still doesn't work as expected. This is specifically related to the fact that your column structure involves using a colspan within the first sub-row. This is something that generally tends to cause problems in fixed table layouts (which dgrid uses for simplicity and efficiency), and as such, dgrid can't really fully support such a layout.

We would recommend rearranging your structure so that the first sub-row does not have colspans, if at all possible.

npadgen commented 11 years ago

The specific application we are developing has a long headline and associated metadata. The users have expressed a preference that the headline sits above, rather than below, the metadata, which is why we need a colspan in the first row.