Here is my code on home.component.ts -
import { Component, OnInit, ViewChild } from '@angular/core';
import { DataManager, Query, UrlAdaptor, WebApiAdaptor, ODataAdaptor } from '@syncfusion/ej2-data';
import { GridComponent, EditService, ToolbarService, PageService, ColumnChooserService, EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-ng-grids';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
providers: [ToolbarService, EditService, PageService, ColumnChooserService]
})
export class HomeComponent implements OnInit {
public title: string = "Manage Client Payment Options";
public data: Object[];
public dataManager: DataManager;
@ViewChild('grid')
public grid: GridComponent;
public editSettings: EditSettingsModel;
public toolbar: ToolbarItems[];
public pageSettings: Object;
ngOnInit(): void {
console.log("This is testing");
this.dataManager = new DataManager({
//url: '/api/Payment',
url: '/api/Payment',
adaptor: new WebApiAdaptor
});
this.editSettings = { allowEditing: true, allowAdding: false, allowDeleting: false, mode: 'Normal' };
this.toolbar = ['Edit', 'Update', 'Cancel', 'ColumnChooser'];
//this.pageSettings = { pageCount: 5 };
}
}
Here is my Web API Code -
[HttpGet()]
public ActionResult Get()
{
List<ClientInfo> clientPaymentInfos = new List<ClientInfo>();
Int32 intCnt = 0 ;
DataTable dtPaymentInfo = new DataTable();
using (SqlConnection conn = new SqlConnection(_connString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "pr_GetAllClientInfo";
SqlDataReader dr = cmd.ExecuteReader();
dtPaymentInfo.Load(dr);
intCnt = dtPaymentInfo.Rows.Count;
foreach(DataRow dRow in dtPaymentInfo.Rows)
{
ClientInfo clientInfo = new ClientInfo();
clientInfo.clientNumber = dRow["ClientNumber"].ToString();
clientInfo.clientName = dRow["ClientName"].ToString();
clientInfo.relatedClientNumber = dRow["RelatedClientNumber"].ToString();
clientInfo.allowACHProcessing = (Boolean)dRow["AllowACHProcessing"];
clientInfo.allowCCProcessing = (Boolean)dRow["AllowCCProcessing"];
clientPaymentInfos.Add(clientInfo);
}
}
}
var result = new { count = intCnt, result = clientPaymentInfos };
return Ok(result);
}
But whenever I try to run and check the browser it does not call the Web API at all. If I try it separately it does work but cannot call from the data manager. But I get the following error -
core.js:1448 ERROR TypeError: Cannot read property 'length' of undefined
at WebApiAdaptor.UrlAdaptor.getRequestQuery (adaptors.js:474)
at WebApiAdaptor.UrlAdaptor.processQuery (adaptors.js:435)
at DataManager.executeLocal (manager.js:116)
at eval (manager.js:164)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4736)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at ZoneTask.invokeTask (zone.js:496)
at ZoneTask.invoke (zone.js:485)
defaultErrorLogger @ core.js:1448
Any help is greatly appreciated. My old projects still work. Not sure what the new version of .NET core is having issues.