React Grid Live Data Updates

    The Ignite UI for React Live Data Updates feature in React Grid is used for enabling real-time or near-real-time updates of data displayed within the grid. This is extremely useful in apps where data is constantly changing, like stock market trackers, live sports scores, or IoT (Internet of Things) dashboards. The IgrGrid can handle thousands of updates per second, while staying responsive for user interactions.

    React Live-data Update Example

    The sample below demonstrates the Grid performance when all records are updated multiple times per second. Use the UI controls to choose the number of records loaded and the frequency of updates. Feed the same data into the Column Chart to experience the powerful charting capabilities of Ignite UI for Angular. The Chart button will show Category Prices per Region data for the selected rows and the Chart column button will show the same for the current row.

    Data binding and updates

    Um serviço fornece dados ao componente quando a página é carregada e quando o controlador deslizante é usado para buscar um determinado número de registros. Enquanto em um cenário real os dados atualizados seriam consumidos do serviço, aqui os dados são atualizados no código. Isso é feito para manter a demonstração simples e focar em seu objetivo principal - demonstrar o desempenho da grade.

    <IgrGrid id="grid1"></IgrGrid>
    
    function startUpdate(frequency) {
      const timer = setInterval(() => {
        setData(prevData => FinancialDataClass.updateRandomPrices(prevData));
      }, frequency);
    
      setStartButtonDisabled(true);
      setShowChartButtonDisabled(true);
      setStopButtonDisabled(false);
    }
    

    A change in the data field value or a change in the data object/data collection reference will trigger the corresponding pipes. However, this is not the case for columns, which are bound to complex data objects. To resolve the situation, provide a new object reference for the data object containing the property. Example:

    <IgrGrid id="grid1">
        <IgrColumn field="price.usd"></IgrColumn>
    </IgrGrid>
    
    private updateData(data: any[]) {
        const newData = []
        for (const rowData of data) {
            rowData.price = { usd: getUSD(), eur: getEUR() };
            newData.push({...rowData});
        }
        gridRef.current.data = newData;
    }
    

    Modelos

    A atualização do modo de exibição funciona da mesma maneira para colunas com um modelo padrão e para colunas com um modelo personalizado. No entanto, é recomendável manter os modelos personalizados relativamente simples. À medida que o número de elementos no modelo aumenta, o impacto negativo no desempenho também aumenta.

    API References

    Additional Resources

    Nossa comunidade é ativa e sempre acolhedora para novas ideias.