Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleQuery + Tree: Added rows under expanded parents do not render with the correct indentation #1275

Closed
kfranqueiro opened this issue Apr 26, 2016 · 3 comments
Labels
Milestone

Comments

@kfranqueiro
Copy link
Member

kfranqueiro commented Apr 26, 2016

Steps to reproduce with code below:

  1. Expand item 1 (which will also select it since you clicked it)
  2. Click Add button
  3. Notice that child ends up rendered with no indentation (level 0)

This happens regardless of how many children you add. If you select 1, don't expand, and add a child, when you expand the child will be rendered at the correct indentation, but any subsequent items added under item 1 after it's expanded will have the same problem.

<button id="add" type="button">Add child to selected item</button>
<div id="grid"></div>
require([
    'dojo/_base/declare',
    'dgrid/Grid',
    'dgrid/demos/laboratory/grid/SingleQuery',
    'dgrid/Selection',
    'dgrid/Tree',
    'dgrid/test/data/createHierarchicalStore'
], function (declare, Grid, SingleQuery, Selection, Tree, createStore) {
    var store = createStore({ data: [] });
    var grid = new (declare([ Grid, SingleQuery, Selection, Tree ]))({
        columns: {
            id: {
                renderExpando: true,
                label: 'ID'
            }
        },
        collection: store.getRootCollection(),
        selectionMode: 'single'
    }, 'grid');

    var nextId = 0;
    store.addSync({
        id: ++nextId,
        hasChildren: true
    });

    document.getElementById('add').onclick = function () {
        var selected = +Object.keys(grid.selection)[0];
        if (!selected) {
            return;
        }

        store.addSync({
            id: ++nextId,
            hasChildren: true,
            parent: selected
        });
    };
});
@kfranqueiro kfranqueiro added this to the 1.0.1 milestone Apr 26, 2016
@kfranqueiro kfranqueiro self-assigned this Apr 26, 2016
@kfranqueiro
Copy link
Member Author

I have a fix for this, and I verified that I can cleanly rebase the branch for #1260 on it and it still works. Probably going to go ahead and work on bringing in SingleQuery and adding a few tests pursuant to #1271 then merge this with that.

@kfranqueiro
Copy link
Member Author

I need to re-approach this fix. My original attempt moves all computation of indentation level to insertRow, which is problematic for subsequent refreshCell calls.

@kfranqueiro
Copy link
Member Author

I've fixed the fix (yo dawg) and added another test for the second issue. I've also confirmed that my branch now resolves the issue as I originally discovered it in my application.

I'm going to look at #1277, then probably merge both at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant