| 481 | | var row = {}; |
| 482 | | row.__dojo_data_item = item; |
| 483 | | dojo.forEach(this.fields.values, function(a){ |
| 484 | | value = this.store.getValue(item, a.name); |
| 485 | | row[a.name] = (value === undefined || value === null)?"":value; |
| 486 | | }, this); |
| 487 | | |
| 488 | | // FIXME: where else do we need to keep this in sync? |
| 489 | | //Handle stores that implement identity and try to handle those that do not. |
| 490 | | if (this._canIdentify) { |
| 491 | | this._rowIdentities[this.store.getIdentity(item)] = {rowId: request.start+idx}; |
| 492 | | }else{ |
| 493 | | var identity = dojo.toJson(request.query) + ":start:" + request.start + ":idx:" + idx + ":sort:" + dojo.toJson(request.sort); |
| 494 | | this._rowIdentities[identity] = {rowId: request.start+idx, item: item}; |
| 495 | | } |
| | 496 | var row = this._createRow(item); |
| | 497 | this._setRowId(item, request.start, idx); |
| 571 | | _storeDatumChange: function(item, attr, oldVal, newVal){ |
| 572 | | // the store has changed some data under us, need to update the display |
| | 573 | _setRowId: function(item, offset, idx){ |
| | 574 | // FIXME: where else do we need to keep this in sync? |
| | 575 | //Handle stores that implement identity and try to handle those that do not. |
| | 576 | if (this._canIdentify) { |
| | 577 | this._rowIdentities[this.store.getIdentity(item)] = {rowId: offset+idx, item: item}; |
| | 578 | }else{ |
| | 579 | var identity = dojo.toJson(this.query) + ":start:" + offset + ":idx:" + idx + ":sort:" + dojo.toJson(this.sortFields); |
| | 580 | this._rowIdentities[identity] = {rowId: offset+idx, item: item}; |
| | 581 | } |
| | 582 | }, |
| | 583 | _getRowId: function(item, isNotItem){ |
| | 584 | // summary: |
| | 585 | // Function determine the row index for a particular item |
| | 586 | // item: |
| | 587 | // The store item to examine to determine row index. |
| | 588 | // isNotItem: |
| | 589 | // Boolean flag to indicate if the item passed is a store item or not. |
| | 617 | }, |
| | 618 | _storeDatumDelete: function(item){ |
| | 619 | if(dojo.indexOf(this._currentlyProcessing, item) != -1) |
| | 620 | return; |
| | 621 | // the store has deleted some item under us, need to remove that item from |
| | 622 | // the view if possible. It may be the deleted item isn't even in the grid. |
| | 623 | var rowId = this._getRowId(item, true); |
| | 624 | if(rowId != null){ |
| | 625 | this._removeItems([rowId]); |
| | 626 | } |
| | 627 | }, |
| | 628 | _storeDatumNew: function(item){ |
| | 629 | if(this._disableNew) |
| | 630 | return; |
| | 631 | // the store has added some item under us, need to add it to the view. |
| | 632 | this._insertItem(item, this.data.length); |
| | 633 | }, |
| | 634 | insert: function(item, index){ |
| | 635 | // Push the given item back to the store |
| | 636 | this._disableNew = true; |
| | 637 | var i = this.store.newItem(item); |
| | 638 | this._disableNew = false; |
| | 639 | this._insertItem(i, index); |
| | 640 | }, |
| | 641 | _insertItem: function(storeItem, index){ |
| | 642 | var row = this._createRow(storeItem); |
| | 643 | this._setRowId(storeItem, 0, index); |
| | 644 | dojox.grid.data.Dynamic.prototype.insert.apply(this, [row, index]); |
| | 670 | remove: function(inRowIndexes){ |
| | 671 | // summary: |
| | 672 | // Function to remove a set of items from the store based on the row index. |
| | 673 | // inRowIndexes: |
| | 674 | // An array of row indexes from the grid to remove from the store. |
| | 675 | /* Call delete on the store */ |
| | 676 | for(var i=inRowIndexes.length-1; i>=0; i--){ |
| | 677 | // Need to find the item, then remove each from the data store |
| | 678 | var item = this.data[inRowIndexes[i]].__dojo_data_item; |
| | 679 | this._currentlyProcessing.push(item); |
| | 680 | this.store.deleteItem(item); |
| | 681 | } |
| | 682 | /* Remove from internal data structure and the view */ |
| | 683 | this._removeItems(arguments); |
| | 684 | this._currentlyProcessing = []; |
| | 685 | }, |
| | 686 | _removeItems: function(inRowIndexes /*array*/){ |
| | 687 | // summary: |
| | 688 | // Function to remove a set of items from the store based on the row index. |
| | 689 | // inRowIndexes: |
| | 690 | // An array of row indexes from the grid to remove from the store. |
| | 691 | dojox.grid.data.Dynamic.prototype.remove.apply(this, arguments); |
| | 692 | // Rebuild _rowIdentities |
| | 693 | this._rowIdentities = {}; |
| | 694 | for (var i = 0; i < this.data.length; i++){ |
| | 695 | this._setRowId(this.data[i].__dojo_data_item, 0, i); |
| | 696 | } |
| | 697 | }, |