Hi Infragistics team,
I have a UltraWin Grid in my application where there are 2 types of columns Bound
and Unbound. I have a masking set to nnnn for both the columns.
Issue: In bound columns the value that is coming is of 10 digits and due to masking(nnnn)
the significant digits from from (left) of the figure is getting truncated where as in unbound
column, it is getting truncated from Trailing side which is fine and that is what required in
bound columns also. Any Quick fix will be appreciated.
Regards,
Sanjiv
Hi Sanjiv,
I doubt this has anything to do with the columns being bound or unbound. My guess is that the columns you are looking at are using different DataTypes.
Check the DataType property on each column at run-time.
Hi Mike,
Gud to hear from you.
Actually the underlying data type is double. Although the masking is "nnnn".
Actually why I brought up the bound / unbound issue because in bound column, it is trunctaing the
figure from front chopping off the significant digits and in unboud columns it is trunctaing the value
from trailing side that is what required.
In unbound column there is no data type set explicitly may be that is behaving in the right manner.
I don't see how bound or unbound could possibly make any difference. The editor that handles the masking gets the value of the cell from the grid. It does not know or care where the data comes from or whether the field is bound or not.
So there must be some other difference between the columns.
Please have a look @ the follwing example for the unbound / bound column issue.
1) Put the ultragrid on the form in windows application
2) Use following code in Formload or any button click vent handler
////Create the data table
DataTable table = new DataTable();
table.Columns.Add("Bound", typeof(double)); // type double
table.Columns.Add(
"Dummy2", typeof(int)); // type int
if (!ultraGrid1.DisplayLayout.Bands[0].Columns.Exists("UnBound"))
{
ultraGrid1.DisplayLayout.Bands[0].Columns.Add(
"UnBound"); // Adding unbound column
}
table.Rows.Add(12345.67, 12345);
ultraGrid1.DataSource = table;
ultraGrid1.Rows[0].Cells[2].Value = 12345.67;
ultraGrid1.DisplayLayout.Bands[0].Columns[1].MaskInput =
"nnnn";
ultraGrid1.DisplayLayout.Bands[0].Columns[0].MaskInput = "nnnn.nn";//bound column
ultraGrid1.DisplayLayout.Bands[0].Columns[2].MaskInput = "nnnn.nn";//Unbound column
Bound Dummy2 Unbound
2345.67 1234 1234.50
Now that is what decribes the problem with bound / unbound columns. Original value is 12345.67, In Bound column it is 2345.67 (Truncating 1 from front)
but in unbound column, it is 1234.50
There is a difference between '9' and 'n'. The 'n' indicates a number section. So a group of n's is treated as a group, whereas a '9' is just a single character which is not tightly tied to the other 9's adjacent to it.
I can't make unbound columns as it will not fulfill my requirements.
Any ways, I just want to know one thing why is 9999.99 and nnnn.nn is different in truncation. i think they should behave like same. OR Is there any other difference between them which is why value gets truncated from trailing side in 9999.99 and it act same for double and string type
But in nnnn.nn, value gets truncated from front and it is different for string and double.
I do not understand. Are you saying that you want the bound columns to behave like they are strings?
There's no way to do that directly. But you could create unbound columns for each of your numeric columns and then hide the numeric columns from the user. Then you would use the InitializeRow event to copy the value of the real numeric column into the unbound (string) column.
Agreed!!! Even I also figured out that yesterday about default set to string.
So what i need is the way so that the figure should only get truncated from trailing side.
I tried 9999.99 and it worked fine(trailing side gets truncated) for both the cases bound / unbound.
But the issue with the 9999.99 format is when I enter the value in cell in edit mode say like the
value is 12.55 then it appears like 12 .55 even though it appears correctly after exiting from cell i.e. 12.55
Okay, as I said, the problem here has nothing to do with bound or unbound.
The issue is that you are never setting the DataType on the unbound column. It therefore defaults to String. So the difference you are seeing here is the difference between a numeric column and a string column.
Set the DataType on the unbound column to double or int and it will work the same as the bound columns do.