Data Changed - Continued Topic
Prev topic - http://www.activewidgets.com/messages/1788-14.htm
Problem - grid.refresh() was crashing when grid was sorted before changing data...
Suggested solution for CSV & XML was this patch
Active.HTTP.Request.prototype.response = function(data){
if (this.$owner) {
this.$owner.setRowProperty("value", function(i){return i});
this.$owner.setRowProperty("order", function(i){return i});
this.$owner.setRowProperty("count", this.getCount());
this.$owner.setSortProperty("index", null);
this.$owner.refresh();
}
}
We have similar problems in JS Array data
Here is the work-around patch I'm using.
Active.Controls.Grid.prototype.setAction("dataChanged", function() {
// set data count
var newCount = this.currentRoles.length;
this.setDataProperty("count", newCount);
// clear internal row state
var rowValues = [];
for(var i=0; i < newCount; ++i) { rowValues.push(i); }
this.setRowProperty("values", rowValues);
this.setSortProperty("index", null);
// clear selection - if required
this.setSelectionProperty("index", -1);
this.setSelectionProperty("values", []);
this.refresh();
});
This is how it's being used.
...
function changeData() {
// change the myData - add/edit/delete
// tell grid about new size (remember using setDataProperty)
obj.setDataProperty("count", myData.length);
obj.action("dataChanged");
}
...
My question, How can we invoke this action internally when obj.setDataProperty("count", myData.length); is called.
By the way - I can live with this extra line of code after every obj.setDataProperty("count", myData.length);
Sudhaker Raj
August 25,