How to incorporate an editable field into a mat-row within a mat-table using Angular 9

I am currently working on enhancing an Angular screen that allows users to manage data in a table with just one column. While the code I have implemented below successfully displays the data, I have been unable to find any examples of how to make this single column editable.

HTML

<div class="SERIALCLASS">
    <br/>
    <div class="center" >
        Serial Exceptions<br/>

        <div>
            <table mat-table [dataSource]="dataSource" matSort>
                <ng-container matColumnDef="partNo">
                    <th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 300px !important;padding-right: 15px !important;">  Part No:  </th>
                    <td mat-cell *matCellDef="let row" style="padding-right: 15px !important;"> {{row.partNo}} </td>
                </ng-container>

                <ng-container matColumnDef="partNo1">
                    <th mat-header-cell *matHeaderCellDef style="width: 300px !important;padding-right: 15px !important;"> 
                        <mat-form-field class="filter" floatLabel="never" style="width: 80px !important;">
                            <mat-label>Filter</mat-label>
                            <input matInput [formControl]="partNoFilter">
                        </mat-form-field></th>
                </ng-container>

                <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
                <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
                <tr mat-header-row *matHeaderRowDef="displayedColumns1">  </tr>
            </table>

        </div>
    </div>
</div>

.TS file

import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { UserApiService } from 'src/app/services/api/user-apiservice';

@Component({
  selector: 'app-serial-exceptions',
  templateUrl: './serial-exceptions.component.html',
  styleUrls: ['./serial-exceptions.component.scss']
})
export class SerialExceptionsComponent implements OnInit {
  isLoading = true;
  isempty = false;

  dataSource = new MatTableDataSource<any>([]);

  partNoFilter = new FormControl('');

  @ViewChild(MatSort) sort: MatSort;    
  @ViewChild(MatPaginator) paginator: MatPaginator;
  
  displayedColumns: string[] = ['partNo'];
  displayedColumns1: string[] = ['partNo1'];

  filterValues = {
    partNo: ''
  };

  constructor(
    private repoService: UserApiService,
  ) { }

  ngOnInit(): void {
    this.getData();
    this.partNoFilterFunc();
  }

  getData(){
    this.isLoading = true;
    this.isempty = false;
    setTimeout(() => {
      this.repoService.getSerialExceptions().subscribe(largeDataSet => {
        console.log(largeDataSet);
        this.dataSource.paginator = this.paginator;
        this.dataSource.sort = this.sort;
        this.dataSource.data = largeDataSet;
      });
    })
    this.dataSource.filterPredicate = this.createFilter();
  }

  partNoFilterFunc(){
    this.partNoFilter.valueChanges
    .subscribe(
      partNo => {
        this.filterValues.partNo = partNo;
        this.dataSource.filter = JSON.stringify(this.filterValues);
      }
    );
  }

  createFilter(): (data: any, filter: string) => boolean {
    let filterFunction = function(data, filter): boolean {
      let searchTerms = JSON.parse(filter);
      return data.partNo.toString().toLowerCase().indexOf(searchTerms.partNo.toLowerCase()) !== -1;
    };
    return filterFunction;
  }

}

A colleague shared this example with me, but it seems quite complex for my needs. In fact, I reverted back to my original work due to multiple errors encountered while trying to implement this example.

https://stackblitz.com/edit/inline-edit-mat-table?file=app%2Finline-edit%2Finline-edit.component.ts

Is there a simpler way to enable editing in a specific column within a mat-row?

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

Can you explain the significance of $f in jQuery scripts?

There are multiple jQuery-related scripts that utilize the $f function, however, I have been unable to locate a definitive explanation of its purpose. Here is an example: var iframe = document.getElementById(iframe_id); this.player = global.$f(iframe); ...

Displaying a slideshow with multiple images - Fotorama 4 offers the ability to slide through

I'm currently utilizing Fotorama.js, which can be found at fotorama.io Is there a way to display more than one image using fotorama.js? I am interested in creating a carousel with this plugin. <div class="fotorama"> <div data-img ...

Navigating to the header tab in React Native and accessing a variable

