Announcement

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

    problem with grid.autoSaveEdits: false, and rowHasChanges


    SmartClient Version: v13.1p_2025-04-09/AllModules Development Only (built 2025-04-09)

    Hello, in a grid with autoSaveEdits: false, when there are pending edits, I want to change the style of the entire record so that it's clear the record needs to be saved - even when the edit consists of clearing a cell value.

    While testing my solution, I believe I've found a bug. Please try the following test case in the editByRow sample:


    Code:
    isc.IButton.create({
        ID: "saveAllButton",
        title: "Save All",
        click: "countryList.saveAllEdits()"
    });
    
    isc.ListGrid.create({
        ID: "countryList",
        width: 550, height: 224, top: 50,
        // use server-side dataSource so edits are retained across page transitions
        dataSource: countryDS,
        // display a subset of fields from the datasource
        autoSaveEdits: false,
        modalEditing: true,
        canEditCell: function (rowNum, colNum) {
            var editedRecord = this.getEditedRecord(rowNum);
            var fieldName = this.getFieldName(colNum);
    
            if (fieldName === "countryName" && editedRecord.countryName === 'France') {
                return false;
            }
    
            return this.Super("canEditCell", arguments);
        },
        getCellCSSText: function (record, rowNum, colNum) {
            if (this.rowHasChanges(rowNum) && !this.recordMarkedAsRemoved(rowNum)) {
                return this.editPendingCSSText;
            } else {
                return this.Super("getCellCSSText", arguments);
            }
        },
        fields: [
            {
                name: "countryCode",
                title: "Flag",
                width: 40,
                type: "image",
                imageURLPrefix: "flags/24/",
                imageURLSuffix: ".png",
                canEdit: false
            },
            {name: "countryName"},
            {name: "capital"}
        ],
        autoFetchData: true,
        canEdit: true
    })
    then
    1. edit the first and second records by deleting their "Capital" values
    2. click "Save All"
    3. Edit the second record again by double-clicking the (now empty) "Capital" cell.
    4. Exit the cell without typing anything - either by clicking outside the cell or pressing Enter (not Escape)
    5. You'll see that the record gets the "pending" style.

    In fact, countryList.recordHasChanges(1) returns true and countryList.getEditValues(1) is:
    Code:
    {pk: 2, capital: null}

    #2
    Hi Claudio
    We tried your test case and didn't see the behavior you're describing. Could you double check that the sample code you've posted here reproduces the issue for you and also share your environment (OS / Browser)?

    Thanks

    Comment


      #3
      Hello, it happens using Chrome, FF and Safari on MacOS, but there's a typo in the test case, here is the corrected version:

      Code:
      isc.IButton.create({
          ID: "saveAllButton",
          title: "Save All",
          click: "countryList.saveAllEdits()"
      });
      
      isc.ListGrid.create({
          ID: "countryList",
          width: 550, height: 224, top: 50,
          // use server-side dataSource so edits are retained across page transitions
          dataSource: countryDS,
          // display a subset of fields from the datasource
          autoSaveEdits: false,
          modalEditing: true,
          canEditCell: function (rowNum, colNum) {
              var editedRecord = this.getEditedRecord(rowNum);
              var fieldName = this.getFieldName(colNum);
      
              if (fieldName === "countryName" && editedRecord.countryName === 'France') {
                  return false;
              }
      
              return this.Super("canEditCell", arguments);
          },
          getCellCSSText: function (record, rowNum, colNum) {
              if (this.rowHasChanges(rowNum) && !this.recordMarkedAsRemoved(rowNum)) {
                  return this.editPendingCSSText;
              } else {
                  return this.Super("getCellCSSText", arguments);
              }
          },
          fields: [
              {
                  name: "countryCode",
                  title: "Flag",
                  width: 40,
                  type: "image",
                  imageURLPrefix: "flags/24/",
                  imageURLSuffix: ".png",
                  canEdit: false
              },
              {name: "countryName"},
              {name: "capital"}
          ],
          autoFetchData: true,
          canEdit: true
      })

      Comment


        #4
        We now see the issue and have someone looking into it.
        Regards

        Comment

        Working...
        X