Monday, July 7, 2025

The Angular CLI requires a minimum Node.js version of either

 

The Angular CLI requires a minimum Node.js version of either

The error "The Angular CLI requires a minimum Node.js version of either" occurs when your Node.js version is not supported by the Angular CLI.

To solve the error, install the long-term supported version of Node.

You can use the node -v command to check your version of Node.js.
if you saw in error it is indicate current node version is 20.15 but it is not supporting so we have to upgrade Node version -
So we have to upgrade node-v22.17.0-x64 ( You can use node version according to you angular version ).

Thank you when you update the version this issue is fixed.


Thank you Hope it is help you !  


Thursday, July 3, 2025

How to connect Source control in Visual studio code

Dear Developer,

When starting a new project in Visual Studio and you want to connect it to source control, here’s what you need to do:

Take a look at the window below:

1st you have to download and install the Gits for window(I am using window os you can manage according to your OS) the URL is https://git-scm.com/downloads/win

Then, refer to the first screen and click the Reload link. You should see a screen like the one below:
Thank you! I hope this was helpful to you.







Unable to find packages "PackageName". No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Microsoft Visual Studio Offline Packages

 Hello Everyone,

Sometimes, when you clone your code to a new location and try to run it, you might encounter an error like:

Unable to find package "PackageName". No packages exist with this ID in source(s): C:\Program Files\dotnet\library-packs, Microsoft Visual Studio Offline Packages

Don’t worry — this is a common issue, and the solution is simple. Just follow the steps below to resolve it.

✅ Here's how to fix it:

1. Add nuget.org as a Package Source

Visual Studio might not be configured to look at the official NuGet repository. To fix this:

  1. Go to Tools > Options.
  2. Navigate to NuGet Package Manager > Package Sources.
  3. Click the "+" button to add a new source.
  4. Set:
    • Namenuget.org
    • Sourcehttps://api.nuget.org/v3/index.json
  5. Click Update or OK to save.

Make sure nuget.org is checked and at the top of the list 

your setting look like as below screen.

Rebuild your solution ! Hope it help you 
Thank you!





Wednesday, December 4, 2024

How to set Custom Filter Menu Components in angular 17 with Kendo UI

 Dear Reader, 

if you want to set menu filter Kendo UI with angular then it very useful tips.

 for example when you are using  <kendo-grid></kendo-grid> so you have to follow below steps for filter the menu.



on UI Component

<kendo-grid
[data]="gridDataSource$ | async"
filterable="menu"
(dataStateChange)="dataStateChange($event)">  
<kendo-grid-column field="productName" title="Product Name" width="150">
</kendo-grid-column>
</kendo-grid>



and My TS code are as below
import { process, State } from '@progress/kendo-data-query';

export class DataComponent implements OnInit {
  skip = 0;
  public state: State = {
    skip: 0,
    take: 10,
    filter: {
      logic: 'and',
      filters: []
    }
  };
dataStateChange(state: DataStateChangeEvent): void {
    this.state = state;
    this.loadData();
  }

  private loadData(): void {
    this.gridDataSource$ = this.gridDataSubject.asObservable().pipe(
      map(gridDataResult => process(gridDataResult.data, this.state))
    );
  }

}

Thank you Hope it is helpful to you ! Happy learning.

Wednesday, November 20, 2024

Upgrade braces from 3.0.2 to 3.0.3 to fix the vulnerability.

if you are working in angular with good MNC company so you have audit issue , how to fix the audit issue regarding the below issue.

Recommendation

Upgrade braces from 3.0.2 to 3.0.3 to fix the vulnerability.


Description

The NPM package braces fails to limit the number of characters it can handle, which could lead to Memory Exhaustion. In lib/parse.js, if a malicious user sends "imbalanced braces" as input, the parsing will enter a loop, which will cause the program to start allocating heap memory without freeing it at any moment of the loop. Eventually, the JavaScript heap limit is reached, and the program will crash.


How to Fix it , it is very simple :-

If you are using NPM 6 or above, you can run npm audit fix on your local machine to fix vulnerabilities. For more info, please visit https://docs.npmjs.com/cli/audit


Hope it is help you, Happy Learning! ....

Monday, October 7, 2024

How to change datetime2 data type to INT

 Dear Friend,

i am come with new solution if you stuck some place your are not able to  ALTER COLUMN the column if column data type is datetime2  so without delayed below is solution.

if you tried with normal query just like ALTER TABLE table ALTER COLUMN [Period] int; 

The Error is :- Operand type clash: datetime2 is incompatible with int?

The error you’re encountering indicates that the Period column currently has a datetime2 data type, and you’re trying to change it to int. Directly changing the data type from datetime2 to int is not allowed because they are incompatible types.

