[ 2 posts ]

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Default on button in button group

Post Posted: Thu Mar 15, 2012 3:48 am
+0-
Hi Satyam, may I request a configuration option for a button group of toggle buttons so that if I have a group of toggle buttons, I can default one of them to the 'on' state. Not sure exactly how this would work, currently I am doing something like this for a show hide columns dialogue on yui3 datatable:

buttonGroup = (new Y.ButtonGroup(
{
alwaysSelected : true,
children:
[
new Y.ButtonToggle({label:'Show'}),
new Y.ButtonSeparator(),
new Y.ButtonToggle({label:'Hide'})
]
}
)
).render(insertNode.one(".showhide_panel-pickerbtns"));


if(dataTableNode.one(".yui3-column-" + columns.keys[i].get("key")).hasClass("showHideColumn-Hide")) {

buttonGroup.item(2).set("selected",1);
buttonGroup.item(2).get("srcNode").addClass(buttonGroup.item(2)._classNames['selected']);

} else {

buttonGroup.item(0).set("selected",1);
buttonGroup.item(0).get("srcNode").addClass(buttonGroup.item(2)._classNames['selected']);

}

But I dont suppose this solution is ideal as it is not relying on any public methods!

Kind regards

Richard.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Default on button in button group

Post Posted: Thu Mar 15, 2012 6:30 am
+0-
I guess that you could do:

buttonGroup.item(2).fire('press');

which would simulate a key press, with all its consequences.

You might want to check this sample code, it is a very lightweight button set, it just plugs into Node so that you actually create buttons, toggles or groups via HTML and then tell this simple plugin to add toggling and grouping to those same nodes. It is very small, the following file contains the demo and the plugin itself which is a very small part of it. It relies on classes on the HTML itself to know which button is which. Then, you just use Node to do whatever you want with them.

http://satyam.com.ar/yui/3.5/button/usingATTRS.html



http://satyam.com.ar/yui/3.5/button/usingATTRS.html
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum