I have grid where each cell represents some quantity of different widgets. I would like the user to be able to press on button and switch from the quantity of the widget to its value. So, for example, widget1 is worth $5 a piece and widget2 is $6 a piece
Qty based display
widget1 1 2 3
widget2 5 10 15
Corresponding $ based display
widget1 $5 $10 $15
widget2 $30 $60 $90
This $-based grid is not editable since it is derived from the qty based information. But the qty-based grid is editable and how the information would be held in the datatable.
Since this $-based information is not editable, I am hoping I do not have to generate another datatable to hold these derived numbers. What are my options?
Thanks!
I'm a little fuzzy on what the actual data looks like here. Does the data contain the quantities or the prices? Or both? Is the value just a straight multiplication of quantity times some constant?
It seems like the thing to do here is use unbound columns and hide the "real" column. Let's say, for example, that the data source here contains quantities and the $ values are determined by some calculation. I would bind the grid to the quantities and hide the actual columns, then create an equal number of unbound column in the grid. Use the InitializeRow event of the grid to copy the value of the "real" column into the unbound column. You can base whether or not to copy the actual value or the $ value on a flag.
To handle updates, you would handle the BeforeRowUpdate event and reverse this process, copying the unbound column value into the "real" column.
the only other issue is what to do to get the grid to refresh when you change your flag. This is easy - you just call grid.Rows.Refresh(FireInitializeRow).
Chris Bishop said:you thought about adding unbound columns? and then just looping through to do your cacluations?
Yes, I have been thinking of a similar idea. I was thinking I would create another table to hold these value and writing event handler to keep them in synch. As you suggest I can instead create a new column for every qty data column. The dollar data column can been tied to qty data column using CalcManager formulas . The disadvantage is both options would double the amount of memory. Your text attribute idea was very promising and would have been an "eyes only" kind of solution I was looking for if had worked. Thanks again for trying hard for the solution.
I will see if Mike Saltzman has some suggestions on Monday.
weird every once in awhile it tells me i cannot post without approval hmmmm....Well incase you don't get my last message i will try it again... I don't think you are going to be able to do the "text vs value" thing (sorry haven't been in win controls in awhile so gave you the wrong adivse there)...
Knowing that you do not want to modify your dataset have you tried adding unbound colums?Something like:
using Infragistics.Win.UltraWinGrid;
public class Form1 { private void Form1_Load(object sender, System.EventArgs e) { this.UltraGrid1.DisplayLayout.Bands(0).Columns.Add("widgetAcol", "WidgetA Text"); UltraGridRow x; foreach ( x in UltraGrid1.Rows) { if (x.Cells(0).Value == 1) { x.Cells(4).Value = "I am widget a text value"; } } } }
just noticed that myself (haven't been in the win controls in awhile) I am not sure you are going to be able to do the "text vs value" thing however knowing that you don't want to mess with your dataset have you thought about adding unbound columns? and then just looping through to do your cacluations?
something like:
I found that in UltraWinGrid, a cell's text property is read-only.
Try this and it won't compile -> ultraGrid1.DisplayLayout.Rows[0].Cells[0].Text = "hello"
Did you mean some other property?
So I am still looking for suggestions.