Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    A good way to show server initiated feedback

    When saving/deleting data, I sometimes would like to show feedback to the user when the save/delete action is performed by the server (I use a JSON RestDataSource). As an example, I could think of a employee reporting hours per day and after a save action I could show a dialog with the total hours in the month.

    What kind of event/callback mechanism would I use? I am thinking about transformResponse in the data source and using extra meta data. For a create or update action, this could be:

    Code:
    response: {
      status: 0,
      data: {
        id: 1,
        name: 'John Doe',
        date: '2010-09-16',
        hours: 5
      },
      hours_per_month: 100
    }
    For a delete action, it's something like this:

    Code:
    response: {
      status: 0,
      data: {
        id: 1
      },
      hours_per_month: 95
    }
    The reason I choose transformResponse is that it seems to be triggered for all data operations (fetch, add, update, delete) and it is widget independent: it works for a form and a editable grid.

    My objections to this approach is that a data source doesn't feel like the right place to update visual components.

    Any thoughts or ideas?
    Thanks in advance.

    #2
    There's really no shortcut for using component-specific callbacks to do this (such as the callback for saveData(), or editComplete()). While you could add this at the DataSource layer as a short-term hack, it's likely to misfire some time in the future, for example, confirmation dialogs popping up in the middle of a multi-row drag and drop that happens to be issuing "update" or "add" operations.

    Comment

    Working...
    X