jQWidgets Forums

jQuery UI Widgets Forums Grid Display of % character in grid using 'p' cellsformat

This topic contains 2 replies, has 2 voices, and was last updated by  Mr.Moo 9 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • Mr.Moo
    Participant

    I have a ko.computed() value that calculates a percentage returning the value using .toFixed(2) when the grid is first rendered it correctly displays as 0% in the grid’s column. However, when the values affecting the calculation are changed and the value is re-displayed it loses its % identifier in the column e.g. 7.59 is this behaviour correct?

    If not, then how do I retain the % symbol in the column’s output short of writing a custom renderer.


    Moo


    Peter Stoev
    Keymaster

    Hi Mr.Moo,

    The cellsformat property of a column defines how a cell value is displayed in the column. You will not lose the character when the column values are Numbers so check whether your custom code puts numbers there, not Strings or some Objects.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Mr.Moo
    Participant

    Hi Peter,

    Thanks for pointing me in the right direction.

    Looking at the documentation I note that .toFixed() returns a string so explains why the % symbol was being lost. So to fix it I prepended my return statement with a +. i.e. return +(MyPercentCalc).toFixed(2)

    Moo

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.