Closed Level0r0s closed 8 years ago
modelGrid.onAfterRender
event doesn't exist.
But there is modelGrid.onRender
event. It is called while cells rendering. So if you apply Invoke.later(function(){})
scheme with 'first callback call wins' logic, than you can achieve needed effect.
See module invoke
in the API. It works under browser as well and also it avoids memory leak of setTimeout()
without clearTimeout()
idiom.
In general it is not needed to keep track of grid's rendering. Grid rendering occurs while various operations on data or grid itself. Can you please describe the goal of your logic within your task?
With such description we will be able to think of new onAfterRender
event.
Also you can make a pull request to add this new event to ModelGrid.
Send focus to the modelGrid after query, AGIL application, no need use the mouse to select Row.
example:
Event KeyPress in modelGrid
if modelGrid.KeyPress = 27 (ESC) { imputSearch.Focus()} ;
Event modelGrid.onAfterRender
if (!model.qryPODepartamento.length===0){
modelGridFocus.value.focus(); // this event ocurred before render modelGrid
}
link to function: modelGridFocus.value.focus() solved with the function
Create Class to Resolve
function TmodelGridFocus()
{
this.modelGrid = {};
this.modelGridOld = {};
this.firstFocu = {};
this.processFocus = false;
this.changeModelGrid=function(modelGrid){
if (this.modelGridOld ===modelGrid) {
return;
};
if (this.modelGridOld ) {
if (this.onRenderOld) {
this.modelGridOld.onRender = this.onRenderOld();
};
};
this.modelGrid =modelGrid;
if (this.modelGrid.onRender) {
this.onRenderOld =this.modelGrid.onRender;
};
this.modelGridOld =modelGrid;
//modelGridFocus.firtsTabStop(modelGridFocus.modelGrid.element,true, modelGridFocus) ;
this.modelGrid.onRender = function(evt){
if (modelGridFocus.onRenderOld) { onRenderOld();}
if (modelGridFocus.processFocus){
modelGridFocus.processFocus =false;
Invoke.later(function(){
if (!modelGridFocus.modelGrid.data.length==0){
//form.btnTeste.focus();
modelGridFocus.firtsTabStop(modelGridFocus.modelGrid.element,true, modelGridFocus) ;
modelGridFocus.firstFocu.focus();
}
});
};
};
};
this.firtsTabStop = function (el,inicio, o) {
if (el.tabIndex >-1) {
o.firstFocu = el;
return true;
}
else {
// Check if this element is a tab stop
if (!inicio) {
// Check if children are tab stops
for (var i = 0, l = el.children.length; i < l; i++) {
if (this.firtsTabStop(el.children[i],false,o)) {
return true;
}
}
}
else {
// Check if children are tab stops
for (var i = 0, l = el.children.length; i < l; i++) {
if (el.children[i].tagName==='TABLE'){
if (this.firtsTabStop(el.children[i],false,o)) {
return true;
};
}
}
}
}
};
this.checkSetFocus=function (){
if (!this.modelGrid.data.length==0){
this.processFocus=true ;
};
};
}
Example use:
var modelGridFocus = new TmodelGridFocus();
modelGridFocus.changeModelGrid( form.modelGrid); //use to set modelGrid to controller
model.Records.requery(
function(){
modelGridFocus.checkSetFocus(); //use to check records >0
},
Added an event onAfterRender
. It is experimental and is available in nightly build (on branch master).
form.modelGrid.onAfterRender = function (evt) { Logger.info('grid rendered'); };
Example:
no found event after render modelGrid .
Tanks link to function: modelGridFocus.value.focus() solved with the function