I'm using the UltraWebGrid (8.3) to edit data and have a column with format set as "#,##0.00" to display dollar amounts. On a few of the cells in that column I need to allow whole dollars only. I wanted to override the column format property for those cells to "#,##0" in the InitializeRow method but can't find any format property at the cell level. How would I accomplish this?
Thanks in advance.
Hello,
Yes, this is correct - format is only applicable per Column programmaically and applies for all Cells. However, you can easily change that - just set the Cell.Text property to any format you wish using String.Format (String.Format uses similar format mask syntax as the Column.Format property)
Thanks for your response. But I'm not clear where the best place is to do this. I had thought reading your response that I would put the code in the InitializeRow method. But at that point the text has not yet been formated by the column. I need to change the text in the cell after the column has applied it's format. Is there a method at the row level that is after formatting or do I need to manally reformat each row in the grid's PreRender method? Seems like there should be a better way.
Thanks again.
I tried removing the Format in the aspx code and manually formatting all the cells in the InitializeRow method. Some are formatted as money with 2 decimal places and some as other values that don't have decimal places. This appeared to give me what I wanted. But when I edit a cell that should contain a money amount, it no longer formats on the client side. Thus I enter "100000" and want it to format as "100,000.00" but I get "100000". Seems like the only way to do that is to apply the format to the column. Since there appears to be no way to override the column format on individual cells, I'm concluding that the grid cannot handle different formats in different rows.
I am looking at a solution for this as well. I am surprised this is not a feature that has long been requested by developers. Is there anyway to override the format or input provider?
Yes, I indeed did not take into account editing of the data. I scoured the help for some hooks where you can possibly run custom code to change the format before and after editing but could not really work something out using our client side events documented here (Befoire and After editing..)
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR3.5/html/WebGrid_Client_Side_Events_CSOM.html
Also all forum threads discuss read only grids and not editing in this scenario:
http://forums.infragistics.com/forums/p/11489/43640.aspx#43640
Hopefully someone else will be able to help and say if this is possible, meanwhile I will continue looking for ways to do it and let you know if I succeed.