@@ -154,19 +154,48 @@ export class EditDataTableComponent implements OnInit {
154154 ) {
155155 this . route . data . subscribe ( ( data : { dataTable : any ; columnCodes : any } ) => {
156156 this . dataTableData = data . dataTable ;
157+
158+ // Get the relationship column name based on application table
159+ const relationshipColumnName = this . getRelationshipColumnName ( this . dataTableData . applicationTableName ) ;
160+
157161 this . dataTableData . columnHeaderData . forEach ( ( item : any ) => {
162+ // Mark system columns (id, created_at, updated_at) and relationship column as system
158163 item . system = [
159- 'created_at' ,
160- 'updated_at'
161- ] . includes ( item . columnName ) ;
164+ 'id' ,
165+ 'created_at' ,
166+ 'updated_at'
167+ ] . includes ( item . columnName ) || item . columnName === relationshipColumnName ;
162168 } ) ;
163169 this . columnData = this . dataTableData . columnHeaderData ;
164170 this . dataForDialog . columnCodes = data . columnCodes ;
165171 } ) ;
166172 }
167173
168174 /**
169- * Creates and sets data table form and columns table.
175+ * Gets the relationship column name.
176+ * @param {string } appTableName Application table name.
177+ * @returns {string } Relationship column name.
178+ */
179+ getRelationshipColumnName ( appTableName : string ) : string {
180+ // Map application table names to their relationship column names
181+ const tableToColumnMap : { [ key : string ] : string } = {
182+ m_client : 'client_id' ,
183+ m_group : 'group_id' ,
184+ m_center : 'center_id' ,
185+ m_office : 'office_id' ,
186+ m_loan : 'loan_id' ,
187+ m_savings_account : 'savings_account_id' ,
188+ m_savings_account_transaction : 'savings_transaction_id' ,
189+ m_product_loan : 'product_loan_id' ,
190+ m_savings_product : 'savings_product_id' ,
191+ m_share_product : 'share_product_id'
192+ } ;
193+
194+ return tableToColumnMap [ appTableName ] || '' ;
195+ }
196+
197+ /**
198+ * Create and set data table form and columns table.
170199 */
171200 ngOnInit ( ) {
172201 this . initData ( ) ;
@@ -190,7 +219,12 @@ export class EditDataTableComponent implements OnInit {
190219 * Initializes data table changes and column data.
191220 */
192221 initData ( ) {
193- this . columnData . shift ( ) ;
222+ // Remove the 'id' column if it exists (primary key for multi-row datatables)
223+ // but keep the relationship column visible (it's already marked as system)
224+ if ( this . columnData . length > 0 && this . columnData [ 0 ] . columnName === 'id' ) {
225+ this . columnData . shift ( ) ;
226+ }
227+
194228 this . dataTableChangesData . apptableName = this . dataTableData . applicationTableName ;
195229 this . dataTableChangesData . entitySubType = this . dataTableData . entitySubType ;
196230 for ( let index = 0 ; index < this . columnData . length ; index ++ ) {
0 commit comments