joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
75 stars 56 forks source link

Total Amount of a column #199

Open jsuske1985 opened 4 years ago

jsuske1985 commented 4 years ago

Hi,

I was able to get a total amount of one column...but now I am having trouble displaying it, what would you recommend?

           ```

result.Items = query.ToList();

            var totalAmount = 0.0;

            foreach (var item in result.Items)
            {
                totalAmount += item.Amount;
            }

            ViewBag.totalAmount = totalAmount;


I have tried with a ViewBag but that did not work at all. This code is inside the RetrieveData block. 
snehalgiramkar commented 4 years ago

I need to display total which will be sum of a particular column in grid itself. Let me know for solutions

jsuske1985 commented 4 years ago

I need to display total which will be sum of a particular column in grid itself. Let me know for solutions

Hi, I did figure out a solution, but I don't exactly remember what I did to get it to work...basically I had to edit the project a build a new dll for it. I have attached the project I downloaded and adjusted, the dll is in there also. This will update the totalAmount of items on the page. The usage is similar to what I have above, you just have to assign the total amount to the totalAmount QueryResult model object...hope this makes sense. MVCGrid.Net-master.zip