:: Forum >>

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 :

var checkbox = new AW.UI.Checkbox;
checkbox.onControlValueChanged = function(value){
alert("this one works fine");

var obj = new AW.UI.Grid;
var c0 = new AW.UI.Checkbox; //OR AW.Templates.Checkbox;
c0.onControlValueChanged = function(value){
c0.onItemClicked = function(event, i){
alert("here too")
c0.onControlStateChanged = function(value){
alert("here also")
obj.setCellTemplate(c0, 0);

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!
Saturday, November 26, 2005
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 :

Any ideas?
Tuesday, November 29, 2005
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
Tuesday, November 29, 2005
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 :


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 :

["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?

Tuesday, November 29, 2005
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".
Friday, December 30, 2005
Thanks lw, I read the post
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
Tuesday, January 3, 2006

This topic is archived.

Back to support forum

Forum search