Opened 10 years ago

Closed 6 years ago

#9386 closed defect (patchwelcome)

Treegrid: unable to edit child rows in Treegrid

Reported by: OliverM Owned by: Evan
Priority: low Milestone: 2.0
Component: DojoX Grid Version:
Keywords: Cc:
Blocked By: Blocking:

Description

I played around with the Treegrid. It semms that the edit function is not working properly. I've tried that with the latest nightly build.

I did some tests in the test_treegrid.html.

  • when I add editable=true to the columns in "dojox.grid.TreeGrid? 1-Level" test the edit function works like expexted.
  • when I add editable=true to some child columns in the other tests the edit function does not work.

Attachments (2)

editTreeGrid.js (1.9 KB) - added by cdabija 8 years ago.
All fixes in one file. Also allow the column that is expandable to return the value when is edited. And when click on level 1 to edit, the children are not open for edit anymore.
TreeGridEdit.patch (3.5 KB) - added by Anton 7 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 10 years ago by Adam Peller

Owner: changed from Bryan Forbes to Nathan Toone

comment:2 Changed 10 years ago by Nathan Toone

Milestone: 1.4future

comment:3 Changed 9 years ago by Nathan Toone

Owner: Nathan Toone deleted

Unassigning my tickets.

comment:4 Changed 9 years ago by rpgdude

I am having the same issue.

comment:5 Changed 9 years ago by tadams

I encountered the same issue. There are two fixes required to allow the child items to be edited. The first issue is the updateRow method of Grid does not expect the row index to be anything other then a simple number, in the case of treegrid the row identifier is a string of the form rowNumber/childIdx/childIdx/etc. This can be addressed in the TreeGrid?, by overriding the method as follows:

updateRow: function(inRowIndex){
  if (inRowIndex.indexOf){
     var seperator = inRowIndex.indexOf("/");
     if (seperator != -1){
	inRowIndex = inRowIndex.substring(0,seperator);
     }
  }
  arguments[0]=inRowIndex;
  this.inherited(arguments);
}

The second issue is in the dojox\grid\cells\tree.js method formatIndexes: function(inRowIndexes, inItem). This method is not handing when the row index of the selection is an identifer to a child row and thus never makes the call to formatEditing, specifically this code:

if(this.editable && (this.alwaysEditing || (i.rowIndex==inRowIndexes[0] && i.cell==this)))
{
   return this.formatEditing(d, inRowIndexes[0], inRowIndexes);
}

This if statement will always return false in the scenario where a child row is about to be edited. The rowIndex when a child row has been selected is a string, for examlpe "2/1" when the second rows first child is being edited. The inRowIndexes in this scenario is an array of length two containing {2,1}, the comparison of the if statment is comparing "2/1" to 2. This if statement needs to recognize the multipart identifier and identify each subpart to each subpart of the array. This can be done by changing the if statement and the parameter passed to the formatEditing method as follows:

if(this.editable && (this.alwaysEditing || (this.isEditingRow(inRowIndexes) &&  i.cell==this))){
    return this.formatEditing(d, i.rowIndex, inRowIndexes);
}

Where the method isEditingRow is defined as follows:

isEditingRow : function(inRowIndexes){
  var i = this.grid.edit.info;
		
  if (i.rowIndex && i.rowIndex.indexOf){
     var rowEntries = i.rowIndex.split('/');
			
     if (rowEntries.length == inRowIndexes.length){
        for (var i = 0; i < rowEntries.length; i++){
           if (rowEntries[i] != inRowIndexes[i]){
	       return false;
	    }
        }
        return true;
      }
  }
  return i.rowIndex == inRowIndexes[0];
}

I have tested this only against a single nesting of child items, but I believe it would work generically for any depth.

Changed 8 years ago by cdabija

Attachment: editTreeGrid.js added

All fixes in one file. Also allow the column that is expandable to return the value when is edited. And when click on level 1 to edit, the children are not open for edit anymore.

comment:6 Changed 8 years ago by dylan

Milestone: future1.8
Owner: set to Bryan Forbes
Priority: highlow
Status: newassigned

Bryan, please determine if this is still an issue with the DataGrid?.

The patch is pre-AMD... cdabija, do you have a CLA on file?

comment:7 Changed 7 years ago by Colin Snover

Milestone: 1.82.0

1.8 has been tagged; moving all outstanding tickets to next major release milestone.

comment:8 Changed 7 years ago by Anton

Hello all. I attach patch for edit TreeGrid? and you can edit any cell. Better if you will use dojox.grid.cell.dijit Could you please check and commit my patch. If I made ​​a mistake somewhere, I am ready fix that.

Thanks

Changed 7 years ago by Anton

Attachment: TreeGridEdit.patch added

comment:9 Changed 6 years ago by Bryan Forbes

Owner: changed from Bryan Forbes to Evan

comment:10 Changed 6 years ago by bill

DojoX Grid and EnhancedGrid are deprecated in favor of dgrid and gridx.

You should upgrade your code to use one of those two grids.

We will consider patches to the old DojoX Grid code though.

comment:11 Changed 6 years ago by bill

Resolution: patchwelcome
Status: assignedclosed
Note: See TracTickets for help on using tickets.