Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Possible bug & proposed fix

    Hi,

    I'm playing with v11.0p_2016-07-17/LGPL Deployment and have found a possible problem with menus.

    I have a datasource that returns tree data as a child array and I want to bind this data to a MenuButton but had a problem - sub-menus were not appearing.

    Upon closer inspection I see some code has been recently updated in Menu.initWidget:
    Code:
    if (this.dataSource != null && !this.hasFlatDataSource()) {
    and Menu.hasFlatDataSource is defined as:
    Code:
    hasFlatDataSource : function () {
        var ds = isc.DataSource.get(this.dataSource);
        var names = ds.getFieldNames();
        var hasPK = false, hasFK = false;
        for (var i=0; i < names.length; i++) {
            var fld = ds.getField(names[i]);
            if (fld.primaryKey) hasPK = true;
            if (fld.foreignKey) hasFK = true;
        }
        return !(hasPK && hasFK);
    }
    Which means that unless there is a parent-linked relationship then a tree never gets created.

    I think the correct behaviour would be to also consider the following condition in hasFlatDataSource:

    Code:
    ds.childrenField != null || dataProperties.modelType == "children"
    For now, to fix my use case I've just overriden hasFlatDataSource() in my sub-class to return false and the menu is working.
    Last edited by jaredm; 23 Jul 2016, 15:17.

    #2
    Your proposed fix is correct, so it has been applied to the affected branches. Please try the next nightly build, dated July 26.

    Thanks.

    Regards
    Isomorphic Software

    Comment

    Working...
    X