PDA

View Full Version : javascript in title of column



erenault
15 Jul 2008, 7:02 AM
Hi,

In the view, I use a javascript function allowing manage for multilingual labels.
In the form $$viewtemplate I have this :

<script language="javascript">
var mylabel1="mylabelEN1"
var mylabel2="mylabelEN2"
</script>

<script language="javascript">
function getLabel(myKey) {
document.write(myKey);
}
</script>

A function in the header load the text of myLabel1 and myLabel2 in user's language.
In the title of the column, I have [<script> getLabel(mylabel2)</script>]
If I display the view without Ext.nd, I see "mylabelEN1" in the title of the column:D
But if i display the view with Ext.nd, I see only []:(
I think the javascript is interpreted by the function using readdesign but i don't know where changing the code.:((

Could someone help me ?
Thanks for avance

jratcliff
16 Jul 2008, 7:35 PM
This is a tough one. Perhaps there's a way to add a listener to the GridPanels 'beforerender' event and from there, get the column model and change the column header. :-?

erenault
17 Jul 2008, 12:28 AM
This is a tough one. Perhaps there's a way to add a listener to the GridPanels 'beforerender' event and from there, get the column model and change the column header. :-?
I'll try it.
But I've got another idea :
if there is a tag in the column header, the tag is deleted from display.
Do you know if it's normal ?
I will try your solution ...


sorry for my bad english:">

erenault
18 Jul 2008, 12:49 AM
This is a tough one. Perhaps there's a way to add a listener to the GridPanels 'beforerender' event and from there, get the column model and change the column header. :-?
=D>
the solution :


listeners: {
'beforeRender':{
fn: function(){
this.store.on( 'load', function(){
for (var i = 0; i < this.getColumnModel().getColumnCount(); i++) {
this.getColumnModel().setColumnHeader(i, getHeader(this.getColumnModel().getColumnHeader(i)) );
}
}, this)
}}
}



function getHeader( strKey )
{
var result = strKey.toLowerCase().trim();
var start = result.indexOf("getstring(");
if (start != -1)
{
result = result.substring(start+10,result.indexOf(")"));
eval('result = '+result);
} else {
if ( result.indexOf("view") != -1 )
eval('result = '+result);
}
return result;
}

Thanks you a lot