# Formatting ProgressBar Value

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC ProgressBar</td>
 </tr>
 <tr>
  <td>Progress Telerik UI for ASP.NET MVC version</td>
  <td>Created with the 2024.2.514 version</td>
 </tr>
</table>

## Description

How can I format the current value of the ProgressBar that is displayed into a Grid column?

By design, the underlying value of the ProgressBar must be a number. In some cases, the value must be formatted. For example, when the number groups must be comma-separated to match the current culture.

## Solution

Follow the steps below to initialize a ProgressBar into a specified Grid column and format its value based on the French (`fr-FR`) culture:

1. Add the ProgressBar element through the `ClientTemplate()` option of the Grid's column.

```Razor HtmlHelper
  columns.Bound(p => p.Freight).ClientTemplate("<div class='progress'></div>");
```

1. Handle the `DataBound` event of the Grid, select the `div` elements with class `progress` and initialize the ProgressBar component in each column cell.

```Razor HtmlHelper
  @(Html.Kendo().Grid<OrderViewModel>()
    .Name("grid")
    .Events(ev => ev.DataBound("onDataBound"))
    ...// Other configuration.
  )
```

```JS scripts
  <script>
    function onDataBound(e) {
      var grid = this;
      grid.tbody.find(".progress").each(function (e) {
          var row = $(this).closest("tr");
          var model = grid.dataItem(row);
          $(this).kendoProgressBar({
              max: model.Freight,
              value: model.Freight
          })
      });
    }
  </script>
```

1. Within the `DataBound` event handler, select the `k-progressbar` elements, and access the respective ProgressBar value through the `k-progressbar-status` element. Use the [`kendo.parseFloat()`](https://docs.telerik.com/kendo-ui/api/kendo/methods/parsefloat) and [`kendo.toString()`](https://docs.telerik.com/kendo-ui/api/kendo/methods/tostring) methods to format the value and update it with jQuery.

```JS scripts
  <script>
    function onDataBound(e) {
      var grid = this;
      grid.tbody.find(".progress").each(function (e) {
          ... 
      });

      $.each($(".k-progressbar"), function(){
        let currentValue = $(this).find(".k-progress-status").text();
        $(this).find(".k-progress-status").text(kendo.toString(kendo.parseFloat(currentValue), 'n2', 'fr-FR'));
      });
    }
  </script>
```

For a runnable example based on the code above, refer to the [REPL example on formatting the value of ProgressBar displayed into a Grid column](https://netcorerepl.telerik.com/GykLQIlH233FLp0u38).

## More ASP.NET MVC ProgressBar Resources

* [ASP.NET MVC ProgressBar Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/interactivity/progressbar/overview)

* [ASP.NET MVC ProgressBar Demos](https://demos.telerik.com/aspnet-mvc/progressbar)

* [ASP.NET MVC ProgressBar Product Page](https://www.telerik.com/aspnet-mvc/progressbar)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the ProgressBar for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/progressbar)

* [Server-Side API Reference of the ProgressBar for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/progressbar)

* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)

* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
