Available in the Full Version

Data Grid - Auto-Generate Columns

Show
records
1Chai1110 boxes x 20 bags18.000039010false
2Chang1124 - 12 oz bottles19.0000174025false
3Aniseed Syrup1212 - 550 ml bottles10.0000137025false
4Chef Anton's Cajun Seasoning2248 - 6 oz jars22.00005300false
5Chef Anton's Gumbo Mix2236 boxes21.3500000true
ProductIDProductNameSupplierIDCategoryIDQuantityPerUnitUnitPriceUnitsInStockUnitsOnOrderReorderLevelDiscontinued

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

This sample shows the auto-generate columns functionality of igGrid. Auto-generation of columns is very useful when the data source contains a lot of columns which should be displayed in the grid. When columns are auto-generated their header captions are taken from the data source field names. The autoGenerateColumns option is used in combination with defaultColumnWidth option.

Code View

Copy to Clipboard
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.lob.js"></script>
</head>
<body>
    <table id="grid"></table>
    <script src="/data-files/northwind-products.js"></script>
    <script>
        $(function () {
            $("#grid").igGrid({
                autoGenerateColumns: true,
                defaultColumnWidth: "150px",
                width: "100%",
                dataSource: northwindProducts,
                responseDataKey: "results",
                features: [
                    {
                        name: "Paging",
                        type: "local",
                        pageSize: 5
                    },
                    {
                        name: "Sorting",
                        type: "local"
                    },
                    {
                        name: "Filtering",
                        type: "local"
                    }
                ]
            });
        });
    </script>
</body>
</html>