Save and refresh grid kendo

I have the following method, which changes a variable from false to true in a grid, what I need is to save that variable and refresh the grid so that when the page is refreshed, the reflected changes are seen.

onClickBloquear(event: any) {
    if (event.dataItem !== undefined) {
      const id = event.dataItem.id;
      this.service.bloquear(id);
    }
  }

Upvotes: 0

Views: 141

Answers (1)

ForestG
ForestG

Reputation: 18085

Angular does not store anything on a compnent.

If you want to save states, variables etc. you need an angular service which can be used to store data, and it can be injected to any of your components instances.

You provided a really small code, and hard to guess what your exact problem is, but something this should solve it:

  1. create a service
  2. Inject it into your component
  3. Store the variable you are referring in it
  4. On the component ngOnInit, look for the variable in the service
  5. if it is stored, then load it, otherwise use a default value.

Upvotes: 1

Related Questions