iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
We have a few grids that require the user see the currency figures for a specific currency format which may not be the same as the grid's culture. For example, the user may have the grid culture set to en-US but wants to see the currency formatted in Euros via en-IE for Ireland or maybe formatted for pt-BR. The reason we can't set the entire grid culture is we don't want to affect any other columns like dates or other numbers that need to stay formatted for the en-US culture.
I can't find a way to do this right now so I need some help in doing this please. I've tried overriding the InitializeCell but this is not working. The grid overrides my format when it renders.
Here's my OnInitializeCell override.
public override bool OnInitializeCell(WebGridCell cell) { bool bRet = base.OnInitializeCell(cell); if (cell.Column.ColumnType != ColumnType.Text) { return bRet; } DataRow[] drFilteredRows = m_dtColumns.Select( "columnName = \'" + cell.Column.Name + "\'"); if (drFilteredRows != null && drFilteredRows.Length > 0) { DataRow dr = drFilteredRows[0]; if (!string.IsNullOrEmpty(cell.Column.DataFormatString) && cell.Column.DataFormatString.StartsWith("C")) { if (!string.IsNullOrEmpty(cell.Text)) { cell.Text = ((decimal)cell.Value).ToString( cell.Column.DataFormatString,new CultureInfo("pt-BR")); } } } return bRet; }
The above is hard-coded to format using the Brazillian Real as an override but after rendering, it shows up in the US dollar format.
So 123456789.53 should show up as "R$ 123.456.789,53" and not "$123,456,789.53" as it does now. So how do I accomplish this please? Thanks.
I wanted to also request a feature that allows setting the culture at the row, column and/or cell levels. If this was available, it would have accomplished what we need to do.
Those would all derive from the LayoutSettings.Culture setting initially and then can be overriden by the developer later if need be.
Hello,
I have discussed with the developer team about the culture settings. Unfortunately, you cannot have multi cultures in a single WebGrid instance. WebGrid takes account only one culture per instance. Therefore, different WebGrid can have different culture.
However, you are still able to format the column using custom format string. In WebGrid, we provide DataFormatString property in each column. You can customize this property according to your needs.
Thank you.
Hi,
Yes, we use DataFormatString but it only formats according to the assigned culture, so if you set it to "C2" for currency, for example, it'll get formatted according to the layout culture assigned.
We need to have the ability to assign a culture at the row, column and/or cell level or at least an override format. Would you please add this as a request for a future enhancement? This is a big one for us so we can use this feature sooner than later please.
In the meanwhile, do you guys have some ideas on how to achieve what we need?
Martin,
I tried setting the DataFormatString to the Brazilian Real, i.e., R$ ###.###.##0,00 and it did not format correctly (see attached). A number like 123456.5565, should format to R$ 123.456,56. Also, the negative numbers should be in parans.
[EDIT] Never mind on the negative number as that was a format issue on our part, i.e., we just needed to update the format string to R$ ###.###.##0,00;(R$ ###.###.##0,00)
Try to use the following custom format string in WebGrid:
<ISWebGrid:WebGridColumn Caption="Freight" DataMember="Freight" DataType="System.Decimal" Name="Freight" Width="100px" DataFormatString="R$ #,##0.00">
When you put 123456.5565, it will render as R$ 123,456.56.
Hope this helps.
Yes, I tried that already per my post and it does not work. The culture assigned to the grid still overrides this. Look at the result of your example. It's not formatted correctly. Did you actually read my post closely?
We still need the option to set the culture specifically on a column, row and/or cell. Our system will be used worldwide and someone in the US would be using it in English where a colleague in the Netherlands may be using Dutch and another colleague in France using Francais. But in all cases, some grids will need to display specific currency columns based not on the home language, but the base currency. So just because the user in the Netherlands (nl-NL) is using our product in Dutch, their base currency may still be set in US Dollars. So it's very important that we have the ability to format, correctly, the value based on a different culture, at the column/row/cell level, than the global grid layout setting.
This is critical to us so please pass this on to development to see the feasibility of getting this in as a feature and how quick it can be done. Also, would you please find out if there's a way we can override the grid formatting? Is there an override I'm missing other than OnInitializeCell? Thanks.
I apologize for the misunderstanding of your issue.
I have discussed with the developer team regarding this issue. Currently, it is probably a limitation from WebGrid to perform different culture in the same instance. As you said, WebGrid can only apply 1 culture and you are not able to override the culture even using InitializeCell Server-side event.
I will create a Feature Request and submit it to the developer team, so that they can enhance WebGrid further.
Thanks Martin. I found a partial workaround for now by using a template column which uses a label that's assigned the text we need formatted how we need it.
This still presents several issues that you might forward to your development team:
Right now, we're having to drop the Export feature altogether as it's not usable with how we're implementing the grid. We really need to have the export work alongside the grid once the culture setting is added at the row/column/cell level please.
This is creating a lot more work for us as we now have to write our own export routines. Thanks.
Hello A Yousif,
I will forward and inform the development team on your issues. However, could you provide me a simple working sample that replicates the issue that you mentioned?
If you can zip and attach the sample, it would be easier for me to directly forward the sample to the development team to be investigated further.
I really don't have the time to create the sample, but you can create it as it's very simple per the info I've provided. Just create a grid and set it's culture to say ru-RU (Russian). Create one of your columns as a template that holds a label and then format that column's value, during the data binding, using the another culture like en-US. Once displayed, use the export and you'll see your template column formatted in the ru-RU culture. For our case we use currency, so don't forget to set your data type to "System.Decimal" if you're going to also use currency.
I have forwarded your issue to the development team.
However, about the exporting templated column issue, exporting only accepts native column type because it generally renders only textual content, while template column can contain graphics or more complex controls.
Thanks Martin. Sorry I didn't have time to provide a sample. The end of the year is crunch time and I'm buried right now. If you couldn't duplicate this based on my description, let me know after the new year starts and I should have time to put a sample for you.
I have forwarded your scenario to the development team to be investigated further.
You can provide me a sample based on your scenario after the new year. It would be easier for us to investigate the issue.
Meanwhile, I will let the development team to work on your issue.
Sorry I never got around to providing the sample regarding the template column, but at this point, we still need the feature to format at the row and cell level as mentioned above using different cultures. Has this been added to 2011 R1? The export won't be an issue once this feature is added since the values will be native values and not templated objects. Thanks.
The developer team has given me the update of this issue.
This Feature Request has been noted by the team and will be added in the next release, which means that this culture setting will be applied in the 2011 R2.
Regards,-Martin-
Great news. Thank you.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname