grid.clearAll() bug?

Hi guys,
I have 2 grids. When selecting a row in the first, it shows relevant data on the second.
An event onRowSelect is taking care of that.
The first thing the function does, is clearing the second grid.

function job_is_selected(row_id, ind){
targets_grid.clearAll();
job_num = jobs_grid.cellById(row_id, jobs_grid.getColIndexById(“ID”)).getValue();

// then, getting new data
var loader = dhtmlxAjax.postSync(perl, "data=job_num" 
targets_grid.loadXMLString(loader.xmlDoc.responseText);

}

The problem is the ClearAll() doesn’t work so the grid looks stuck with wrong data for a few seconds.

Now, I found out that if I have dhtmlXWindows object open and shown before calling the ClearAll function, it does work.

function job_is_selected(row_id, ind){
dhxPlugins = new dhtmlXWindows();
… preparation of window …
window_obj.window(“cnsl_window”).show();

targets_grid.clearAll();
job_num = jobs_grid.cellById(row_id, jobs_grid.getColIndexById("ID")).getValue();

// then, getting new data
var loader = dhtmlxAjax.postSync(perl, "data=job_num" 
targets_grid.loadXMLString(loader.xmlDoc.responseText);

}

What’s going on here…?

Thanks,
Guy.

The problem is the ClearAll() doesn’t work so the grid looks stuck with wrong data for a few seconds.

Problem caused by the sync. loading operation. While sync operation is processed, browser will not repaint self. So to fix the view, just add a small timeout between grid clearing and sync data loading

targets_grid.clearAll() setTimeout(function(){ var loader = dhtmlxAjax.postSync(perl, "data=job_num" targets_grid.loadXMLString(loader.xmlDoc.responseText); } },1);

Thanks, got it.
Why is it so? Is the ClearAll function work async?
All I want is clear, and then, continue. Isn’t it possible to make that function synced?
Anyway, how much time is necessary? A second is too much in my case.

Thanks,
Guy.

the clearAll is a sync operation, but while it changes state of html, browser will not paint it until current js thread is still active ( default browser’s behavior ) and thread will be active while sync operation is not finished. So while inner state will be changed, browser will still show old one while postSync will not be processed.

With timeout grid clearing and postSync are in separate js threads and doesn’t affect each other.