on 04-30-2007 11:02 AM
hi all,
In my project i need to show the table rows in different colors, like first row blue, second row red, third row yello.... like that I need to show the table rows in all possible different colors.
I used table design property alternating and made table readonly, but its showing only 2 different colors blue and light blue( almost white).
I tried with the blog " colorful table in web dynpro" by sangeetha bandari...
<a href="/people/sap.user72/blog/2006/04/25/colourful-table-in-web-dynpro table in web dynpro</a> still its not working.
please help me out in this regard...
regards
pradeep
thank you abhi,
But still the same problem, I tried to add two rows as you said, but its showing that 2 rows 20 times, that is total 40 rows are displaying in my table. If I entered three twos its showing 3*20=60, its showing sixty rows. could you please tell me the reason. (may be its there inside for loop).
And also, coloring is coming only for first 20 rows, then after its not showing any colors only blue color.
here is the modified code as you told.
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName("deeps");
e.setNumber("3");
e.setDate("02/10/1980");
wdContext.nodeColor().addElement(e);
IColorElement e1= wdContext.nodeColor().createColorElement();
e1.setCellDesign1(design);
e1.setName("pradeep");
e1.setNumber("2");
e1.setDate("28/04/1980");
wdContext.nodeColor().addElement(e1);
}
<b>Please let me know the mistakes in my code.</b>thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pradeep,
it is showing those 2 rows 20 times because the loop continues for 10 times
(because Iterator i = WDTableCellDesign.iterateValues(); <b>i.hasNext()</b>; )
'i' here has 10 values , i.e. it is iterating for 10 time so 10 * 2 records = 20;
if you just want 2 records then you can break the loop after adding those 2 records
just try out this one:
Iterator i = WDTableCellDesign.iterateValues();
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName("deeps");
e.setNumber("3");
e.setDate("02/10/1980");
wdContext.nodeColor().addElement(e);
design = (WDTableCellDesign) i.next();
IColorElement e1= wdContext.nodeColor().createColorElement();
e1.setCellDesign1(design);
e1.setName("pradeep");
e1.setNumber("2");
e1.setDate("28/04/1980");
wdContext.nodeColor().addElement(e1);
dont put the code in loop,
let me know what you get;
regards
this works perfectly.... thank you very much.
you deserve full points...
thanks & regards,
Pradeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
May be this is not good coding practice(what i wrote in doInit()), but I am just learning(practicing) how to do the coloring... for the future purpose.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Abhijith,
When i did as you said, total table is filled with the single row values. As the code u said is in for loop.
Ofcourse as I asked for, It is displaying data and color to a row. But for example I need to have 5 different rows with different values, then it will not work.
check my total code for 3 rows
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
wdContext.nodeColor().addElement(e);
ArrayList al=new ArrayList();
IPrivateTablecolorCompView.IColorElement lobElement3 = wdContext.createColorElement();
lobElement3.setName("deeps");
lobElement3.setNumber("1");
lobElement3.setDate("02/10/1980");
al.add(lobElement3);
wdContext.nodeColor().bind(al);
IPrivateTablecolorCompView.IColorElement lobElement2 = wdContext.createColorElement();
lobElement2.setName("deep");
lobElement2.setNumber("2");
lobElement2.setDate("28/04/1980");
al.add(lobElement2);
IPrivateTablecolorCompView.IColorElement lobElement1 = wdContext.createColorElement();
lobElement1.setName("pradeep");
lobElement1.setNumber("3");
lobElement1.setDate("16/10/1981");
al.add(lobElement1);
wdContext.nodeColor().bind(al);
Its just displaying 3 rows with given data, colors are not there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pradeep,
Could you please let me know why have you used this two lines:
al.add(lobElement3);
wdContext.nodeColor().bind(al); //what is 'al'
ok,
1) Create a node Color as in blog
2)suppose you want to accept two parameters then create 2 value attributes besides CellDesign1, lets say the 2 value attributes are Name and Age.
3)Create a table(set its dataSource to Color) with two columns , so it will have 2 textView,
4)bind the CellDesign property of both column to CellDesign1 of node Color, set text Property of CellEditor of 1st Column to Name(Color.Name) and text of 2nd to Color.Age.
5)Now in WdDoInit() write the code:
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e = wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName("Deeps");
e.setAge("24");
wdContext.nodeColor.addElement(e);
IColorElement e = wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName("Abhi");
e.setAge("24");
wdContext.nodeColor.addElement(e);
//Same way you can add any nos of element
}
Earlier when you tried it showd you 1 row because you have used bind(), this replaces the whole element collection with the parameter you have. instead in loop we should always use addElement();
This should give u the result.
hope it helps
let me know if you face any problem
regards
ps : this may give you rows with same color since 'design' is not changing , when you will use loop to insert values , it will give you expected result.
Hi,
I bind the table cell Editor with the values what i need to show, I am able to view the values in the table when i execute. Proble here is, I am not able to see the color to the perticular row where some value is there.
color is showing in the rows where data is not there. I want the color in the rows only where data exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
table color is working fine till I add the data to the table. In doInit() I am adding data to a row, like
IPrivateTablecolorCompView.IColorElement lobElement3 = wdContext.createColorElement();
lobElement3.setName("deeps");
lobElement3.setNumber("3");
lobElement3.setDate("02/10/1980");
al.add(lobElement3);
wdContext.nodeColor().bind(al);
just before the color code (for loop).
when I execute this, color is not assigning to the row which has data, coloring is starting after the row which has data.
What I need to do If I want the coloring to the existing row which has data, not for all the rows.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
some doubt related to this topic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
U r right Valery... I forgot to add that line thank you very much.
Its solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not able to see different colors. I changed the design to standard, and I did each and every step perfectly. Its showing normal table with blue color.
In the 9th step of the blog shows
IColorElement e = wdContext.nodeColor().createAndAddColorElement();
but i could not write createAndAddColorElement() method. Its giving error so I used createColorElement() method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems that you forget to add element to node:
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName(design.toString());
/* MISSING LINE*/
wdContext.nodeColor().addElement(e);
}
VS
pradeep,
This example requires NW04s, proobably uou have NW04.
Check Help->About in your NW IDE -- if it reports version 7.x then its NW04s and we can help you to solve your problems, but if it reports 2.x -- then it is NW04 and functionality mentioned in blog is not available
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi silaev,
I am using 7.0.0 version, this means its NW04s (as you said).
my code in doInit() method is
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
e.setName(design.toString());
}
pradeep,
So what is not working in your case?
You don't see different colors or something elese?
Try to use "standard" table design.
Also make sure that you performed step 7 from blog correctly (binding of CellDesign property)
Valery Silaev
SaM Solutions
Pradeep,
considering this is the code you have used for tables colors,
check out the comments code...
for (Iterator i = WDTableCellDesign.iterateValues(); i.hasNext(); )
{
WDTableCellDesign design = (WDTableCellDesign) i.next();
IColorElement e= wdContext.nodeColor().createColorElement();
e.setCellDesign1(design);
//instead of following statement :
e.setName(design.toString());
//use this as
e.setName("Deeps");
//similarly you can set other attributes too, depending upon how many value attributes
//you have defined in node Color
wdContext.nodeColor().addElement(e);
}
similarly you can have any number of value attribute under node Color, and correspondingly same no of columns, with each columns CellDesign Property set to Color.CellDesign1
hope it helps
regards
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.