Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

CanvasItem.storeValue not emitting change events

$
0
0
My CanvasItem isn't emitting the events the storeValue documentation promised me. In the example I've pasted below, I have two FormItems. I can catch events from the TextItem "ti", but not from the CustomItem "ci".

Digging in your ISC_Forms.js, I see that the first statement:
Code:

        if (this.compareValues(newValue, this._value)) {
            //this.logWarn("FI._updateValue: not saving, value unchanged: " + this._value);
          return true;
        }

is evaluating true when I call storeValue from my cellChanged method. If I comment the "return true" then I capture the event as expected. I can see that storeValue is called with every key stroke, so presumably it's changing the value every time, but cellChanged is only called when I hit Enter at which point the value is already up to date.

Am I doing something wrong?

I'm using "v9.1p_2015-07-08/Pro Deployment".


Code:

isc.ClassFactory.defineClass("CustomItem", "CanvasItem");
isc.CustomItem.addProperties({
  shouldSaveValue:true,
  createCanvas: function() {
      var lg = isc.ListGrid.create({
        dataSource: isc.DataSource.create({
            clientOnly:true,
            fields:[
              {hidden: true,name: "id",primaryKey: true},
              {name:"salign",title:"A"}
            ]
        }),
        saveLocally:true,
        data:this.getValue(),
        canEdit: true,
        cellChanged : function () {
            console.log("cellChanged",this.data);
            this.canvasItem.storeValue(this.data);
        }
      });
      return lg;
  },
  changed: function(f,i,v){
      console.log("changed");
  },
  showValue : function (displayValue, dataValue) {
      if (this.canvas == null) return;
      console.log("showValue:",dataValue);
      this.canvas.setData(dataValue);
  },
});

var df = isc.DynamicForm.create({
  width:300,
  height:200,
  autoDraw:true,
  numCols:1,
  colWidths:["*"],
  fields:[{name:"ci",showTitle:false,
            editorType:"CustomItem",
            height:200,
            defaultValue:[{id:1,salign:"initial text"}],
            changed: function(f,i,v){
              console.log("changed ci");
            },
          },
          {name:"ti",showTitle:false,
            changed: function(f,i,v){
              console.log("changed ti");
            },
          }
          ],
  itemChanged: function(item,newValue){
      console.log("itemChanged",item.name);
  },
});


Viewing all articles
Browse latest Browse all 4756

Trending Articles