Opened 10 years ago

Closed 8 years ago

#10438 closed defect (patchwelcome)

DataGrid large selection doesn't work

Reported by: andre steenveld Owned by: Evan
Priority: high Milestone: 1.8
Component: DojoX Grid Version: 1.4.0b
Keywords: datagrid selection Cc: brianforbes, Nathan Toone
Blocked By: Blocking:

Description

When selecting items programmaticly in a grid via grid.selection.addToSelection() only the items that are rendered will be selected.

In this supplied test case there is a dataset of about ~800 records, all items are selected when the store is attached to the grid. Yet the resulting selection is only 25 records. I am working on a patch.

Demo: http://bonsai.nmpo.nl/experiments/selected.html

Attachments (1)

RangeSelection.patch (2.7 KB) - added by andre steenveld 10 years ago.

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by andre steenveld

Attachment: RangeSelection.patch added

comment:1 Changed 10 years ago by andre steenveld

The patch adds a method to dojox.data.DataSelection? called selectRange( start, count ). It will force the grid to get the items in the range, index them and add them to the selection. It seems like a slightly hackish solution but it works. I will add another demo tomorrow which will demonstrate the fix.

comment:2 in reply to:  1 Changed 10 years ago by fphan

Replying to andre steenveld:

The patch adds a method to dojox.data.DataSelection? called selectRange( start, count ). It will force the grid to get the items in the range, index them and add them to the selection. It seems like a slightly hackish solution but it works. I will add another demo tomorrow which will demonstrate the fix.

The fix is not working in 1.4.2. I am still seeing the same problem described above with addToSelection().

  function test() {
    var gridObj = dijit.byId(dataGrid);
    gridObj.selection.selectRange(0, 171); // My grid displays 23 lines and buffer/rowsPerPage holds 50.

    var obj = gridObj.selection.getSelected();

    if (obj.constructor == Array) {
        alert('getSelected returned array with length ' + obj.length) ;
        alert(obj[0]);
    } else {
        alert('not array');
    }

    for (i = 0; i < obj.length; i++) {
        if (!store1.isItem(obj[i])) {
            alert('NOT an item starting at index: ' + i);
            break; // This breaks for me (the first round) at i = 50.
        }
        if (i == 171 && store1.isItem(obj[i])) {
            alert('object ' + i + ' email: ' + gridObj.store.getValue(obj[i], 'Email'));
        }
    }
    alert('finished');
}

comment:3 Changed 10 years ago by John Christopher

I have the same problem when manually selecting (using click + shift-click) all rows. I believe that only the rows that are in the cache (QueryReadStore?) are actually returned, the rest are null items.

comment:4 Changed 9 years ago by Nathan Toone

Owner: Nathan Toone deleted

Unassigning my tickets.

comment:5 Changed 8 years ago by evan

Cc: brianforbes Nathan Toone added; brianforbes toonetown removed
Milestone: tbd1.7
Owner: set to evan

comment:6 Changed 8 years ago by evan

Owner: changed from evan to Evan

comment:7 Changed 8 years ago by Evan

Milestone: 1.7future

comment:8 Changed 8 years ago by Evan

Milestone: future1.8
Resolution: patchwelcome
Status: newclosed

It's a long known issue of grid.getSelected() which will only return items currently rendered, though actually a wide range rows are already selected.

The unexpected behavior is grid.getSelected() will trigger fetching more selected items in an asynchronous way so if we check grid.getSelected() with a timeout later, then we may get all the selected rows, but the problem is 'when' to check that.

Based on the existing logic, don't think there is any easy fix without significant changes, so closing as 'patchwelcome'

Note: See TracTickets for help on using tickets.