PDA

View Full Version : Input Box in renderer resets



varunjyoti
18 Dec 2011, 11:07 PM
Hello

I have an input box in a grid which i have applied through renderer.


renderer:function(value,metadata,record,rowIndex,colIndex,store,view){
return '<input type="text" id="contact_email_'+rowIndex +'"/>';
}


The problem is that when i perform any action on grid, the renderer gets called and the input box resets. I dont want the input box to get reset once it is rendered. I need some way so that renderer gets called just once or some other kind of solution

Thanks

tvanzoelen
19 Dec 2011, 3:10 AM
Is it on the column renderer? That will be called on every reload of the grid at least, because it renders the content.

Is an Action column no option, if you don't mind the data in the grid?

varunjyoti
19 Dec 2011, 5:08 AM
tvanzoelen,

It is a column renderer. Is there a way so that the renderer gets called just once. or is there a way so that the renderer does not perform anything so that input box does not get reset

tvanzoelen
19 Dec 2011, 5:25 AM
I think the renderer is supposed to render the column data. It will render if the data if the column changes.

But you can manupulate its output, its javacode.
Maybe something like below.


renderer:function(value,metadata,record,rowIndex,colIndex,store,view){
var item = Ext.get('contact_email_'+rowIndex);
if(item == undefined)
return '<input type="text" id="contact_email_'+rowIndex +'"/>';
}


But I am not sure if this is the proper way to use the columnrenderer.

Other possibillity is to set the value property on the <input> if you know its value.

Is this no option http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.Editing ?

varunjyoti
19 Dec 2011, 6:26 AM
I already tried what you suggested. It makes the column empty. because renderer then returns empty string.
I dont want the editor. i just want the textbox at the first place.


I think the renderer is supposed to render the column data. It will render if the data if the column changes.

But you can manupulate its output, its javacode.
Maybe something like below.


renderer:function(value,metadata,record,rowIndex,colIndex,store,view){
var item = Ext.get('contact_email_'+rowIndex);
if(item == undefined)
return '<input type="text" id="contact_email_'+rowIndex +'"/>';
}


But I am not sure if this is the proper way to use the columnrenderer.

Other possibillity is to set the value property on the <input> if you know its value.

Is this no option http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.Editing (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.grid.plugin.Editing) ?

tvanzoelen
19 Dec 2011, 6:29 AM
Does it still exist that input item if you do this?



renderer:function(value,metadata,record,rowIndex,colIndex,store,view){
var item = Ext.get('contact_email_'+rowIndex);
if(item == undefined)
return '<input type="text" id="contact_email_'+rowIndex +'"/>';
else{
return item;
}
}