Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Angular copiando una fila de tabla

Aquí está mi código. En mi código, permito que el usuario cree una fila con los mismos valores cuando hace clic en un botón junto a una fila. Quiero que sea capaz de crear varias copias. Sin el bucle for, puedo crear solo una fila pero, con el bucle for, no pude crear varias copias. ¿Qué falta en mi código? ¿Qué tengo que hacer?

 copyWorkItem(index: any, row: IWorkItem, event: any) { const dialogRef = this._dialog.open(CopyDialogComponent, { width: "550px", data: row, }); dialogRef.afterClosed().subscribe((result: IWorkItemSelection) => { for(let i= 1; i >= result.CopyQuantity; i++){ let item: IWorkItem = { Product: row.Product, ProductCategory: row.ProductCategory, Version: row.Version, ProductBalance: row.ProductBalance, DeliveryWarehouse: row.DeliveryWarehouse, } if (result.OrderIdCheck == null || result.OrderIdCheck == false) { item.Order = null; } if(result.StockCheck == null || result.StockCheck == false || result.StockCheck == undefined){ item.ProductCategory = null; item.Product = null; } if (result.VersionCheck == null || result.VersionCheck == false) { item.Version = null; } if (result.DeliveryWarehouseCheck == null || result.DeliveryWarehouseCheck == false) { item.DeliveryWarehouse = null; } if (result.QuantityCheck == null || result.QuantityCheck == false) { item.Quantity = null; } //creates a new row let tempData = this.dataSource.data.splice(0); tempData.unshift(item); this.dataSource = new MatTableDataSource(tempData); this.EditIndex = 0; } }); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si desea generar una cantidad de elementos html basados en el resultado CopyQuantity del cuadro de diálogo, recomendaría escribir las copias en una matriz de objetos y luego usar la directiva ngFor de Angular para representar esos elementos en la tabla.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!