Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6853 closed defect (fixed)

The removeSelectedRows method seems to be broken

Reported by: guest Owned by: Bryan Forbes
Priority: high Milestone: 1.2
Component: DojoX Grid Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:

Description

This method of _grid.js seems to be broken and do not do what is expected. The last item in store is removed from grid insted of selection.

	removeSelectedRows: function(){
			// summary:
			//		Remove the selected rows from the grid.
			this.updateRowCount(Math.max(0, this.rowCount - this.selection.getSelected().length));
			this.selection.clear();
		}

Compare insted the code in Nightly Build 28/05/2008

	removeSelectedRows: function(){
		this.edit.apply();
		var s = this.selection.getSelected();
		if(s.length){
			this.model.remove(s);
			this.selection.clear();
		}
	},

The items are not removed from store

thanks

Eduardo

Attachments (1)

test_data_grid_empty.html (2.1 KB) - added by guest 11 years ago.
See replication instructions, please

Download all attachments as: .zip

Change History (9)

Changed 11 years ago by guest

Attachment: test_data_grid_empty.html added

See replication instructions, please

comment:1 Changed 11 years ago by guest

Replication instructions.

[1] Add four, five nodes. [2] Select any item except last. [2] Choose remove selected button

Result: Last will be deleted insted item you chose.

Note: In my real application I saw sometimes, a slight different behavior if several alternatively nodes are chosen (example item1,item3, item5 tigether in one selection) . I think that probably there is an additional bug there, but I cannot be sure of that.

thanks !!

Eduardo

comment:2 Changed 11 years ago by guest

The current removeSelectedRows function do:

[1] Update the number of rows

[2] Clear selection

No removing of rows (if I do not missed something).

Ps: the selected list may be not a continuous list, ex: rows 1,4,7 and 10

thanks !

Eduardo

comment:3 Changed 11 years ago by Bryan Forbes

Resolution: fixed
Status: newclosed

(In [13997]) fixes #6853 !strict

  • Overrode removeSelectedRows in DataGrid? to correctly remove the rows if it's an editable grid.
  • Added custom avatar.

comment:4 Changed 11 years ago by guest

Resolution: fixed
Status: closedreopened

Hi Bryan

I reopen this PR, because something is not working. May be the problem is not in the dataGrid. My program falls inside the removeSelected when you call the dojo.forEach(items, this.store.deleteItem) line.

I have two grids: gridAssigned and gridUsers when and I transfers selected rows from gridAssigned to gridUsers. In gridUsers I recreate a equivalent line and in gridAssigned I remove each line.

See please the code above , the first work, the second falls, I used a code very similar to your removeSelected.

[1]

   var selRows =  new Array();
    selRows=gridAssigned.selection.getSelected();
    noassigned=selRows.length;

    if(noassigned < 1){
      return;
    }
    for(i=0;i<noassigned;i++){
        name = selRows[i].unam;
        grid = selRows[i].grid;
        id   ="\'"+selRows[i].id+"\'";
        modelUsers.newItem({id:id,unam:name,grid:grid}); 
    }

    /*gridAssigned.removeSelectedRows();**

    gridAssigned.edit.apply();
    for (i=0;i<noassigned;i++){
        gridAssigned.store.deleteItem(selRows[i]);
    }

    
    noassigned=0;
    gridAssigned.selection.clear();
    gridAssigned.render();
    gridUsers.setSortIndex(0,true);

[2]

   var selRows =  new Array();
    selRows=gridAssigned.selection.getSelected();
    noassigned=selRows.length;

    if(noassigned < 1){
      return;
    }
    for(i=0;i<noassigned;i++){
        name = selRows[i].unam;
        grid = selRows[i].grid;
        id   ="\'"+selRows[i].id+"\'";
        modelUsers.newItem({id:id,unam:name,grid:grid}); 
    }

    gridAssigned.edit.apply();
    gridAssigned.removeSelectedRows();   <---- Falls here
    
    noassigned=0;
    gridAssigned.selection.clear();
    gridAssigned.render();
    gridUsers.setSortIndex(0,true);

The error message I received in my FF2 error console is:

this._assert is not a function Line 219 in dojo.js

comment:5 Changed 11 years ago by Bryan Forbes

Owner: changed from sorvell to Bryan Forbes
Status: reopenednew

comment:6 Changed 11 years ago by Bryan Forbes

Resolution: fixed
Status: newclosed

(In [14087]) fixes #6853 !strict

  • Changed internal structures of DataGrid? to make indexing more accurate and fix removeSelectedRows.

comment:7 Changed 11 years ago by guest

Thanks Bryan !!

Eduardo

comment:8 Changed 11 years ago by bill

Milestone: 1.2

marking tickets closed in the last three months w/blank milestone to milestone 1.2.

Note: See TracTickets for help on using tickets.