Impact of Gen-AI on IT Jobs - Growth Mindset Show
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Assemblies
.NET Core
.NET Standard
Active Directory
ADO.NET
Agile Development
AJAX
Alexa Skills
Algorithms in C#
Android
Angular
Architecture
ArcObject
Artificial Intelligence
ASP.NET
ASP.NET Core
Augmented Reality
Aurelia
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blockchain
Bootstrap
Bot Framework
Business
C#
C# Corner
C, C++, MFC
Career Advice
Chapters
CIO
Cloud
COBOL.NET
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Cortana Development
Cryptocurrency
Cryptography
Crystal Reports
Current Affairs
Custom Controls
Cyber Security
Data Mining
Databases & DBA
Design Patterns & Practices
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
Expression Studio
F#
Files, Directory, IO
Games Programming
GDI+
General
Generative Engine Optimization (GEO)
Google Cloud
Google Development
Graphics Design
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Internet & Web
Internet of Things
Ionic
iOS
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
kotlin
Leadership
Learn .NET
LightSwitch
LINQ
Machine Learning
Microsoft 365
Microsoft Office
Microsoft Phone
Mobile Development
Multithreading
Nano Banana
NetBeans
Networking
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Power BI
Printing in C#
Products
Progressive Web Apps
Project Management
Python
Q#
QlikView
R
React
Reports using C#
Robotics & Hardware
Ruby on Rails
Salesforce
Security
Servers
SharePoint
SignalR
Silverlight
Smart Devices
Software Testing
SQL Language
SQL Server
Startups
String in C#
Swift
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
WCF
Wearables
Web Development
Web Services
Web3
Windows 10
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML Standard
XML
XNA
XSharp
Register
Login
0
Answer
update and add new row is not working in angular 4
Karthik Kumar
7y
274
0
1
XLINQ
Reply
I am trying crud operation in client side without using any database using inline editing in Angular 4.i am able to bind the values but while updating, values updated but saving as a new value, rest of the table values are not showing. Add new function also not working in my code
1.update is not working
2.addin a new row is not working
my html
<
table
class
=
"table table-striped table-bordered"
cellspacing
=
"0"
>
<
thead
class
=
"table-inverse"
>
<
tr
>
<
th
>
EWID
</
th
>
<
th
>
MMID
</
th
>
<
th
>
PNO12
</
th
>
<
th
>
PWeight
</
th
>
<
th
>
SegmentCO2
</
th
>
<
th
>
CreatedBy
</
th
>
<
th
>
CreatedOn
</
th
>
<
th
>
UpdatedBy
</
th
>
<
th
>
UpdatedOn
</
th
>
<
th
>
Actions
</
th
>
</
tr
>
<
tr
*
ngFor
=
"let movie of preview let i=index"
>
<
td
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.EwId}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.EwId" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
td
>
<
td
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.MMID}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.MMID" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
td
>
<
td
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.PNO12}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.PNO12" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
td
>
<
td
>
<
div
class
=
"hideextra"
style
=
"width:75px"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.PWeight}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="PWeight" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
>
<
div
class
=
"hideextra"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.SegmentCo2}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.SegmentCo2" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
class
=
"medium-columnwidth"
>
<
div
class
=
"hideextra table-width"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.CreatedBy}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.CreatedBy" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
class
=
"medium-columnwidth"
>
<
div
class
=
"hideextra table-width"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.CreatedOn}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.CreatedOn" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
class
=
"medium-columnwidth"
>
<
div
class
=
"hideextra table-width"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.UpdatedBy}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.UpdatedBy" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
class
=
"medium-columnwidth"
>
<
div
class
=
"hideextra table-width"
>
<
span
*
ngIf
=
"!movie.showEdit"
>
{{movie.UpdatedOn}}
</
span
>
<
input
type
=
"text"
[(ngModel)]="movie.UpdatedOn" *
ngIf
=
"movie.showEdit"
style
=
"width: 112px"
class
=
"form-control"
>
</
div
>
</
td
>
<
td
>
<
a
href
=
"javascript:void(0)"
(click)="deletecsv(i)" *
ngIf
=
"!movie.cancel"
class
=
"btn btn-danger btn-xs pull-right"
>
Delete
</
a
>
<
a
href
=
"javascript:void(0)"
*
ngIf
=
"movie.showupdate"
(click)="update(movie)"
class
=
"btn btn-primary btn-xs pull-right"
>
Update
</
a
>
<
a
href
=
"javascript:void(0)"
*
ngIf
=
"movie.showsave"
(click)="addcsv(csvsingle)"
class
=
"btn btn-primary btn-xs pull-right"
>
Save
</
a
>
<
a
href
=
"javascript:void(0)"
*
ngIf
=
"!movie.showEdit"
(click)="editcsv(movie)"
class
=
"btn btn-primary btn-xs pull-right"
>
Edit
</
a
>
<
a
href
=
"javascript:void(0)"
*
ngIf
=
"movie.cancel"
(click)="cancel(movie)"
class
=
"btn btn-primary btn-xs pull-right"
>
Cancel
</
a
>
</
td
>
</
tr
>
</
thead
>
</
table
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"col-xs-1 col-sm-1 col-md-1 col-lg-1"
>
<
button
(click)="newcsv()"
>
Add
</
button
>
//add a new row
</
div
>
component.ts
public
preview: Csvdata[];
public
updatepreview: Csvdata;
private
csvsingle: Csvdata =
new
Csvdata();
update(movie: Csvdata)
{
this
.preview = []
var obj =
new
Csvdata();
obj.EwId = movie.EwId
obj.MMID = movie.MMID
obj.PNO12 = movie.PNO12
obj.PWeight = movie.PWeight
obj.SegmentCo2 = movie.SegmentCo2
obj.CreatedBy = movie.CreatedBy;
obj.CreatedOn = movie.CreatedOn;
obj.UpdatedBy = movie.UpdatedBy;
obj.UpdatedOn = movie.UpdatedOn;
this
.preview.push(obj)
}
cancel(movie: Csvdata) {
movie.showEdit =
false
;
movie.cancel =
false
;
movie.showupdate =
false
;
}
editcsv(i: Csvdata)
{
this
.edited =
true
;
this
.saveD =
false
;
i.showupdate =
true
;
i.cancel =
true
;
i.showEdit = i.showEdit ?
false
:
true
;
this
.updatepreview=i
this
.EwId = i.EwId
this
.MMID = i.MMID
this
.PNO12 = i.PNO12
this
.PWeight = i.PWeight
this
.SegmentCo2 = i.SegmentCo2
this
.CreatedBy = i.CreatedBy
this
.CreatedOn = i.CreatedOn
this
.UpdatedBy = i.UpdatedBy
this
.UpdatedOn = i.UpdatedOn
this
.showSave =
true
;
this
.show =
false
;
}
newcsv()
//add a new row
{
this
.showSave =
true
;
this
.show =
false
;
this
.clear();
var csvdata: Csvdata =
new
Csvdata();
csvdata.EwId =
this
.EwId;
csvdata.MMID =
this
.MMID;
csvdata.PNO12 =
this
.PNO12;
csvdata.PWeight =
this
.PWeight;
csvdata.SegmentCo2 =
this
.SegmentCo2;
csvdata.CreatedBy =
this
.CreatedBy;
csvdata.CreatedOn =
this
.CreatedOn;
csvdata.UpdatedBy =
this
.UpdatedBy;
csvdata.UpdatedOn =
this
.UpdatedOn;
}
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Post
Reset
Cancel
Answers (
0
)
Related Discussion