Announcement

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

    [BUG] ListGrid with inline edit with editByCell doesn't work as expected

    Hi Isomorphic,

    I've found a bug with ListGrid inline editing with editByCell. How to reproduce:

    1. Double click on a first row first column
    2. Enter random text and press Tab
    3. Enter other random text and press Tab
    All other rows react the same - first edit column is sent to server and others not.

    Situation:
    In console you can see that only on step 2. you'll see performDSOperation: Arguments(4) ["update",] operation going.
    and on step 3. no action is taken.

    Preliminary case:
    it's due somehow internal object of DynamicForm is placed into ListGrid.localData and then further changes of DynamicForm object instantly reflects to localData's row info and thus suppresses ability to detect what fields have changed. Because of that no further update operations is triggered..

    I've suspected:
    1) isc.Selection.dataArrived: where updateData = this.data._lastUpdateData; is passed down to dataChanged()
    2) and then isc.Selection.dataChanged: calls ruleScopeComponent.provideRuleContext(ds.getID(), modifiedRecord, grid, hasStableID); which mangles internal structures of ListGrid/ResultSet somehow.

    tried to add this.shallowCopy() in isc.Selection.dataArrived but with no luck.. hope you'll find out faster why is this happening

    All versions are affected:

    Tested on latest - 12.0p/LGPL/2020-03-24
    and 12.1d/LGPL/2020-03-24
    down to 12.0p/LGPL/2019-07-27


    Here is code for test:

    Code:
      
     const testData = [     {id: 1, name: "test", code: "test"},     {id: 2, name: "test", code: "test"},     {id: 3, name: "test", code: "test"}, ];  const parent = {     performDSOperation: isc.DataSource.getPrototype().performDSOperation };  const dataSource = isc.DataSource.create({     ID: "ds",     clientOnly: true,     testData: testData,     fields: [         {             hidden: true,             primaryKey: true,             name: "id",             type: "sequence",             required: false         },         {             title: "Name",             name: "name",             length: 50,             type: "text",             required: true         },         {             title: "Code",             name: "code",             length: 20,             type: "text",             required: false         }     ],     performDSOperation: function () {         console.log("performDSOperation: ", arguments);         return parent.performDSOperation.apply(this, arguments);     },     fetchData: function (criteria, callback, requestProperties) {         console.log('fetchData: ', criteria, requestProperties);         this.performDSOperation("fetch", criteria, callback, requestProperties);     }, }); const listgrid = isc.ListGrid.create({     autoDraw: true,     width: "100%",     height: "100%",     dataSource: dataSource,     canRemoveRecords: true,     autoFetchData: true,     dataProperties: {useClientFiltering: false, useClientSorting: false},     canEdit: true,     editByCell: true }); isc.Button.create({title: "Refresh", autoDraw: true}).click = () => { listgrid.invalidateCache() }

    #2
    Found culprit:

    in function isc.Selection.dataChanged:

    a) there is "reselectOnUpdate" logic, if this is true, then there is a lines:
    var modifiedRecord = this.data.findByKey(originalRecord);
    if (modifiedRecord) this.performReselectOnUpdate(modifiedRecord, rowNum);

    b) a little below if updateContext:
    it's called: ruleScopeComponent.provideRuleContext(ds.getID(), modifiedRecord, grid, null, hasStableID);

    which passes record to DynamicForm of inline editor and now DynamicForm object is actually ResultSet's localData object thats why all other edits instantly updates internal structures of result set thus disables ability to track future changes of that record.

    by replacing: ruleScopeComponent.provideRuleContext(ds.getID(), isc.shallowCopy(modifiedRecord), grid, null, hasStableID); fixes issue.

    Or just selecting reselectOnUpdate to false, but then after pressing Tab selected row gets deselected.

    Hope it will help to fix issue faster. Thanks.

    Comment


      #3
      fast workaround:
      Code:
       
       (()=> { const parent = {     provideRuleContext: isc.ListGrid.getPrototype().provideRuleContext };  isc.ListGrid.addMethods({     provideRuleContext: function (path, data, dbc, suppressChangeEvent) {         if (path === this.dataSource.ID) {             return parent.provideRuleContext.call(this, path, isc.shallowClone(data), dbc, suppressChangeEvent);         } else return parent.provideRuleContext.call(this, path, data, dbc, suppressChangeEvent);     } }); })();

      Comment


        #4
        Thanks for the report and details. A fix has been committed and will be available in builds starting on Mar 25.

        Comment

        Working...
        X