MVVM Grid headerTemplate on nested columns breaks the grid when setting columns through setOptions

1 Answer 34 Views
Grid MVVM
Odd Veibust
Top achievements
Rank 1
Odd Veibust asked on 23 Aug 2023, 01:09 PM | edited on 23 Aug 2023, 01:11 PM

Hi,

We're using a custom binding to set columns from the view model, but we're experiencing some trouble using nested columns and headerTemplate.

I set up a dojo example where you can see the problem. It will occur if you uncomment the headerAttributes that's commented out.

Anyone have any idea how to get this to work properly?

Dojo example: https://dojo.telerik.com/ApIGimiv/2

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 28 Aug 2023, 08:18 AM

Hi, Odd,

Thank you for the provided Dojo.

You can transform the 'Columns' binding into a function that returns the array of items. This way the columns array won't be affected by the default binding mechanisms(which are to turn every object into an ObservableObject).

    Columns: function() {
      return [
        {
          title: 'Account',
          headerAttributes: { class: 'sales-header' },
          columns: [
            { field: 'AccountNumber', title: 'Account number', headerTemplate: 'No', width: 70 },
            { field: 'AccountItems', title: 'Account items', headerTemplate: 'Pcs', width: 70 },
          ]
        },
      ]
    }

Dojo

https://dojo.telerik.com/@gdenchev/AJafuder 

Best Regards,
Georgi Denchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Grid MVVM
Asked by
Odd Veibust
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or