This is a migrated thread and some comments may be shown as answers.

[Solved] .Format

3 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Austin Oberholtzer
Top achievements
Rank 1
Austin Oberholtzer asked on 13 Jan 2010, 10:33 AM
I am having trouble using the format attribute for multiple cultural currencies. Does anyone have any suggestions?

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jan 2010, 03:05 PM
Hi Austin Oberholtzer,

Could you please provide more details? You could paste some source code and tell us what you are trying to achieve.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Austin Oberholtzer
Top achievements
Rank 1
answered on 15 Jan 2010, 08:46 AM
Here is the block of code displaying the model.

The OrderTotal is what I am working with, I need to take that value and then convert it Swedish krona which is typically done by formatting a decimal with  System.Globalization.CultureInfo.

<% Html.Telerik().Grid<OrderGrid>(Model) 
        .Name("Order") 
        .Columns(columns => 
        { 
            columns.Add(o => o.OrderId).Title("Order"); 
            columns.Add(o => o.UserId).Title("Customer"); 
            columns.Add(o => o.ProductName).Title("Product"); 
            columns.Add(o => o.OrderedDate).Format("{0:yyyy-MM-dd}").Title("Ordered"); 
            columns.Add(o => o.DesiredDate).Format("{0:yyyy-MM-dd}").Title("Desired"); 
            columns.Add(o => o.EstimatedDate).Format("{0:yyyy-MM-dd}").Title("Estimated"); 
            columns.Add(o => o.ActualDate).Format("{0:yyyy-MM-dd}").Title("Actual"); 
            columns.Add(o => o.OrderStatus).Title("Status"); 
            columns.Add(o => o.DeliveryStatus).Title("Delivery"); 
            columns.Add(o => o.Quantity); 
            columns.Add(o => o.OrderTotal).Format("{0:C}").Title("Total"); 
            columns.Add(o => 
            {%><a href="/Orders/Details/<%= o.Id%>"><img src="/Content/Images/view.gif" border="0" /></a><%}).Title(" "); 
        }) 
        .CellAction(cell => 
        { 
            if (cell.DataItem.New == true) 
            { 
                cell.HtmlAttributes["Style"] = "background-color: #fef1e9;"; 
 
                if (cell.Column.Title == "Order" || cell.Column.Title == "Product") 
                    cell.HtmlAttributes["style"] = "background-color: #fef1e9; font-weight: bold"; 
                if (cell.Column.Title == " ") 
                    cell.HtmlAttributes["Style"] = "background-color: #fef1e9; border-right: 0px;"; 
                if (cell.Column.Title == "Total") 
                    cell.HtmlAttributes["Style"] = "background-color: #fef1e9; text-align: right;"; 
            } 
            else 
            { 
                if (cell.Column.Title == "Order" || cell.Column.Title == "Product") 
                    cell.HtmlAttributes["style"] = "font-weight: bold"; 
                if (cell.Column.Title == " ") 
                    cell.HtmlAttributes["Style"] = "border-right: 0px;"; 
                if (cell.Column.Title == "Total") 
                    cell.HtmlAttributes["Style"] = "text-align:right;"; 
            } 
        }) 
        .Pageable() 
        .Sortable() 
        .Render(); %> 
    <% } %> 

0
Atanas Korchev
Telerik team
answered on 15 Jan 2010, 09:53 AM
Hi Austin Oberholtzer,

Unfortunately there is a bug with culture specific formatting - we are not using CurrentCulture but CurrentUICulture at the moment. I have fixed this bug. To apply the fix please open
"Source\Telerik.Web.Mvc\Infrastructure\Culture.cs" and replace this:
public static CultureInfo Current
{
    [DebuggerStepThrough]
    get
    {
        return CultureInfo.CurrentUICulture;
    }
}

with this:
public static CultureInfo Current
{
    [DebuggerStepThrough]
    get
    {
        return CultureInfo.CurrentCulture;
    }
}

Also make sure you have set the Culture of your View to Swedish.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Austin Oberholtzer
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Austin Oberholtzer
Top achievements
Rank 1
Share this question
or