3.2.0

Checkboxes in grid

Ok, here is a tricky one :
I understood the checkbox, and according to be, should be the same within the grid... So I made a small example :

<script>
 var checkbox = new AW.UI.Checkbox;
 checkbox.setControlText("Checkbox");
 checkbox.onControlValueChanged = function(value){
 alert("this one works fine");
 }
 document.write(checkbox);
 
 var obj = new AW.UI.Grid;
/////////////////////////////////////////
var c0 = new AW.UI.Checkbox;                 //OR AW.Templates.Checkbox;
c0.onControlValueChanged = function(value){
alert("here")
}
c0.onItemClicked = function(event, i){
alert("here too")
}
c0.onControlStateChanged = function(value){
alert("here also")
}
obj.setCellTemplate(c0, 0);  
/////////////////////////////////////////
 obj.setColumnCount(1);
 obj.setRowCount(1);
 document.write(obj);
</script>

I can't understand why I never catch the event, so as to be able to take over, like change the value of myData array...
Shouldn't the checkbox change automatically the value of the myData[i][j] of the corresponding cell?

Furthermore, when do we use UI or Templates in the grid?

Any light of this is usefull!
Michel
November 26,
Ok, I have been posting several issues about check boxes, and I finally found the first part of my answer : these methods are not called or at least not reached in the grid v2b. Instead, it triggers the function called onToggleClicked... which belongs to the template...

So if you need to change sthg in there, then override the method like this :

CheckboxTemplate.onToggleClicked = function(){
var value = this.getControlProperty("value");
this.setControlProperty("value", !value);
};

Beware that if you override this function, you should keep these two lines that are used to change the layout of the checkbox... Otherwise, they are not called.

Then you can add sthg like myData[i][j] = !value...

Hope this helps...

Now the second part of the answer that I am looking for, is how to have the grid load some checked and some not checked cells :
MyData[
[true,"val1"...
[false,"val2"...
...]

Any ideas?
Michel
November 29,
Michel Can u Show Me How To Set the checkBox Value Deslected while
loading itself . that means before even the first click .. all the check boxes
should be unchecked while loading itself
Josh
November 29,
Ok Josh,
here is what I have done so far :
According to me, or to my personnal use of the grid, I didn't need a template that is both checkbox + text... which shows text on the right hand side of the checkbox.

What I needed to have is a checkbox on the first column to be able to delete a row... so this checkbox appears empty at the initialisation.
To achieve this, I created a new template that I called Check, and removed in there most of the code from Checkbox template.

But for the initialisation process, I just send a myData array that has the following shape :

MyData[
["false","val1"...
["false","val2"...
...]


So far, this works fine : checkboxes are unchecked at page initialisation.
Hope this helps, otherwise ask for more, and check the following file : ActiveWidgets\source\lib\templates\checkbox.js

MY personnal question for all is :
On column 3, I have another checkbox template column used to display a field from database, and the field already has a value...

If I do something like :

MyData[
["false","val1", "true"...
["false","val2", "false"...
...]


Then the checkboxes have the unknown state, which is not my goal...
Should I loop on grid columns after initialisation to set individually all checkboxes that should be checked?
Anybody solved this?

Michel
November 29,
Michel,
I got it to work with an array: the grid loads some checked and some not checked checkboxes. Do you still need the code?

However, I can't figure out how to do the same thing when the data comes from an asynchronous xml table. The checkboxes get loaded with value "mixed".
lw
December 30,
Thanks lw, I read the post
/javascript.forum.10166.3/v2b3-setting-checkboxes-problem.html
And found there your answer,...

I had left this part on the side, but now, I will be able to continue this part of my dev...

Thanks for support
Michel
January 3,

This topic is archived.

See also:


Back to support forum