Hi,
I am using DHTMLX grid with radio buttons as first column in each row.
On selecting the radio button, I need to a call a javascript function.
How can i implement this?
Thank,
Sachin
You can use a code similar to next
grid.attachEvent(“onCheckbox”,function(id,index,mode){
// code here will be called each time when radio or checkbox clicked in grid
});
lazyGrid.setColTypes(“ro,ra,ch,ra,co,ed”);
“ra” is for column oriented radio button.
I need to have two radio buttons in the same cell.
like in HTML code,
Yes<input type=“radio”> No<input type=“radio”>
In such case you will need to create a custom column type, default one doesn’t allow such use-case
Also, if you are need to have one of two options selected - why not use a checkbox instead?
Stanislav you are right, but i need to create two radio buttons,
can u please guide me. how to create custom column.
Thank you.
Try
function eXcell_radioCell(cell)
{
if (cell)
{
this.cell = cell;
this.grid = this.cell.parentNode.grid;
}
this.setValue=function(val)
{
var row_id=this.cell.parentNode.idd;
var value = "<input type='radio' name='myradio" + row_id + "' value='0'/>";
value += '<br/>';
value += "<input type='radio' name='myradio" + row_id + "' value='1'/>";
this.setCValue(value);
}
this.getValue=function(val)
{
var row_id=this.cell.parentNode.idd;
return {value};
}
}
eXcell_radioCell.prototype = new eXcell;
and set cell type to ‘radioCell’
Thank you very much
function eXcell_radioCell(cell)
{
if (cell)
{
this.cell = cell;
this.grid = this.cell.parentNode.grid;
}
this.setValue=function(val)
{
var row_id=this.cell.parentNode.idd;
var value, value1, value2;
var cellIndex = this.cell._cellIndex;
if((val==‘Y’) || val==‘y’)
value = " Yes";
else
value= " Yes";
if((val==‘N’) || val==‘n’)
value1 = " No";
else
value1= " No";
value2 = value+value1;
this.setCValue(value2);
}
[b]this.getValue=function(val)
{
var row_id=this.cell.parentNode.idd;
return {value};
}[/b]
}
eXcell_radioCell.prototype = new eXcell;
In the above code i m not able to get the radio button value, that is Y or N
Thank You
Abhi
To get value of such custom excell try to use:
this.cell.firstChild.value
Thanks all for these, it has been very helpful indeed. I was just wondering where this piece of code should go to ‘this.cell.firstChild.value’ I assume this goes as the return value under the .getValue in the ‘eXcell_radioCell’ as in code below.
this.getValue=function(val)
{
var row_id=this.cell.parentNode.idd;
//return {value};
return this.cell.firstChild.value; // get button label
}
- When I have return{value} I get the following error on my scripts - Uncaught ReferenceError: value is not defined
- When I use return this.cell.firstChild.value; - I get a one irrespective on wether i select a Yes or No
Please, provide with a complete code of your exCell.
function eXcell_radioCell(cell)
{
if (cell)
{
this.cell = cell;
this.grid = this.cell.parentNode.grid;
}
this.setValue=function(val)
{
var row_id=this.cell.parentNode.idd;
var value = “Yes”;
value += “No”;
this.setCValue(value);
}
this.getValue=function(val)
{
var row_id=this.cell.parentNode.idd;
//return {value};
return this.cell.lastChild.value; // get button label
}
}
eXcell_radioCell.prototype = new eXcell;
Your code works well for me.
The excell is displaying well.
Could you pleas,e provide with a complete demo, where the problem can be reconstructed locally.
Here you can find a tutorial about creating a complete demo:
docs.dhtmlx.com/tutorials__auxil … pport.html