Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Anna on Jan 07, 2009 03:14
open dhtmlx forum
How add radio button in a grid

Hello everybody, I'm a newbie so...please be gentle with me :-)
I need to add a radio button with two different values in a row at the top of the grid. Can you help me please?
I have this code:

Grid g = new Grid();

    
        //create the Columns of the Grid
        Column c1 = new Column("70","center","img","str");
        c1.setSort("na");
        c1.setEditable("false");
        Column c3 = new Column("*","left","combo","str");
        c3.setBody("Settore");
        c3.setAutoAttribute("true");
        c3.setSourceAttribute("BfuComboDataProvider");
        c3.setCache("true");
        c3.setSub("true");
        c3.setEditable("false");
        Column c4 = new Column("70","right","edtxt","str");
        c4.setBody("BUF");
        
        Command cellEdit = new Command("setOnEditCellHandler","doOnCellEdit");
        AfterInit afterInit = new AfterInit();
        afterInit.addCommands(cellEdit);
        
        String ico2 = "<img id='saveicon' src='img/icons/ok.png' alt='Conferma' onclick='saveBfuUpdates();' style='margin:2px;cursor: pointer;'/>";
        String ico3 = "<img src='img/icons/new.png' alt='Aggiungi Settore' onclick='addBfuFromIcon();' style='margin:2px;cursor: pointer;'/>";
        c1.setBody("<div style='color: black;text-align: left;'>" + ico2 + ico3 +"</div>");
        g.addHeadElements(c1,c3,c4);
        
        Settings settings = new Settings("px");
        
        g.addHeadElements(settings,afterInit);
Answer posted by Support on Jan 07, 2009 16:20
The syntax which you are using differ from standard one, are you using some kind of wrapper around dhtmlxgrid?

In common case the type of each cell can be defined by column type, so for "ra" column - all data will be rendered as radio buttons.
If you need to have two radio buttons in the same cell - you need to create a custom excell with such functionality , or use native HTML inputs as

<cell type="ro"><![CDATA[
First <input type="radio"> Second <input type="radio">
]]></cell>