Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nancy on Apr 14, 2008 00:35
open dhtmlx forum
How to align cell data

I want to align numeric data to the right. Below is the syntax I used:

for i=1 to index

If IsNaN(a(i)) then
Response.Write "<cell style=""text-align:right;""><![CDATA[ " & a(i) & "]]></cell>"
Else
Response.Write "<cell><![CDATA[" & a(i) & "]]></cell>"
End If
next

Is my syntax correct? Can I use style attribute in cell tag. The problem here is that I can display all but the last row right not aligned i.e., sample output is

20
30
40
50
Only 50 is aligned left I am confused with this behaviour. Please suggest

Answer posted by Support on Apr 14, 2008 05:49
The cell@style must work for any row , without any relation to its position, so the problem may be in your ASP code. I'm not pretty sure, but it may be that
    If IsNaN(a(i)) then
not works as expected.

By the way, you can set align of whole column to the right by using next command
    grid.setColAlign(...

Answer posted on Apr 14, 2008 06:04
But in 'View Source' I can see that even last row is aligned right. Only in the grid it doesnot display. For testing I have included one more row then  all the rows except the last row is aligned right. I think this is the problem with grid. Last row has different properties compared to the other rows. Because when I click on last row and then click on other rows then last row turns white. But when I click on the other rows and click on any other row then those cells dont turn white. Do I need to change any property of grid. please suggest.
Answer posted by Support on Apr 14, 2008 06:49
Please provide the XML code which generated by your ASP script, because it hard to suggest anything, without ability to recreate problem.
By the way, similar problem may occur if you have non-unique row IDs
Answer posted by Nancy on Apr 14, 2008 07:11

Here is my source

 

<script type="text/javascript">

var sXML='<?xml version=\"1.0\" encoding=\"UTF-8\"?><rows><head>

<column width="100" type="ro" align="left"><![CDATA[Name]]></column>

<column width="100" type="ro" align="left"><![CDATA[Quantity]]></column>

</head>

<row>
 <cell><![CDATA[Bread]]></cell>
 <cell style="text-align:right"><![CDATA[4]]></cell>
</row>

<row>
 <cell><![CDATA[Vegetables]]></cell>
 <cell style="text-align:right"><![CDATA[33]]></cell>
</row>
</rows>';
</script>

Here 4 is aligned right but 33 is not aligned right.

Answer posted by Support on Apr 14, 2008 07:31
Please check attached sample, it uses the same code and works correctly.
Attachments (1)