Set header text with knockout binding

Posted by: h.otte on 22 January 2019, 10:05 am EST

    • Post Options:
    • Link

    Posted 22 January 2019, 10:05 am EST

    Hi,

    is it possible to use knockout databind to set the headertext of a flexgrid column?

    Example:

    normally, I would define my columns like this:

    <div style="height: 30px; width: 40px;" data-bind="wjFlexGridColumn: { header: 'Country', binding: 'country', width: '90', isReadOnly: false }">
    

    where country is of course a property of the itemsSource and Country would be the headertext in verbatim.

    Now, I have a variable ‘selectAll’ which I set via knockout. How would I set the headertext, so that it shows 'selectAll’s value?

  • Posted 23 January 2019, 4:31 am EST

    Hi,

    You may directly assign a variable value like:

    <div data-bind ="wjFlexGridColumn: { header: someVariable, binding: 'country'}"></div>
    

    However, if you would the header to be updated automatically when the variable is assigned a new value, then you need to use knockout observables instead of normal variables.

    Please refer to the following sample which demonstrates the same:

    https://codepen.io/anon/pen/jdEYVB?editors=1010

    ~Sharad

  • Posted 28 January 2019, 3:01 am EST

    Thank you, now it works - it was a combination of not getting the right variable name and not writing the parentheses.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels