3.0.5

How to get value of columns alignment?

How do you get how a column is aligned? To find out if its value is left or right? Not sure of proper syntax to find it's alignment dynamically.

Such as:

if (Column is align right) { then do this }
if (Column is align left) { then do that}

Thanks!
Anthony
September 29,
Hello,

'obj.getColumnTemplate(colIndex).getStyle("text-align");' should help
Gernot
September 30,
Tried it and it just gives "undefined"....
Anthony
September 30,
Hello,

if the style has not been set, this returns 'undefined', the default align is left, so this style maybe is not set. did you try it with right aligned columns?
Gernot
September 30,
Here is how I got the CSS set up.

.active-column-0 {width: 80px;}
.active-column-1 {width: 200px;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

And I was trying it with a right align column...

I was trying to change alignment based on how it was already displayed....

// Gets changes column alignment on Dbl-click
   var varSelCol=0;
   function fctOpen(){
    // Check to see what alignment
    var X = obj.getColumnTemplate(varSelCol).getStyle("text-align");
    //alert(X);  // alert me to columns alignment
    // Change alignment to opposite
    if ( X == "right" ) {    
          obj.getColumnTemplate(varSelCol).setStyle("text-align", "left");
    }
    else {obj.getColumnTemplate(varSelCol).setStyle("text-align", "right");}
    obj.refresh();
   }  
   obj.setAction('click', function(src){
   varSelCol = src.getColumnProperty('index');
   }); 
   obj.setEvent('ondblclick', function(event, src){fctOpen()});
Anthony
September 30,
You were right that it shows "undefined" on default. What I mean is that when it loads the data when the page opens the CSS positions the text. So I guess that at that point it "undefined". And if I manipulate the alignment and then do obj.getColumnTemplate(varSelCol).getStyle("text-align"); again it will give the alignment.

So how would I be able do with out manipulating the text alignment dynamically first like below? Such as on startup.

obj.getColumnTemplate(varSelCol).setStyle("text-align", "center");
Anthony
September 30,
nevermind, I think I figured it out already.
Anthony
September 30,

This topic is archived.

See also:


Back to support forum