Please note that this control has been deprecated and replaced with the Grid component, and as such, we recommend migrating to that control. This will not be receiving any new features, bug fixes will be deprioritized. For help or questions on migrating your codebase to the Data Grid, please contact support.

    Web Components Binding Local Data

    The following sample demonstrates the Ignite UI for Web Components Data Table / Data Grid data binding to an array of data.

    Web Components Binding Local Data Example

    EXAMPLE
    TS
    HTML
    CSS

    Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.

    Code Snippet

    public data: any[];
    public initData() {
            const names: string[] = [
                "Intel CPU", "AMD CPU",
                "Intel Motherboard", "AMD Motherboard", "Nvidia Motherboard",
                "Nvidia GPU", "Gigabyte GPU", "Asus GPU", "AMD GPU", "MSI GPU",
                "Corsair Memory", "Patriot Memory", "Skill Memory",
                "Samsung HDD", "WD HDD", "Seagate HDD", "Intel HDD", "Asus HDD",
                "Samsung SSD", "WD SSD", "Seagate SSD", "Intel SSD", "Asus SSD",
                "Samsung Monitor", "Asus Monitor", "LG Monitor", "HP Monitor" ];
    
            const countries: string[] = ["USA", "UK", "France", "Canada", "Poland",
                "Denmark", "Croatia", "Australia", "Seychelles",
                "Sweden", "Germany", "Japan", "Ireland",
                "Barbados", "Jamaica", "Cuba", "Spain",];
            const status: string[] = [ "Packing", "Shipped", "Delivered"]
            const sales: any[] = [];
    
            for (let i = 0; i < 200; i++) {
                const price = this.getRandomNumber(10000, 90000) / 100;
                const items = this.getRandomNumber(4, 30);
                const value = Math.round(price * items);
                const margin = this.getRandomNumber(2, 5);
                const profit = Math.round((price * margin / 100) * items);
                const country = this.getRandomItem(countries);
                sales.push({
                    Country: country,
                    CountryFlag: this.getCountryFlag(country),
                    Margin: margin,
                    OrderDate: this.getRandomDate(),
                    OrderItems: items,
                    OrderValue: value,
                    ProductID: 1001 + i,
                    ProductName: this.getRandomItem(names),
                    ProductPrice: price,
                    Profit: Math.round(profit),
                    Status: this.getRandomItem(status),
                });
            }
    
            this.data = sales;
        }
    ts
    Ignite UI for Web Components | CTA Banner

    API References