Ui-grid

来自ling
跳转至: 导航搜索
  • $scope.gridOptionsgetDirtyRows(): returns an array of gridRows of all currently dirty rows
  • $scope.gridOptionsgetErrorRows(): returns an array of gridRows of all currently errored rows
  • $scope.gridOptionsflushDirtyRows(): flushes all currently dirty rows to the server, might be used on a page navigation request or pressing of a save button
  • $scope.gridOptionssaveRow( rowEntity ): event called when a row is ready for saving
  • $scope.gridOptionsrowEditWaitInterval: grid option that controls how long a wait will be before a save is triggered (in ms)


Each row is in one of four states at any point in time:

clean: No edits have been made (or no edits since the last save) isDirty: Edits have been made, but the data has not yet been saved, either because the user is still editing the row or because the timer hasn't triggered as yet isSaving: The callback to save the row has been called and has not yet returned. The row is not editable during this time, and is shown as greyed out, so as to avoid the user causing locking exceptions by editing the row again isError: The save callback returned an error. The row still has the updated data displayed, but will be shown in red The basic method of operation is that whenever a cell is edited (identified using the edit.afterCellEdit event) an isDirty flag is set on the row, and a saveTimer is set. If another cell in the same row commences editing within 2 seconds (or other configurable time), then the timer will be destroyed again. Otherwise upon the timer completing the row will be set to a status of isSaving and greyed out, and the saveRow event will be called. The function called by this event must call rowEdit.setSavePromise, and the rowedit feature will wait on that promise.

If the cellNav feature is also enabled, then a setFocus on a cell within the row is sufficient to delay the timer (this more easily deals with situations where only some columns are editable, and a user tabs or clicks to a non-editable field on the same row).

If the promise is successfully resolved then the row is set back to clean. If the promise is rejected then the row is set to a status of isError.

Optionally, the calling application can request flushDirtyRows, which will trigger the save event for all currently dirty rows. If the rowEditWaitInterval grid option is set to -1, then saves will never be triggered by timer, and only be triggered when manually called.

Methods and properties are provided to operate with this regime:

getDirtyRows(): returns an array of gridRows of all currently dirty rows getErrorRows(): returns an array of gridRows of all currently errored rows flushDirtyRows(): flushes all currently dirty rows to the server, might be used on a page navigation request or pressing of a save button saveRow( rowEntity ): event called when a row is ready for saving rowEditWaitInterval: grid option that controls how long a wait will be before a save is triggered (in ms)