DHTMLX Docs & Samples Explorer

Radio Buttons Manipulation

Enabling/Disabling Radio Buttons

Enabling/Disabling Radio Buttons for Tree

dhtmlxTree supports radio buttons. To turn them on for the whole tree, the user should call the following method:

        tree.enableRadiobuttons(true); // false - disables radio buttons for the whole tree

This method should be called before data loading in the tree takes place.

Enabling/Disabling Radio Buttons for Items

There is the possibility to enable radio buttons for child items of a certain node in the tree. In this case, the checkboxes of these child items will be replaced by radio buttons:

        tree.enableCheckboxes(true); //enable checkboxes
        tree.enableRadiobuttons(true, itemId);  // enable radio buttons for child items of a certain node; false to disable

Enabling/Disabling Single Radio Mode

Method enableSingleRadioMode() changes radio buttons logic in the way that there can be only one checked radio button in the whole tree. To switch this mode on, the user should write the following code line:

        tree.enableSingleRadioMode(mode, itemId);

The parameters are:

  • mode(true|false) - whether single radio mode is enabled/disabled;
  • itemId - id of the item that will be checked.