To resolve this, you need to follow these steps:

  1. Create a New Column:

    • Add a new column with the desired data type (int).-- Step 1: Add a new column with the desired data type
    • ALTER TABLE tableName ADD PeriodInt INT;
  2. Update the New Column:

    • Populate the new column with the converted values from the existing column.
    • -- Step 2: Update the new column with converted values
      UPDATE tableName 
      SET PeriodInt
      = YEAR(Period) * 100 + MONTH(Period);
  3. Drop the Old Column:

    • Remove the old column.
    • -- Step 3: Drop the old column
      ALTER TABLE tableName 
      DROP COLUMN Period;
  4. Rename the New Column:

    • Rename the new column to the original column name.
    •  Step 4: Rename the new column to the original column name
      EXEC sp_rename 'tableName 
      .PeriodInt', 'Period', 'COLUMN';



Thank you for your Time Hope it will help you

Friday, October 4, 2024

Kendo-Grid checkbox selected value update on database - step 1 How to do settings on Child component.

 Dear Reader,

This is a very important topic because developers are often confused about how to manage checkbox checked and unchecked values, and how to update multiple records with one click. First, I will explain how to set up the settings in the child component, which you can then use across multiple components. Here is my Child-Grid

<kendo-grid
  [data]="gridDataResult"
  (dataStateChange)="onDataStateChange($event)"
  (edit)="onEdit($event)"
  [selectable]="{ mode: 'multiple', checkboxOnly: true }"
  kendoGridSelectBy="id"
  [(selectedKeys)]="selectedKeys"
  (selectionChange)="onSelectionChange($event)"
  (selectedKeysChange)="onSelectedKeysChange()"
>
  <ng-template kendoGridToolbarTemplate>
    <button kendoGridAddCommand *ngIf="gridSetting.enableAdd">{{ gridSetting.addCommandTxt }}</button> 
    <button type="button" *ngIf="gridSetting.enableExport" kendoGridExcelCommand>Export to Excel</button> 
    <button kendoButton *ngIf="gridSetting.enableSave" (click)="onUpdateSelected()">Submit Selected Entry</button>
  </ng-template>

  <!-- Move the checkbox column to the first position -->
  <kendo-grid-checkbox-column *ngIf="showCheckbox" [showSelectAll]="true" [width]="50"></kendo-grid-checkbox-column>

  <kendo-grid-command-column
    [title]="gridSetting.commandColTxt"
    [width]="gridSetting.commandColWidth"
    *ngIf="gridSetting.enableEdit || gridSetting.enableRemove || gridSetting.enableDeny"
  >
    <ng-template kendoGridCellTemplate let-dataItem>
      <button kendoGridEditCommand [primary]="true" look="flat" *ngIf="gridSetting.enableEdit">
        <span class="k-icon k-i-edit" [title]="gridSetting.editCommandTxt">{{gridSetting.editCommandTxt}}</span>
      </button>
      <button kendoGridEditCommand [primary]="true" look="flat" *ngIf="gridSetting.enableDeny">
        <span class="k-icon k-i-edit" [title]="gridSetting.denyCommandTxt">{{gridSetting.denyCommandTxt}}</span>
      </button>
      <button
        kendoGridRemoveCommand
        *ngIf="gridSetting.enableRemove && (dataItem[gridSetting.activeFlagField] || gridSetting.activeFlagField === undefined)"
      >
        {{ gridSetting.removeCommandTxt }}
      </button>
    </ng-template>
  </kendo-grid-command-column>

  <kendo-grid-column
    *ngFor="let column of columns"
    [hidden]="column.type === ColumnTypeEnum.Hidden"
    [field]="column.displayField === undefined ? column.field : column.displayField"
    [title]="column.title"
    [format]="column.format"
    [filter]="column.filterType"
    [width]="column.width"
  >
    <ng-template kendoGridCellTemplate let-dataItem let-data *ngIf="column.type === ColumnTypeEnum.Checkbox">
      <input
       [state]="selectAllState"
       kendoGridSelectAllCheckbox
       (selectAllChanges)="onSelectAllChanges($event)"
        type="checkbox"
        kendoCheckBox
        disabled
        [attr.checked]="
          dataItem[column.displayField === undefined ? column.field.toString() : column.displayField.toString()] ? 'checked' : null
        "
      />
    </ng-template>
  </kendo-grid-column>

  <kendo-grid-excel [fileName]="gridSetting.exportFileName"></kendo-grid-excel>
</kendo-grid>


My Ts file 


@Component({
  selector: 'app-shared-common-grid',
  templateUrl: './common-grid.component.html',
  styleUrls: ['./common-grid.component.scss']
})
export class CommonGridComponent extends BaseGridComponent implements OnInit {
 
  @Input() showCheckbox: boolean = true;
  @Input() set gridDataSource$(input$: Observable<GridDataResult>) {
    if (input$) {
      this.gridData$ = input$;
      this.refreshGridData();
    }
  }
  @Input() private saveSuccess: EventEmitter<any>;

