admin管理员组

文章数量:1302913

I have been working on ag grid since quite long time. Currently we got a requirement to change the grid display for mobile devices (for example width <480 px).

Does Ag grid support/convert its view for small devices? If yes, could you provide the relevant link for the same?

I have been working on ag grid since quite long time. Currently we got a requirement to change the grid display for mobile devices (for example width <480 px).

Does Ag grid support/convert its view for small devices? If yes, could you provide the relevant link for the same?

Share edited Jul 5, 2020 at 19:42 mkrieger1 23.3k7 gold badges64 silver badges81 bronze badges asked Dec 25, 2018 at 8:11 ASHOK POTHINENIASHOK POTHINENI 911 gold badge1 silver badge2 bronze badges 1
  • Interesting point is that the table on their landing page adjusts itself quite nice on mobile (less columns), but they don't provide any guides on this topic.. – Pavel Commented Dec 17, 2019 at 11:18
Add a ment  | 

1 Answer 1

Reset to default 7

AgGrid adjust by itself. The default themes is capable of dynamic resizing itself.

You can use params.api.sizeColumnsToFit() in either on onGridReady or onFirstDataRendered. This will do dynamic resizing with scrolls.

However i would suggest to create a seperate view for mobile, display only relevant colums which makes sense in mobile view.

var column = [{ field: "Col1" }, { field: "Col2", }, { field: "Col3", }, { field: "Col4", }, { field: "Col5", }];

    var mobileColumn = [{ field: "Col1" }, { field: "Col2", }, { field: "Col3", }];

    window.addEventListener('resize', function () {
        setTimeout(function () {
            if (window.innerWidth <= 480) {
                gridOptions.setColumnDefs(mobileColumn);
                params.api.sizeColumnsToFit();
            }
        })
    })

dynamically set columns for mobile view

本文标签: javascriptCan we change the view for AG grid in mobile devicesStack Overflow