@@ -9,6 +9,7 @@ import { IgrGrid, IgrGridToolbar, IgrGridToolbarActions, IgrGridToolbarExporter,
99import { ComponentRenderer , PropertyEditorPanelDescriptionModule , WebGridDescriptionModule } from 'igniteui-react-core' ;
1010import { InvoicesDataItem , InvoicesData } from './InvoicesData' ;
1111import { IgrPropertyEditorPropertyDescriptionChangedEventArgs } from 'igniteui-react-layouts' ;
12+ import { IgrRowType } from 'igniteui-react-grids' ;
1213
1314import 'igniteui-react-grids/grids/themes/light/bootstrap.css' ;
1415import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
@@ -67,6 +68,7 @@ export default class Sample extends React.Component<any, any> {
6768 autoGenerate = { false }
6869 data = { this . invoicesData }
6970 onRendered = { this . webGridPasteFromExcel }
71+ rowClasses = { this . webGridEditedRowClassesHandler }
7072 ref = { this . gridRef }
7173 id = "grid"
7274 primaryKey = "OrderID" >
@@ -157,6 +159,7 @@ export default class Sample extends React.Component<any, any> {
157159
158160 private txtArea : any ;
159161 public pasteMode = "Paste starting from active cell" ;
162+ public updatedRecsPK : any [ ] = [ ] ;
160163
161164 public get textArea ( ) {
162165 if ( ! this . txtArea ) {
@@ -202,7 +205,6 @@ export default class Sample extends React.Component<any, any> {
202205 const grid = this . grid as any ;
203206 const columns = grid . visibleColumns ;
204207 const pk = grid . primaryKey ;
205- const addedData : any [ ] = [ ] ;
206208 for ( const curentDataRow of processedData ) {
207209 const rowData = { } as any ;
208210 for ( const col of columns ) {
@@ -211,22 +213,12 @@ export default class Sample extends React.Component<any, any> {
211213 }
212214 // generate PK
213215 rowData [ pk ] = grid . data . length + 1 ;
216+ this . updatedRecsPK . push ( rowData [ pk ] ) ;
214217 grid . addRow ( rowData ) ;
215- addedData . push ( rowData ) ;
216218 }
217219 // scroll to last added row
218220 grid . navigateTo ( grid . data . length - 1 , 0 , ( ) => {
219- this . clearStyles ( ) ;
220- for ( const data of addedData ) {
221- const row = grid . getRowByKey ( data [ pk ] ) ;
222- if ( row ) {
223- const rowNative = this . getNative ( row ) as any ;
224- if ( rowNative ) {
225- rowNative . style [ "font-style" ] = "italic" ;
226- rowNative . style . color = "gray" ;
227- }
228- }
229- }
221+ grid . cdr . detectChanges ( ) ;
230222 } ) ;
231223 }
232224 public updateRecords ( processedData : any [ ] ) {
@@ -238,7 +230,6 @@ export default class Sample extends React.Component<any, any> {
238230 const columns = grid . visibleColumns ;
239231 const cellIndex = grid . visibleColumns . indexOf ( cell . column ) ;
240232 let index = 0 ;
241- const updatedRecsPK : any [ ] = [ ] ;
242233 for ( const curentDataRow of processedData ) {
243234 const rowData = { } as any ;
244235 const dataRec = grid . data [ rowIndex + index ] ;
@@ -258,36 +249,10 @@ export default class Sample extends React.Component<any, any> {
258249 grid . addRow ( rowData ) ;
259250 continue ;
260251 }
252+ this . updatedRecsPK . push ( rowPkValue ) ;
261253 grid . updateRow ( rowData , rowPkValue ) ;
262- updatedRecsPK . push ( rowPkValue ) ;
263254 index ++ ;
264255 }
265-
266- this . clearStyles ( ) ;
267- for ( const pkVal of updatedRecsPK ) {
268- const row = grid . getRowByKey ( pkVal ) ;
269- if ( row ) {
270- const rowNative = this . getNative ( row ) as any ;
271- if ( rowNative ) {
272- rowNative . style [ "font-style" ] = "italic" ;
273- rowNative . style . color = "gray" ;
274- }
275- }
276- }
277- }
278-
279- protected clearStyles ( ) {
280- const rows = [ ...( document . getElementsByTagName ( "igx-grid-row" ) as any ) ] ;
281- for ( const rowNative of rows ) {
282- rowNative . style [ "font-style" ] = "" ;
283- rowNative . style . color = "" ;
284- }
285- }
286-
287- protected getNative ( row : any ) {
288- const rows = [ ...( document . getElementsByTagName ( "igx-grid-row" ) as any ) ] ;
289- const dataInd = row . index . toString ( ) ;
290- return rows . find ( x => ( x . attributes as any ) [ "data-rowindex" ] . value === dataInd ) ;
291256 }
292257
293258 public processData ( data : any ) {
@@ -308,6 +273,13 @@ export default class Sample extends React.Component<any, any> {
308273 return pasteData ;
309274 }
310275
276+ public webGridEditedRowClassesHandler = {
277+ edited : ( row : IgrRowType ) => {
278+ const grid = this . grid as any ;
279+ return this . updatedRecsPK . indexOf ( row . data [ grid . primaryKey ] ) !== - 1 ;
280+ }
281+ } ;
282+
311283}
312284
313285// rendering above component in the React DOM
0 commit comments