Since Ok Alert is shown, you are in good condition and the callback function is called successfully. The problem is that calling the removeAllChildren method does not remove rows from your collector. the solution is to iterate over the columns and delete the rows as follows:
Ti.App.addEventListener('db_update', function(){ alert("OK"); //get picker columns var columns=$.picker.getColumns(); //Iterate over picker columns for (var it=0,length=columns.length;i<length;it++){ //iterate over column rows if(columns[it]){ var len = col.rowCount; for(var index=0,collength=columns[it].length;index<collength;index++){ //remove rows[index] of columns[it] columns[it].removeRow(columns[it].rows[index]); } } } });
By the way, Applcelerator people said that using global events (Ti.App events) could cause memory management problems ...
Keep in mind that application-level events are global, which means that they remain in context all the time your application is running (unless you delete them). This also means that all the objects that they reference also remain in the application scope. This may interfere with the collection of these objects. Heroes of Appellier .
Another method is to use global functions:
In your first view controller (where the collector is defined):
Alloy.Globals.removeAllPickerChildren=function(){
and then in the second view of the viewcontroller:
$.btnclick.addEventListener('click', function(){ if(Alloy.Globals.removeAllPickerChildren) Alloy.Globals.removeAllPickerChildren(); });
source share