Hello Team,
Am trying to sum up the quantity and Total Amount in my dataTable footer, but is showing underline red, how do I modified the code to to perform this sumation and the total should only display the Quantity and TotalAmount at the footer after a date range is selected such as StartDate to EndDate ,
public ActionResult getNewOrder()
{
using (db = new ASPNETMASTERPOSTEntities())
{
var dataList = db.tblCustomers.Include("tblOrders");
var modifiedData = dataList.AsEnumerable().SelectMany(x => x.tblOrders.Select(d => new OrderViewModel
{
CustomerId = x.CustomerId,
CustomerName = d.tblCustomer.CustomerName,
PhoneNo = d.tblCustomer.PhoneNo,
OrderDate = d.tblCustomer.OrderDate,
CategoryName = d.CategoryName,
ProductName = d.ProductName,
Quantity = d.Sum(x=>x.tblOrders.Quantity),
UnitPrice = d.UnitPrice,
TotalAmount = d.Sum(x => x.tblOrders.TotalAmount),
OrderId = d.OrderId
})).ToList();
return Json(modifiedData, JsonRequestBehavior.AllowGet);
}
}
Vishal JoshiPosted Jul 12, 2023, 11:11 AM
Hello Emma,
You need to use the footerCallback method of the jquery data table for summation.
Please check below sample code for the same.
Thanks
Vishal Joshi
Deepak RawatPosted Jul 3, 2023, 5:55 AM
to calculate the sum of quantities and total amounts in a DataTable footer, but the code you provided is showing an underline in red. Unfortunately, I don't have the complete context of your code or the specific error message you're encountering, which makes it difficult to pinpoint the exact issue. However, I can provide you with some general guidance to help you modify your code.
consider the following modifications to your code:
Amit MohantyPosted Jul 3, 2023, 5:23 AM
If the OrderDate property is of type string instead of DateTime, then you need to convert the OrderDate string to DateTime before performing the comparison.
Emmmanuel FIADUFEPosted Jul 2, 2023, 5:46 PM
Senior Amit, I encounter this error after trying your code
Amit MohantyPosted Jul 2, 2023, 5:31 AM