@@ -50,10 +50,10 @@ const getColumns = (props) => {
50
50
console . log ( 'Line 50 id = ' , params . id ) ;
51
51
// const fields = api.getAllColumns().map((c: any) => c.field).filter((c : any) => c !== '__check__' && !!c);
52
52
return params . id ;
53
-
53
+
54
54
// return params.getValue(fields[0]);
55
55
} ;
56
- return (
56
+ return (
57
57
< Button style = { { width :`${ 3 } px` } }
58
58
onClick = { ( ) => {
59
59
deleteHandler ( getIdRow ( ) ) ;
@@ -72,15 +72,15 @@ const TableStateProps = (props) => {
72
72
const [ state ] = useContext ( StateContext ) ;
73
73
const [ editRowsModel ] = useState < GridEditRowsModel > ( { } ) ;
74
74
const [ gridColumns , setGridColumns ] = useState ( [ ] ) ;
75
-
75
+
76
76
77
77
useEffect ( ( ) => {
78
78
setGridColumns ( getColumns ( props ) ) ;
79
79
} , [ props . isThemeLight ] )
80
80
// get currentComponent by using currently focused component's id
81
81
const currentId = state . canvasFocus . componentId ;
82
82
const currentComponent = state . components [ currentId - 1 ] ;
83
-
83
+
84
84
// rows to show are either from current component or from a given provider
85
85
let rows = [ ] ;
86
86
if ( ! props . providerId ) {
@@ -90,25 +90,25 @@ const TableStateProps = (props) => {
90
90
// changed to get whole object
91
91
if ( props . displayObject ) {
92
92
const displayObject = props . displayObject ;
93
- // const displayObject = providerComponent.stateProps[props.displayObjectId - 1].value;
94
- // format the object to match the table data format {id:_, key:_, value:_, type:<might do typeof or leave blank>}
93
+ // format for DataGrid
95
94
let id = 1 ;
96
95
for ( const key in displayObject ) {
97
- rows . push ( { id : id ++ , key :key , value : displayObject [ key ] , type : typeof ( displayObject [ key ] ) } ) ;
98
- }
96
+ // if key is a number make it a string with brackets aroung number
97
+ rows . push ( { id : id ++ , key : ( isNaN ( key ) ? key : '[' + key + ']' ) , value : displayObject [ key ] , type : typeof ( displayObject [ key ] ) } ) ;
98
+ }
99
99
} else {
100
100
rows = providerComponent . stateProps . slice ( ) ;
101
101
}
102
102
}
103
103
console . log ( rows ) ;
104
104
105
105
const { selectHandler } : StatePropsPanelProps = props ;
106
-
106
+
107
107
// when component gets mounted, sets the gridColumn
108
108
useEffect ( ( ) => {
109
109
setGridColumns ( getColumns ( props ) ) ;
110
110
} , [ ] ) ;
111
-
111
+
112
112
return (
113
113
< div className = { 'state-prop-grid' } >
114
114
< DataGrid
0 commit comments