Partial DataSource Data From Server

I have a listgrid that I am displaying in a popup window. The grid contains 2 columns read from a database (and held in a datasource) and a 3rd column that the user can edit. This column is not part of the datasource and none of the data is ever returned to the server.

Each time the window is displayed I need to rebuild the list and reset the user-editable field back to blank. I have tried refreshing the list by calling invalidateCache() and setData() followed by fetchData(). Both of these rebuild the list but any changes made to the user-editable column still appear.

How do I get rid of these previous values?

Not sure that I completely understand your scenario but you can clear user-edited values which have never been saved via clearEditValue()

Thanks, but that doesn’t seem to give me what I need. Maybe a little more explanation is in order.

In the window I have a grid that lists employee names (read from a database) and allows the user to select which one(s) to send an email to. The user can choose “To”, “CC” or blank (meaning not a recipient). The list of names is dependent upon some other settings (defined in the page containing this popup window) so I need to refresh the list of employees each time the window is displayed.

I define the grid as follows:

recipientGrid: isc.ListGrid.create({
  autoFetchData: true,
  alternateRecordStyles: true,
  showAllRecords: true,
  canEdit: true,
  editByCell: true,
  fields: [
    {name: "select", type: "text", canEdit: true, width: 50, valueMap: ["","To","CC"]},
    {name: "name", canEdit: false},
    {name: "company", canEdit: false}
  ],
  dataSource: isc.DataSource.create({
    clientOnly: true,
    dataFormat: "json",
    dataURL: "recipientlist",
    fields: [
      {name: "username", type: "text", primaryKey: true},
      {name: "name", type: "text"},
      {name: "company", type: "text"}
    ],
    handleError: function(response, request) {logger.fatal("Error reading recipient list.");return false;}
  }),
  selectionChanged: function(record, state) {
    recipientGrid.endEditing();
  }
})

This data is not written back to the server. I read through the grid after the user clicks a button to determine which people were selected as recipients and then dismiss the window.

I also have a function that I call before showing the window that refreshes the grid data. The refresh works fine in that the list of names is rebuilt correctly, but any changes the user previously made to the “select” column still appear. I need all cells in this column to revert back to their original blank value.

clear: function() {
  recipientGrid.deselectAllRecords();
  if (recipientGrid.data && recipientGrid.data.invalidateCache)
    recipientGrid.data.invalidateCache();
}

I originally thought that, since the “select” field is defined in the grid but not the datasource then this would simply be blank when the datasource is refreshed. I guess this is not the case?

Thanks again for the help.

I am quickly (or not so quickly, since I have been messing with this for 2 days now) coming to the conclusion that there is no way to do this. There seems to be a disconnect between the grid, the data source and the test data.

It seems I can update the data correctly once by setting grid.data.dataSource.testData[i].field bat after that there is no way to get the grid to stop displaying the value. I can change field back to an empty string but the old value continues to show, even though inspecting the underlying value shows it has been changed.

I have tried invoking grid.redraw, grid.markForRedraw, grid.refreshCell, grid.clearEditValue but none of these have any effect.

If I try to call grid.setEditValue or grid.updateData I get an error which appears to be due to the grid not have a data source.

Before I scrap this approach (and waste two days worth of work) is there anything else I may have missed or need to do differently?

EditValues are what’s sticking around, so ignore all those other approaches.

Most likely there was just something wrong with your attempts to call clearEditValue(). The can’t-miss version of getting rid of editValues is to call grid.discardAllEdits() with no parameters. If anything is sticking after that we’d be very surprised :slight_smile: