在没有页面加载的情况下刷新数组

refresh array without page load

我在 angular 中实现了一项功能,其中我在网格中显示过滤后的数组详细信息。 单击网格中的按钮时,我调用了一个函数 onClick(),我们可以更新记录。 当记录更新时,我需要刷新过滤后的数组,而不需要重新加载页面。 帮我实现这个功能。

 selected:any;
  filtered : any=[];
  Form: FormGroup;

    onOptionsSelected() {
      if (this.Form.invalid) {
        alert('Please choose an option')
        return;        
      }
      else{
      this.filtered = this.studentInfo.filter(t=>t.Id == this.selected);
      }      
    }  

    public Response: any = [];

    onClick(index: number, id: string, roll_no: string){
      const obj = {
        id : id,
        roll_no : roll_no,
      }      
     this.Srvc.postmethod('students', obj).subscribe((response:any)=>{
        this.Response = response;
        if(this.Response.status === 200)
        {
          alert('Record updated');                  
        }  
   });
  }

试试下面的代码。

更新过滤后的数组,在所需索引处将状态设为 Y,以便它反映在网格中。

 onClick(index: number, id: string, roll_no: string){
          const obj = {
            id : id,
            roll_no : roll_no,
          }      
         this.Srvc.postmethod('students', obj).subscribe((response:any)=>{
            this.Response = response;
            if(this.Response.status === 200)
            {
              alert('Record updated');  
              this.filtered[index].present = 'Y'  // try this line
            }  
       });
      }