  @Output() selectionChange: EventEmitter<SelectionEvent> = new EventEmitter<SelectionEvent>();
  @Output() selectAllChanges: EventEmitter<SelectAllCheckboxState> = new EventEmitter<SelectAllCheckboxState>();
  @Output() selectedKeysChange: EventEmitter<void> = new EventEmitter<void>();
  @Output() loadingStateChange: EventEmitter<boolean> = new EventEmitter<boolean>();
  loading: false;
 
  selectedRecords: Array<any> = [];
  public selectAllState: SelectAllCheckboxState = "unchecked";
  public selectedKeys: Array<number> = [];
  constructor() {
    super();
  }

 
  onSelectionChange(e: SelectionEvent): void {
    this.selectionChange.emit(e);
  }

  onSelectAllChanges(checkedState: SelectAllCheckboxState): void {
    this.selectAllChanges.emit(checkedState);
  }

  onSelectedKeysChange(): void {
    this.selectedKeysChange.emit();
  }

 
}

Now My Parent code is as below :

<app-shared-common-grid
    [columns]="columns"
    [gridLoading]="loading"
    [gridSubmitting]="submitting"
    [gridDataSource$]="gridDataSource$"
    [gridSetting]="gridSetting"
    [saveSuccess]="saveSuccess"
    [showCheckbox]="true"
    (updateSelectedRecords)="onUpdateSelectedRecords($event)"
    (editClicked)="onEditClicked($event)"
    (selectionChange)="handleSelectionChange($event)"
    (selectAllChanges)="handleSelectAllChanges($event)"
    (selectedKeysChange)="handleSelectedKeysChange()"  
  ></app-shared-common-grid>

My Parent TS


@Component({
  selector: 'app-sample-submit-list',
  templateUrl: './submit-list.component.html'
})
export class SubmitListComponent implements OnInit {
  form: FormGroup;
  dropdownLoading = true;
  productControl: FormControl;
  loading = false;
  submitting: boolean;
  columns: ColumnSetting[];
  gridSetting: GridSetting;
  gridDataSource$: Observable<GridDataResult>;
  private gridDataSubject = new BehaviorSubject<GridDataResult>({ data: [], total: 0 });
  saveSuccess: EventEmitter<any> = new EventEmitter();
  hasData$: Observable<boolean>;
  ApproverDataSource$: Observable<Approver[]>;
  selectedKeys: any[] = [];
  selectedRecords: any[] = [];
  public mySelection: number[] = [];
  selectAllState: SelectAllCheckboxState = "unchecked";
  constructor(
  ) {
   
  }
  ngOnInit(): void
  }

  handleSelectionChange(event: SelectionEvent) {
    // Handle selection change event
    console.log('Parent component selection change:', event);
    if (event.selectedRows && event.selectedRows.length > 0) {
      event.selectedRows.forEach(row => {
        if (!this.selectedRecords.some(record => record.id === row.dataItem.id)) {
          this.selectedRecords.push(row.dataItem);
        }
      });
    }

    if (event.deselectedRows && event.deselectedRows.length > 0) {
      const deselectedIds = event.deselectedRows.map(row => row.dataItem.id);
      this.selectedRecords = this.selectedRecords.filter(record => !deselectedIds.includes(record.id));
    }

    this.selectedKeys = this.selectedRecords.map(record => record.id);
  }


  handleSelectAllChanges(checkedState: SelectAllCheckboxState) {
    // Handle select all changes event
    console.log('Parent component select all changes:', checkedState);
    if (checkedState === 'checked') {
      this.gridDataSource$.subscribe(data => {
        this.selectedRecords = data.data.filter(record => record.isChecked);
        this.selectedKeys = this.selectedRecords.map(record => record.id);
      });
    } else {
      this.selectedRecords = [];
      this.selectedKeys = [];
    }
  }

  handleSelectedKeysChange() {
    // Handle selected keys change event
    console.log('Parent component selected keys change');
    const len = this.selectedKeys.length;
    this.gridDataSource$.subscribe(data => {
      const gridDataLength = data.data.length;
      if (len === 0) {
        this.selectAllState = 'unchecked';
      } else if (len > 0 && len < gridDataLength) {
        this.selectAllState = 'indeterminate';
      } else {
        this.selectAllState = 'checked';
      }
    });
  }

  handleLoadingStateChange(isLoading: boolean) {
    // Handle loading state change
    this.loading = isLoading;
  }


  onUpdateSelectedRecords(selectedRecords: any[]): void {
    if (this.selectedKeys.length > 0) {
      this.submitting = true; // Activate the loader
      this.serviceforUpdate.updateRecords(this.selectedKeys).subscribe(
        res => {
          console.log('Selected records updated successfully.');
          this.notifyResult(res);
        },
        error => {
          console.error('Error updating records:', error);
          this.notifyResult({ viewStatus: ViewStatus.Failure, message: 'Error updating records' });
          this.submitting = false;
        }
      );
    } else {
      console.log('No records selected.');
    }
  }

 
}

Here is the full code. I hope it helps you. Thank you, Guru (Mr. Surendra), for explaining all the concepts.