web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

add total to Gridview

(0) ShareShare
ReportReport
Posted on by 2,050

greetings 

i'v created new form and i add Gridview data source of this Gridview is temptable

and that Gridview have allow to add or delete row and there's column have amount

so i want sum (total) that column even after add or delete rows (means i only want total for column amount of Gridview Regardless temptable)

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    If I understand your requirement correctly, it's the same thing that was discussed in the thread Show summary of tempory table for a grid control two weeks ago.

  • mohammed.mqi Profile Picture
    2,050 on at

    does this include newly added rows manually

    which did not already before in the data source?!!

    because some of columns on grid allow to editable

    and where should i put this method in data source of table?!

    updateTotal()
  • Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    I'm sorry, but I don't understands most of what you're saying. What do you mean by "which did not already before in the data source"? How is it related to that "some of columns on grid allow to editable"? Which scenario are you talking about when you ask where you should put the method?

    The solution in the blog post calculates totals when the form query gets executed, but you can easily call recalculation at other places as well (such as after inserting a new record).

  • mohammed.mqi Profile Picture
    2,050 on at

    thanks for replay

    as you see here

    bringdata.PNG

    when i click bring data it will be collect all data which i asked from my code (query) to temptable then will populate into grid and user he can add more rows as he like or even he can delete

    so i was mean the row which add recently by user it dosn't came from my query 

    in this case I just want to sum the final result of the grid 

    in c# i was summing column of grid like this

    int sum = 0;
    for (int i = 0; i < dataGridView1.Rows.Count;   i)
    {
        sum  = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
    }
    label1.Text = sum.ToString();

    how can i do that on my grid x

  • Suggested answer
    Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    Please forget that C# code, it's for arrays while we're talking about AX tables. In X++, you should use the sum() aggregation function to sum the values.

    Look again at Summarized values in AX form; you'll find both an explanation and code there.

  • mohammed.mqi Profile Picture
    2,050 on at

    thanks for replay

    i tried that but still didn't get it i'm trying to do sum for column after he modify the price on Adjusted Price

    so i'm already create button to create with control RealEdit named (Total) to get sum over there

    but still give me 0 value when i press on button to execute updateTotal() method

  • Martin Dráb Profile Picture
    239,680 Most Valuable Professional on at

    The solution demonstrated in the blog post uses a database query to calculate the sum - something like sum(MyField) from MyTable where {filters used on the form} (it just uses query classes to generate the statement).

    If you run this calculation after adding a new record or changing an existing one, it'll summarize all records again (including what you've added or changed).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans