Browse Source

changes

dev
Arun Jadhav 10 months ago
parent
commit
783b198eba
2 changed files with 6 additions and 11 deletions
  1. +1
    -0
      src/app/pages/veriable-form/veriable-form.component.sass
  2. +5
    -11
      src/app/pages/veriable-form/veriable-form.component.ts

+ 1
- 0
src/app/pages/veriable-form/veriable-form.component.sass View File

@@ -47,3 +47,4 @@


.row-section .row-section
padding: 20px padding: 20px
overflow-y: auto

+ 5
- 11
src/app/pages/veriable-form/veriable-form.component.ts View File

@@ -12,9 +12,6 @@ import { ApiService } from 'src/app/_services';
}) })
export class VeriableFormComponent implements OnInit { export class VeriableFormComponent implements OnInit {
form: FormGroup; form: FormGroup;

// Sample variable list for dropdown
variableList = ['Variable 1', 'Variable 2', 'Variable 3'];
public componentDestroyed = new Subject(); public componentDestroyed = new Subject();
rdsValues: any; rdsValues: any;
selectedParamValue: any = {}; selectedParamValue: any = {};
@@ -22,7 +19,7 @@ export class VeriableFormComponent implements OnInit {


constructor(private fb: FormBuilder, private api: ApiService) { constructor(private fb: FormBuilder, private api: ApiService) {
this.form = this.fb.group({ this.form = this.fb.group({
rows: this.fb.array([]) // Form array for multiple rows
rows: this.fb.array([])
}); });
} }


@@ -52,9 +49,9 @@ export class VeriableFormComponent implements OnInit {


createColumn(): FormGroup { createColumn(): FormGroup {
return this.fb.group({ return this.fb.group({
type: [''], // Type can be 'text' or 'variable'
textValue: [''], // For text input
variableValue: [''] // For variable select
type: [''],
textValue: [''],
variableValue: ['']
}); });
} }


@@ -65,7 +62,7 @@ export class VeriableFormComponent implements OnInit {


addRow(): void { addRow(): void {
const row = this.fb.group({ const row = this.fb.group({
columns: this.fb.array([this.createColumn()]) // Initialize with one column
columns: this.fb.array([this.createColumn()])
}); });
this.rows.push(row); this.rows.push(row);
} }
@@ -85,16 +82,13 @@ export class VeriableFormComponent implements OnInit {


for (let item of this.rdsValues.modbus) { for (let item of this.rdsValues.modbus) {
if (item.hasOwnProperty(selectedParam)) { if (item.hasOwnProperty(selectedParam)) {
// Initialize the row if not present
if (!this.selectedParamValue[rowIndex]) { if (!this.selectedParamValue[rowIndex]) {
this.selectedParamValue[rowIndex] = {}; this.selectedParamValue[rowIndex] = {};
} }
// Assign the selected param value to the specific row and column
this.selectedParamValue[rowIndex][colIndex] = item[selectedParam]; this.selectedParamValue[rowIndex][colIndex] = item[selectedParam];
break; break;
} }
} }

this.inputValue = this.selectedParamValue[rowIndex][colIndex] this.inputValue = this.selectedParamValue[rowIndex][colIndex]
console.log(`Row: ${rowIndex}, Column: ${colIndex}, Value:`, this.selectedParamValue[rowIndex][colIndex]); console.log(`Row: ${rowIndex}, Column: ${colIndex}, Value:`, this.selectedParamValue[rowIndex][colIndex]);
} }


Loading…
Cancel
Save