Clicking on an empty space within the Angular project will trigger a screen update when new data is retrieved from

Working on an Angular project where data is fetched from various services and used for calculations. The processed data is then displayed in a component utilizing the Syncfusion Grid Component. However, there seems to be an issue where the data loads during the ngOnInit lifecycle hook but does not immediately appear on the page. Oddly enough, clicking anywhere on the screen triggers the data to finally display. Struggling to find a solution to this problem, any suggestions?

<ejs-grid #grid id='grid'[rowHeight]='30' (rowDataBound)="rowDataBound($event)" [dataSource]='XXX$ | async' [editSettings]='editSettings' (cellSaved)="dataChanged($event)" height="300px" style="color: red;">
            <e-columns>
                <e-column field='x1' [visible]="check[0]" headerText='x1' textAlign='center'  width=120></e-column>
                <e-column field='x2' [visible]="check[1]" headerText='x2' textAlign='center'  width=120></e-column>                    
                <e-column field='x3' [visible]="check[2]" headerText='x3' textAlign='center'  width=120></e-column>
            </e-columns>
</ejs-grid>

Implemented binding of dataSource property with an observable, passing data into this observable from an array using the "of()" method.

XXX$!: Observable<XModel[]>;

this.XXX$= of(YYY);

Answer №1

The issue was resolved by utilizing changeDetectionRef.detectChanges().

import { ChangeDetectorRef } from '@angular/core';

Include the following in the constructor after importing,

constructor(private ref: ChangeDetectorRef){}

Invoke detectChanges() at the desired location

this.ref.detectChanges();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporate the teachings of removing the nullable object key when its value is anything but 'true'

When working with Angular, I have encountered a scenario where my interface includes a nullable boolean property. However, as a developer and maintainer of the system, I know that this property only serves a purpose when it is set to 'true'. Henc ...

The Angular2 app and NodeJs in the Docker container are unresponsive

After creating a new Angular2 app using angular-cli and running it in Docker, I encountered an issue where I could not connect to it from localhost. First, I initialized the app on my local machine: ng new project && cd project && "put m ...

Using ngx-translate to access JSON files stored in a server

I have been working on integrating translation key-value pairs into my system using a JSON file hosted on a server. The server holds a file called "en.json". Here is what I have accomplished so far: App Module Imports: TranslateModule.forRoot({ ...

Struggling to fetch a DropDown menu from an Array in ReactJS

Trying to utilize an array of City Names in a Auto Complete text field within ReactJS. The array is successfully printed, but encountering difficulty displaying the list in the browser's Dropdown. An error message is being displayed in the browser r ...

Tips for adjusting HighCharts layout with highcharts-vue integrations

I have a fairly simple component: <template> <div> <chart v-if="!loading" ref="priceGraph" constructor-type="stockChart" :options="chartData" ...

How can I utilize Angular services to transfer a count value to the Component?

I've been working on creating a coin counter for my application by developing a service specifically for counting coins. However, when I tried to use this service in one of my components where the count function is triggered, I encountered some diffic ...

Using the attribute selector in an Angular 2 standalone component

In my research, I have come across several sources mentioning that an angular component selector can be enclosed in square brackets similar to a directive selector. However, when I tried it, it did not work for me: import { ChangeDetectionStrategy, Compone ...

Using ngForm to implement multiselect options in HTML

Attempting to implement a multiselect dropdown that is tied to a dynamic property receiving data from a JSON script via service. Successfully displayed the data in the dropdown, but encountering abnormalities when adding the multiple attribute within the s ...

Utilizing CDK to transfer files to S3 storage bucket

I've been trying to upload a file to an S3 bucket created using CDK, but I keep encountering the same error even when using AWS's example code. Here is the stack: export class TestStack extends cdk.Stack { public readonly response: string; ...

Is there a way to access the element reference of a component directly within the template?

When I mouse over certain elements, I use the following code to set focus: <div #divTemplateVar (mouseover)="divTemplateVar.focus()"></div> However, this method does not work for components: <component #componentTemplateVar (mouseover)="c ...

Does this fall under the category of accepted practices for employing an effect in Angular?

I am working on integrating an Angular directive with a signal that receives values from a store selector. This signal is crucial for determining whether a button should be disabled or not. I'm curious about the best approach to listen to this signal ...

"Setting up a schema in TypeORM when connecting to an Oracle database: A step-by-step guide

As a newcomer to TypeORM, I'm using Oracle DB with Node.js in the backend. Successfully connecting the database with TypeORM using createConnection(), but struggling to specify the schema during connection creation. One workaround is adding the schem ...

What is the best way to eliminate the default focus on the stepper header in Angular Material?

My Angular application using the Angular Material library includes a dialog component with a stepper. The stepper has 3 steps, each containing an Angular reactive form. Currently, when the user opens the dialog, the focus is automatically moved to the head ...

Looking to reallocate information, paginate, and sort each time a new row is added to the mat-table

In my application, I have a customized <mat-table> with an implemented addRow() function that adds a new row to the table using default values based on the data type. The challenge I'm facing is that each time a new row is added, I find myself ...

The 'formGroup' property cannot be bound as it is not recognized as a valid property of 'form' in Angular 7

I tried implementing a login feature using web API with Angular 7, but encountered an error when using <form [formGroup]="loginForm" (submit)="loginFormSubmit()">. What could be causing this issue? https://i.sstatic.net/3M2a5.jpg login.component.ht ...

Ways to exit a forEach loop when a specific condition is satisfied and obtain a string or break statement

I'm currently using Angular 14 and have been encountering some issues with a piece of code involving a ternary operator. Despite researching resources like this one and others, I haven't found a solution that works for me. The code in question lo ...

Expand by focusing solely on recognized attributes?

I am working on creating an interface that can accept a mapped type, allowing for both runtime logic and compile-time typing to be utilized. Here is an example of what I'm aiming for: type SomeType = { a: string b: { a: string, b: string } } magi ...

While attempting to utilize npm install, I encounter an error on a discord bot stating "msvsVersion is not defined."

Struggling with self-hosting a TypeScript discord bot, the setup process has been a puzzle. It's supposed to generate a build directory with an index.js file, but it's unclear. Installed Visual Studio Build Tools 2017 as required, yet running npm ...

Step-by-step guide to configuring Angular 2 in Visual Studio 2013

Struggling to set up Angular 2 in Visual Studio 2013 without any external web tools? Even after following the Angular2 Quick Start guide, I couldn't get it to work. Is tsconfig.json supported in VS 2013? Any assistance or helpful links would be grea ...

How can I create an input field in MUI that restricts input to letters, numbers, and dashes

Is there a way to configure an MUI input field so that it only accepts letters, numbers, and dashes while excluding spaces and symbols such as (*&^%$#@!,.<>{}[])? Specifically, I want to allow characters that wouldn't disrupt a URL, like . Tha ...