Announcement

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

    setEditValues bug (or unexpected inconsistency with setEditValue)

    I've isolated a test case where grouping is not dynamically updated when setEditValues is used where an equivalent setEditValue is. I'm using "v9.1p_2015-02-07/Pro Deployment".

    If you click "setEditValue", you'll see that the United States jumps to Asia's group, as expected. But if you click setEditValues, the United States incorrectly remains in the North America group.

    This seems like a bug to me. Or, if this behavior is what Isomorphic wants, it should be included in the list of differences in the documentation for setEditValues.


    Code:
    countryData = [
    {
        continent:"North America",
        countryName:"United States",
    },
    {
        continent:"Asia",
        countryName:"China"
    }
    ];
    
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:150, alternateRecordStyles:true,
        fields:[
           {name:"countryName", title:"Country"},
           {name:"continent", title:"Continent"}
        ],
       groupByField:"continent",
       canEdit:true,
       groupStartOpen:"all",
       autoFetchData:true,
       data: countryData,
       autoDraw:true
       
    });
    
    isc.Button.create({
       top:175,
       autoDraw:true,
       title:"setEditValue",
       click: function(){
          var record = countryData[0];
          var rowNum = countryList.getRecordIndex(record);
          var colNum = countryList.getFieldNum("continent");
          countryList.setEditValue(rowNum,colNum,"Asia");
          countryList.saveAllEdits();
       }
    });
    
    isc.Button.create({
       top:200,
       autoDraw:true,
       title:"setEditValues",
       click: function(){
          var record = countryData[0];
          var rowNum = countryList.getRecordIndex(record);
          record["continent"] = "Asia";
          countryList.setEditValues(rowNum,record);
          countryList.saveAllEdits();
       }
    });

    #2
    There's a problem with your app code here. You're directly manipulating the underlying data object (the record in the data-set) [and then calling 'setEditValues' with that modified record].
    Instead you should create a new 'edits' object which contains just the modified values you want to apply and pass that to setEditValues. Something like this:

    Code:
    isc.Button.create({
       top:200,
       autoDraw:true,
       title:"setEditValues",
       click: function(){
          var record = countryData[0];
          var rowNum = countryList.getRecordIndex(record);
          var edits = {continent:"Asia"};
          countryList.setEditValues(rowNum,edits);
          countryList.saveAllEdits();
       }
    });
    Regards
    Isomorphic Software

    Comment


      #3
      Ok, that variant resolves the issue.

      I didn't think it would be a problem to pass in extra data because I expected it to iterate over the ListGrid's fields and grab associated values. But it looks like initial groupTree data is also being copied and referenced before the groupTree data is rebuilt.

      Comment

      Working...
      X