:: Forum >>

new bug in grid?

Hi,

here is an exemple of a code that doesn't work. I try to change from a button the color of a row. if i set once the color with "obj.getRowTemplate(1).setStyle("background","red");", i can't set it again... Why?

here's the code :

<html>
<head>
<TITLE>Manuel des echecs Aude sur IP</TITLE>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
<style>
#myGrid .aw-alternate-even {background: #fff;}
#myGrid .aw-alternate-odd {background: #eee;}
#myGrid .aw-rows-selected {background: #316ac5;}
#myGrid .aw-grid-headers {color: blue}
#myGrid .aw-row-selector {width: 40px; text-align: left}
#myGrid .aw-row-1 {background: #FF0000}
</style>
<script>
var obj = new AW.Grid.Extended;
var button = new AW.UI.Button;
obj.setId("myGrid");
button.setId("button");
button.setControlText("clic me for color yellow");
obj.setControlSize(800, 250);
obj.setCellText(function(i, j){return j + "-" + i});
obj.setHeaderText("header");
obj.setColumnCount(10);
obj.setRowCount(10000);

// I set the color once :
obj.getRowTemplate(1).setStyle("background","red");


document.write(obj);
document.write(button);

button.onClick = function(text){
// when i set another time (from a button), it doesn't work!!!
obj.getRowTemplate(1).setStyle("background","yellow");
obj.refresh();
};
</script>
</body>
</html>
Pierre
Monday, November 21, 2005
just wondering if the event fires from the button the second time
J
Thursday, November 24, 2005
If you want to try the button : try to comment the first modification, then tuch the button : it will work... once, and no more. I don't know why, that's my question...

try this :

<html>
<head>
<TITLE>Manuel des echecs Aude sur IP</TITLE>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
<style>
#myGrid .aw-alternate-even {background: #fff;}
#myGrid .aw-alternate-odd {background: #eee;}
#myGrid .aw-rows-selected {background: #316ac5;}
#myGrid .aw-grid-headers {color: blue}
#myGrid .aw-row-selector {width: 40px; text-align: left}
#myGrid .aw-row-1 {background: #0000FF}
</style>
<script>
var obj = new AW.Grid.Extended;
var button = new AW.UI.Button;
var button2 = new AW.UI.Button;
obj.setId("myGrid");
button.setId("button");
button2.setId("button2");
button.setControlText("clic me for color yellow");
button2.setControlText("clic me for color red");
obj.setControlSize(800, 250);
obj.setCellText(function(i, j){return j + "-" + i});
obj.setHeaderText("header");
obj.setColumnCount(10);
obj.setRowCount(10000);


document.write(obj);
document.write(button);
document.write(button2);

button.onClick = function(text){
// when i set another time (from a button), it doesn't work!!!
obj.getRowTemplate(1).setStyle("background","yellow");
obj.refresh();
};

button2.onClick = function(text){
// when i set another time (from a button), it doesn't work!!!
obj.getRowTemplate(1).setStyle("background","red");
obj.refresh();
};
</script>
</body>
</html>

you can tuch first red or yellow, the first action will work, the second not, why?
Pierre
Thursday, November 24, 2005
as I said ensure the button event is been fired put a alert in to notify you to make sure.
J
Thursday, November 24, 2005
i did, and more, if i put something like
alert(obj.getRowTemplate(1));

i can see that the code has changed, whith the good color. But unfortunately, nothing appear to change in the grid...

In the previous ex, if you clic the first button, it'll work, but not the second one (you can reverse order, the first button clicked isn't important) In one case the line will beocome yellow, and can't change to red, and in the second case, it become red, and can't change to yellow...
Monday, November 28, 2005
I'm having the same problem, have you found the fix for this?
If yes, please post.
ShepherdOwner
Wednesday, January 11, 2006
I find it is much more reliable to change an objects CLASS then it is to directly manipulate the style via Javascript. If you create a new CLASS that has the style attributes you need, then change the object to that CLASS then you should be able to change it back at will.
I too have had some problems playing with the background setting using Jacascript but have not had any problems manipulating style attributes vis CSS Classes.
Jim Hunter
Wednesday, January 11, 2006

This topic is archived.


Back to support forum

Forum search