@@ -15,6 +15,11 @@ class Component extends Column {
1515 * @member {Function|Object|null} component=null
1616 */
1717 component : null ,
18+ /**
19+ * @member {Object} defaults
20+ * @protected
21+ */
22+ defaults : null ,
1823 /**
1924 * Components can delegate event listeners (or button handlers) into methods somewhere inside
2025 * the view controller or component tree hierarchy.
@@ -37,6 +42,16 @@ class Component extends Column {
3742 */
3843 map = new Map ( )
3944
45+ /**
46+ * Override as needed inside class extensions
47+ * @param {Object } config
48+ * @param {Record } record
49+ * @returns {Object }
50+ */
51+ applyRecordConfigs ( config , record ) {
52+ return config
53+ }
54+
4055 /**
4156 * @param {Object } data
4257 * @param {Neo.column.Base } data.column
@@ -54,14 +69,16 @@ class Component extends Column {
5469 { appName, view, windowId} = gridContainer ,
5570 me = this ,
5671 { recordProperty} = me ,
57- id = ` ${ me . id } -component- ${ rowIndex % ( view . availableRows + 2 * view . bufferRowRange ) } ` ,
72+ id = me . getComponentId ( rowIndex ) ,
5873 component = me . map . get ( id ) ,
5974 componentConfig = me . component ;
6075
6176 if ( Neo . typeOf ( componentConfig ) === 'Function' ) {
6277 componentConfig = componentConfig ( data )
6378 }
6479
80+ componentConfig = me . applyRecordConfigs ( componentConfig , record ) ;
81+
6582 if ( component ) {
6683 delete componentConfig . className ;
6784 delete componentConfig . module ;
@@ -73,6 +90,7 @@ class Component extends Column {
7390 component . set ( componentConfig )
7491 } else {
7592 component = Neo . create ( {
93+ ...me . defaults ,
7694 ...componentConfig ,
7795 appName,
7896 id,
@@ -88,6 +106,17 @@ class Component extends Column {
88106
89107 return component . createVdomReference ( )
90108 }
109+
110+ /**
111+ * @param {Number } rowIndex
112+ * @returns {String }
113+ */
114+ getComponentId ( rowIndex ) {
115+ let me = this ,
116+ { view} = me . parent ;
117+
118+ return `${ me . id } -component-${ rowIndex % ( view . availableRows + 2 * view . bufferRowRange ) } `
119+ }
91120}
92121
93122export default Neo . setupClass ( Component ) ;
0 commit comments