I have implemented a switch in my tab header, and I am looking to retrieve the value of the switch every time it is toggled. How can I accomplish this? const navigationOptions = ({ navigation }) => { const { params = {} } = navigation.state; ret ...

Decoding the `this` Mystery in VueJS

Recently, I decided to delve into the world of VueJS starting from square one. Following their official guide has been a helpful resource, but I've hit a roadblock at this section. One particular example in the guide caught my attention... var app5 = ...

Triggering a modal window with unique content by clicking on various images

Is there a way to trigger a modal window through clicking on an image? Additionally, can different images open different content upon clicking? I am planning to showcase a portfolio where clicking on an image will activate a modal that displays other image ...

Can you have more than one ID at a time?

Similar Question: Is it valid for an HTML element to have multiple IDs? Can a single HTML element have multiple IDs? Is the following code snippet a correct way to use multiple IDs? $("#example" + " #example2") HTML Code: <section id="example ex ...

Tips on leveraging an attribute for type guarding in a TypeScript class with generics

Is there a way to utilize a generic class to determine the type of a conditional type? Here is a basic example and link to TS playground. How can I access this.b and this.a without relying on as or any manual adjustments? type X<T> = T extends true ...

Stripping HTML elements from the body of an HTML document using AJAX before transmitting it as data to the controller

My JSP page contains two buttons labeled "download" and "sendemail". When the "Sendmail" button is clicked, an ajax method is triggered to generate a PDF version of the HTML body and send it to the back-end controller. I attempted to utilize the following ...

How to apply dynamic values for filtering in TypeScript?

My task is to filter out all Portfolio Lead who have English Competency set to No. var data = [{ "Employee Number": 138, "English Competency": "No", "Portfolio Lead": "x", "Maths Competency": "No" }, { "Employee Number": 1385, ...

After completing a sequence, it does not reset

I'm working on creating a versatile "slideshow" feature that can be used for various elements. Currently, I am testing it on a div that contains paragraph text taken from my HTML document and represented as container1, container2, and container3. The ...

I am struggling to display an array of objects retrieved from the server in the UI using AngularJS

I am receiving an array of objects as a JSON from the server. When I try to access my service URI from HTML, I encounter the following array in my console: "angular.js:13920 Error: [$resource:badcfg] http://errors.angularjs.org/1.5.8/$resource/badcfg?p0= ...

Refreshing the Angular dropdown menu

I am facing an issue with a dropdown that I can't seem to reset. Despite clicking on "clear", the dropdown retains the last selection instead of resetting. Although I have successfully reset another dropdown using the same method, I'm struggling ...

How do I create a generic function in TypeScript that adjusts its behavior based on the input argument?

Is there a way to create a generic function that can accept generic arguments like Data<string, number>? Take a look at this code snippet: interface Data<T,R> { a:T; c:R; } function foo( data: Data<string, number> ){ return t ...

Is there a way to retrieve the request object within loopback operational hooks?

I am currently utilizing loopback 3.x and have created an Access Hook within my code. My goal is to include a condition based on the User Agent. Specifically, I am looking to access Request > Headers > User-Agent. Is it feasible to retrieve this in ...

Example of a line graph implementation using a d3 array as input

I am a d3 newbie and I am trying to learn by working with the d3.js line example. The code for this example is provided below. My goal is to adjust it to use model data that I already have in a json object format. However, I am struggling with translating ...

What is the best way to convert API data into a currency format?

Hello, I need assistance with formatting data retrieved from an API into a currency format. The code below successfully retrieves the data but lacks formatting. For instance, if the data displays as 100000000, I would like it to be formatted as IDR100.000. ...

What is the best method for designing a custom mask for the jQuery Masked Input Plugin that accommodates alphanumeric characters, spaces, and accented

Looking for a way to make a custom mask in jQuery Masked Input Plugin that allows alphanumeric characters, spaces, and accented characters? This is what I currently have: $.mask.definitions["A"] = "[a-zA-Z0-9 ]"; $("#input").mask("A?AAAAAAA"); However, ...

turning off next.js server side rendering in order to avoid potential window is undefined issues

I am currently managing a private NPM package that is utilized in my Next.js project, both of which are React and Typescript based. Recently, I integrated a graph feature into the NPM package and encountered an issue where any reference to window within t ...

Discovering the Perfect Cube Using Factorization Technique

Looking for some guidance on a C/JS program to find perfect cubes using the factorization method below. Any assistance is greatly appreciated. 3 * 3 * 3 3 * 3 * 3 3 * 3 * 3 JavaScript Code var num=19683; var arr=[]; for(i=2;i<num;i++){ if(nu ...

AngularJS uses two ng-repeat directives to manage and manipulate data in

I'm implementing a feature where I have two views in my HTML5 code that display the same list. <div class="list" data-ng-repeat="item in model.items"> <div class=list-item"> {{ item.name }} <a data-ng-click="addToLi ...