Hello Team,
I have two form view, the Outer layer consist of SupplierId, Supplier name, Purchase date,Amount, Discount,GrandTotal,IsPaid, detail button and, delete button, so the logic is that when I click detail button on form View one then it will open form view two which contain the product details.
In my angular Js controller contain the dataTable of the Form View one and JS Controller is not able to filter the record based on the supplierId when I click on Detail button which needs to open form view two for me.

I want to filter the data base on supplliers.

FORM VIEW TWO BELOW, it load all the data from the database and not by supplierId

My first method load all the data into the Form two View without filltering and the second method give this generic error;
and when I implement the second method then this error popup;
DataTables warning: table id=PurchaseDataTable - Ajax error. For more information about this error, please see
First Method that load all the data is;
public ActionResult GetAllPurchases()
{
try
{
var purchases = objRestaurantDBEntities.tblPurchases
.Select(x => new PurchasesViewModel
{
PurchaseID = x.PurchaseID,
StockInDate = x.StockInDate,
SupplierId = x.SupplierId,
Name = x.tblSupply.Name,
Total = x.Total,
Discount = x.Discount,
Tax = x.Tax,
GrandTotal = x.GrandTotal,
IsPaid = x.IsPaid,
Description = x.Description
})
.ToList();
return Json(purchases, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
Emmmanuel FIADUFEPosted Apr 19, 2025, 12:02 AM
Please I have change the code from AngularJs function to to javascript function so don't wory trying to give me the answer now, I will provide the right code in due time
Emily FosterPosted Apr 18, 2025, 10:28 PM
It seems like the issue you are facing is related to filtering data by SupplierId in your AngularJS controller when clicking on the Detail button to open Form View Two.
Based on the provided code snippet, it appears that the GetAllPurchases method retrieves all purchases without filtering by SupplierId. To filter the data based on the SupplierId, you need to pass the SupplierId as a parameter when calling the GetAllPurchases method.
Here is an example of how you can modify the GetAllPurchases method to accept a SupplierId parameter and filter the data accordingly:
In your AngularJS controller, make sure to pass the SupplierId parameter when calling the GetAllPurchases method based on the selected Supplier. This way, you will fetch only the purchases related to that specific SupplierId.
By implementing this modification, you should be able to filter the data based on SupplierId when opening Form View Two from Form View One. This adjustment allows you to retrieve and display the correct purchase records for a specific supplier.