NumericTextBox show % in format when not in edit mode

1 Answer 40 Views
Grid NumericTextBox
Keith
Top achievements
Rank 1
Iron
Iron
Keith asked on 19 Oct 2023, 02:25 PM

We are using a NumericTextBox in a grid for percentage complete field. Users would like to see the % when the field is just in display mode.  The Format property of the NumericTextBox isnt showing the percent sign when it is set to p0.

 


@(Html.Kendo().NumericTextBoxFor(m => m)
    .Format("p0")
    .SelectOnFocus(true)
    .Decimals(0)
    .Min(0)
    .Max(100)
    .Spinners(true)
    .Events(e =>
    {
        e.Change("percentCompleteChange");
    })
}
You may momentarily see it right when you click the cell before it changes to the NumericTextBox editor with spinners.

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 24 Oct 2023, 11:43 AM

Hello Keith,

Thank you for the code snippet and the details provided.

The NumericTexBox is actually the Editor in your EditorTemplate for the numeric field.

In order to show the percentage only when a cell is not in an Edit Mode, I would recommend using a ClientTemplate.

Here is an example:

// In the columns declaration of the Grid:
columns.Bound(p => p.Freight).ClientTemplate("#=Freight#%");
The result:

Give a try to the approach above and let me know if further assistance is needed.

Kind Regards,
Anton Mironov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Tags
Grid NumericTextBox
Asked by
Keith
Top achievements
Rank 1
Iron
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or