I am currently facing an issue with the DevExtreme datasource and have already reached out to their support team for assistance. However, I can't help but wonder if I might be overlooking something simple in Angular.
DevExtreme offers an AspNetData source control that streamlines communication with .NET APIs. It allows you to define additional parameters through an Options object. In my particular case, I have set up a "firmaId" loadParams that retrieves its value from a function.
The function "getFirmaId()" merely returns the value of the "firmaId" variable. The selectTab(e) function is triggered when a tab controller is clicked, updating the "firmaId" successfully. However, when I attempt to load the DataSource using the DevExtreme client API, the loadParams of "firmaId" always shows as 0. Is this behavior expected? To me, it seems to contradict the principles of functional programming in JavaScript.
Any assistance on this matter would be greatly appreciated.
firmaId: number;
constructor(private dataService: DataService) {
this.firmaId = 0;
this.dataSource = AspNetData.createStore({
key: "id",
loadUrl: Constants.apiRoot + "/api/cari/get",
insertUrl: Constants.apiRoot + "/api/cari",
updateUrl: Constants.apiRoot + "/api/cari",
deleteUrl: Constants.apiRoot + "/api/cari",
loadParams: { firmaId : this.getFirmaId() },
onBeforeSend: function(method, ajaxOptions) {
ajaxOptions.xhrFields = { withCredentials: true };
}
});
}
getFirmaId():number{
return this.firmaId;
}
selectTab(e) {
this.firmaId = e.itemData.id;
this.dataSource.load();
}