@@ -7,7 +7,7 @@ let table_config2 = {
77 { name : 'name' , show : true , edit : true , width : '150px' , tooltip : true } ,
88 { name : 'job' , show : true , edit : true , width : '150px' , description : 'The job' } ,
99 { name : 'private' , show : true , edit : true , width : '200px' , description : 'your things' , tooltip : true } ,
10- { name : 'html' , show : true , edit : true , width : '500px ' , type : 'html' , description : 'You can use HTML' , tooltip : true }
10+ { name : 'html' , show : true , edit : true , width : '150px ' , type : 'html' , description : 'You can use HTML' , tooltip : true }
1111 ] ,
1212 row_settings : { height : '1.3em' }
1313}
@@ -17,12 +17,12 @@ let genericCrudTable2 = document.getElementById('crud-table-2');
1717const sortStore2 = [ ] ;
1818
1919genericCrudTable2 . setAttribute ( 'table_config' , JSON . stringify ( table_config2 ) ) ;
20- genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData ) ) ;
20+ genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData2 ) ) ;
2121
2222genericCrudTable2 . addEventListener ( 'create' , ( ) => {
2323 console . log ( 'create' ) ;
24- myData . unshift ( { id : Date . now ( ) . toString ( ) , name : 'A_NEW' , job : 'none' , private : 'set hard' , html : 'a <b>b</b> <i>c</i>' } ) ;
25- refresh ( ) ;
24+ myData2 . unshift ( { id : Date . now ( ) . toString ( ) , name : 'A_NEW' , job : 'none' , private : 'set hard' , html : 'a <b>b</b> <i>c</i>' } ) ;
25+ genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData2 ) ) ;
2626} ) ;
2727
2828genericCrudTable2 . addEventListener ( 'details' , ( e ) => {
@@ -33,25 +33,25 @@ genericCrudTable2.addEventListener('details', (e) => {
3333genericCrudTable2 . addEventListener ( 'update' , ( e ) => {
3434 console . log ( 'update' ) ;
3535 console . log ( e . detail . body ) ;
36- for ( let i = 0 ; i < myData . length ; i ++ ) {
37- if ( JSON . stringify ( myData [ i ] ) === JSON . stringify ( table_data [ e . detail . id ] ) ) {
38- myData [ i ] = e . detail . body ;
36+ for ( let i = 0 ; i < myData2 . length ; i ++ ) {
37+ if ( JSON . stringify ( myData2 [ i ] ) === JSON . stringify ( table_data [ e . detail . id ] ) ) {
38+ myData2 [ i ] = e . detail . body ;
3939 break ;
4040 }
4141 }
42- refresh ( genericCrudTable2 ) ;
42+ genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData2 ) ) ;
4343} ) ;
4444
4545genericCrudTable2 . addEventListener ( 'delete' , ( e ) => {
4646 console . log ( 'delete: ' + JSON . stringify ( e . detail . body ) ) ;
4747 console . log ( 'offset in view:' + e . detail . id ) ;
48- for ( let i = 0 ; i < myData . length ; i ++ ) {
49- if ( JSON . stringify ( myData [ i ] ) === JSON . stringify ( myData [ e . detail . id ] ) ) {
50- myData = arrayRemove ( myData , i )
48+ for ( let i = 0 ; i < myData2 . length ; i ++ ) {
49+ if ( JSON . stringify ( myData2 [ i ] ) === JSON . stringify ( myData2 [ e . detail . id ] ) ) {
50+ myData2 = arrayRemove ( myData2 , i )
5151 break ;
5252 }
5353 }
54- refresh ( genericCrudTable2 ) ;
54+ genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData2 ) ) ;
5555} ) ;
5656
5757genericCrudTable2 . addEventListener ( 'sort' , ( e ) => {
@@ -76,6 +76,6 @@ genericCrudTable2.addEventListener('sort', (e) => {
7676 return 0 ;
7777 } ;
7878
79- myData = myData . sort ( tableSort ) ;
80- refresh ( genericCrudTable2 ) ;
79+ myData2 = myData2 . sort ( tableSort ) ;
80+ genericCrudTable2 . setAttribute ( 'table_data' , JSON . stringify ( myData2 ) ) ;
8181} ) ;
0 commit comments