Hello,
my requirements are to sum all the(or some of them) cells on a wingrid of a column and the result use it for other calculation or put it on label or else. How can i do that?
thank you.
Hi Walter,
Which part of this is giving you trouble? There are several samples of using formulas in the grid included with the NetAdvantage SDK.
The easiest way to do something like this would be to use a Summary in the grid. The summary formual would be something like this:
"SUM([columnKey])"
Hi Mike,
i have seen this example http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=10019 but it does not satisfy my req. I'll make an example to explain better: Suppose you have to sum some(or all) cells on a grid and the result sum with a value on an ultranumeric editor and last divide it by a number. Can i do this calcs using only an ultracalcmanager? for example create a named reference1 that holds the sum value of the cell, then create another named reference2 that holds the value of the first namedRef plus the value of the ultranumeric editor...
ps.I dont want to use summaries to get the value sum of the cells
Hi Walter.
This all sounds like a pretty simple case of using formulas to me. I'm having a hard time understanding what you are asking for here. Are you having trouble with the syntax? Or setting up a NamedReference? Or applying a formula to an UltraNumericEditor?
Personally, I would use a NamedReference for anything you don't need to display to the user. It doesn't make sense to use a control just to calculate a formula that is never displayed.
To sum grid column in a NamedReference, you would use the Sum function and pass in the grid column reference.
perhaps its a syntax problem on the formula. I have made a simple example and attached to this discussion. It is a form that has a wingrid with 1 column and an ultranumericeditor. Basically i want to sum all cells of this column and the result multiplied by 2, finally show this result on the ultranumericeditor.
I took a look at your sample and the problem appears to be with the key of the first (and only) band in the grid. You are assigning a DataTable as the grid's DataSource, but this table has no TableName set.
So the grid and the Formula Builder are assuming that the key of this band should be "Band 0", which is what you have in your formula.
But the grid's CalcReference for this band is using a different key for some reason. This is probably a bug, and I encourage you to Submit an incident to Infragistics Developer Support. Just include your sample project and a link to this thread.
Anyway, this is very easy to fix. All you have to do is set the TableName on your DataTable to "Band 0" and it works fine.
Good point. You really would not be able to fix it in a case like that unless you knew the name of the reference that the CalcReference for the grid is using interally. I think it goes something like: "_band_0". Like I said, this is almost certainly a bug.
Fortunately i'm using datatable, but how can i fix this problem if i have a custom List of object as a datasource of the grid? something like this
public class Person { private String _Name; private double _Salary; public double Salary { get { return _Salary;} set { _Salary = value; } } public string Name { get { return _Name; } set { _Name = value; } } }
ultraGrid2.DataSource = TestData2();
public List<Person> TestData2() { List<Person> persons = new List<Person>(); Person ps = new Person(); ps.Salary = 1500; ps.Name = "John"; Person ps1 = new Person(); ps1.Salary = 2100; ps1.Name = "Jim"; persons.Add(ps); persons.Add(ps1); return persons; }
ps:I have submited a new incident.