JSON DataSource adds dropdown for children even if 0 items

4 posts, 0 answers
  1. Peter
    Peter avatar
    44 posts
    Member since:
    Jan 2014

    Posted 01 Apr 2014 Link to this post

    When setting the PanelBar dataSource property, it adds a dropdown (ie a HasChildren indicator) even if there are no items in the array.
    Would this be a reasonable change request to make - to not do this?

    Basically if you do this
     items: [
                                {
                                    text: "Sub Sub Item 1",
                                    value: "Sub Sub Item 1 Value",
                                    items: []
                                },

    You can test this by modifying the code as above on this fiddler.
    http://jsfiddle.net/bundyo/WM4VG/light/

    This is quite a pain, in my case, as I'm populating the dataSource from a C# DTO object. I have "items" as a property and cannot easily just "remove" it. Nor should I need to, in my opinion.
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 03 Apr 2014 Link to this post

    Hello Peter,

    Thank you for contacting us.

    Changing this functionality will be considered a breaking change, as a lof of the Kendo UI users, are relaying to this functionality of the PanelBar control, so changing this default behavior will create a lot of inconvenience for other users.

    I would suggest you to check our uservoice section and post your suggestion there, so other people from the community can vote for it, and if it gets popular we will see it implemented in the future.

    A workaround would be to manually walk through the PanelBar with jQuery and detect if you have not child items, then you can hide the node.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Peter
    Peter avatar
    44 posts
    Member since:
    Jan 2014

    Posted 03 Apr 2014 in reply to Kiril Nikolov Link to this post

    Right.

    I must admit, my mind boggles why it would be implemented like this in the first place - it would never occur to me to rely on the "presence" of an array and ignore that the array is empty. 

    It may be a breaking change to fix it, but it should never had been designed that way, in my opinion.

    If anyone else is reading this... here's my coffeescript to work around it - pass your datasource array into this method before giving to PamelBar.

    removeEmptyItems = (array) ->
    _(array).each (d) ->
    delete d.items if d.items?.length is 0
    removeEmptyItems d.items
    return array
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 04 Apr 2014 Link to this post

    Hello Peter,

    Thank you very much for your input and provided workaround. 

    We will keep in mind your suggestion for future implementations.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready