jQuery UI Widgets Forums Grid custom cell renderer with knockout bindings

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 9 years, 10 months ago.

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

  • Réka
    Participant

    Hello!

    I would like to have some knockout bindings on the custom html I return in the cellsrenderer function. Is there a way to do this?

    This is my code:

      var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {
                        return '<ul><!-- ko if: visible() --> <li style="float:left; margin-right: 30px; padding-top: 5px;">Item 1</li>  <!-- /ko --> <li         style="float:left; padding-top: 5px;">Item 2</li></ul>';
                    }

    The ko.applayBindings method should be called again after the cell is rendered, but I did not find such an event.

    Thank you,
    Réka


    Peter Stoev
    Keymaster

    Hi Reka,

    The cellsrenderer expects HTML String as result so I do not think it is possible to add custom bindings there.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Réka
    Participant

    Hi Peter!

    Thank you for your answer. The way it is written can be changed to:

    <ul id="test" data-bind="visible: visible"><li style="float:left; margin-right: 30px; padding-top: 5px;">Item 1</li><li style="float:left; padding-top: 5px;">Item 2</li></ul>

    so here is only html without knockout tags. All I need to do more is to apply the binding. Is there an event that is triggered after cell rendering is complete?

    Thank you,
    Réka


    Peter Stoev
    Keymaster

    Hi Reka,

    Nope. There’s no such event. Also note that cellsrenderer is called each time a cell needs to be re-rendered i.e while you scroll, change page, sort, filter, edit. If you apply code like “applybindings” – this will definitely affect the performance.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.