Opened 12 years ago

Closed 12 years ago

#5030 closed enhancement (fixed)

Implement onNew and onDelete for dojox.grid.data.DojoData

Reported by: jgarfield Owned by: benschell
Priority: high Milestone: 1.1
Component: DojoX Grid Version: 1.0
Keywords: onNew, onDelete, DojoData, dojox.grid.data.DojoData Cc:
Blocked By: Blocking:

Description

The dojox.grid.data.DojoData? does not observe the onNew and onDelete Notifications from the Data Store API. Since users can use an ItemFileWriteStore? and similar data stores that adhere to the API Notifications, we should monitor and reflect this behavior as well.

In the constructor, we currently have...

if(this._canNotify){
   dojo.connect(this.store, "onSet", this, "_storeDatumChange");
}

which could change to...

if(this._canNotify){
   dojo.connect(this.store, "onSet", this, "_storeDatumChange");
   dojo.connect(this.store, "onNew", this, "_storeDatumNew");
   dojo.connect(this.store, "onDelete", this, "_storeDatumDelete");
}

If anyone would like to elaborate on this ticket and go deeper into detail, please do...I have to run to a meeting, but just wanted to get this in here! :)

Attachments (1)

5030.patch (8.3 KB) - added by benschell 12 years ago.
Patch to include these enhancements

Download all attachments as: .zip

Change History (5)

comment:1 in reply to:  description Changed 12 years ago by guest

Replying to jgarfield:
After far too much hacking around and not enough reading... this allows newItem()'s from the store to propagate to the Grid via the model.

Changing:

	_storeDatumChange: function(item, attr, oldVal, newVal){
		// the store has changed some data under us, need to update the display
		var rowId = this._rowIdentities[this.store.getIdentity(item)];
		var row = this.getRow(rowId);
		row[attr] = newVal;
		var colId = this.fields._nameMaps[attr];
		this.notify("DatumChange", [ newVal, rowId, colId ]);
	},
	datumChange: function(value, rowIdx, colIdx){

To:

	_storeDatumChange: function(item, attr, oldVal, newVal){
		// the store has changed some data under us, need to update the display
		var rowId = this._rowIdentities[this.store.getIdentity(item)];
		var row = this.getRow(rowId);
		row[attr] = newVal;
		var colId = this.fields._nameMaps[attr];
		this.notify("DatumChange", [ newVal, rowId, colId ]);
	},
	_storeDatumNew: function(item, attr, oldVal, newVal){
		// the store has a new item added, so we should update ourselves
		// console.debug("_storeDatumNew", arguments);
		this.insert(item, item._0);
	},
	_storeDatumDelete: function(item, attr, oldVal, newVal){
		// the store has removed an item, so we should update ourselves
		// console.debug("_storeDatumDelete", arguments);
		this.remove(item);
	},
	datumChange: function(value, rowIdx, colIdx){

I am *way* over my head at this level of the toolkit... the insert method is working for me right now in a very simple implementation and to be honest, I'm just assuming that the remove method is correct. (That is to say, it's untested.)

One thing I did notice is that rows added via this method redraw oddly when selected for the first time, but I don't know what I'm missing to make it right.

comment:2 Changed 12 years ago by benschell

Owner: changed from sorvell to benschell

Changed 12 years ago by benschell

Attachment: 5030.patch added

Patch to include these enhancements

comment:3 Changed 12 years ago by benschell

Status: newassigned

comment:4 Changed 12 years ago by Jared Jurkiewicz

Resolution: fixed
Status: assignedclosed

This should be resolved under #5724. Marking closed.

Note: See TracTickets for help on using tickets.