EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: agulas on June 28, 2013, 12:28:39 AM



Title: Button group help
Post by: agulas on June 28, 2013, 12:28:39 AM
I'm new to javascript and easyui and I run into this little problem when using easyui to build some webpages.
I wanna use the  Button Group extended from linkbutton.
and the code is like this:

<a href="javascript:void(0)" class="easyui-linkbutton" data-options="toggle:true,group:'g1',plain:true" iconCls="icon-redo" onclick="someMethod()" id="g1left">toggle1</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="toggle:true,group:'g1',plain:true" iconCls="icon-undo" onclick="someMethod(2)" id="g1right">toggle2</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true" iconCls="icon-redo" onclick="someMethod(3)" id="g2left">toggle3</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="toggle:true,group:'g2',plain:true" iconCls="icon-undo" onclick="someMethod(4)" id="g2right">toggle4</a>



and what i wanna do is, when click different button, I can filter different data to the datagrid.
So my question is how do I get which button is selected in the two button groups?
I tried some js code and they didn't work.


Title: Re: Button group help
Post by: stworthy on June 28, 2013, 07:10:44 AM
Retrieve the 'selected' property to get what buttons is pressed.
Code:
$('a.easyui-linkbutton').each(function(){
var opts = $(this).linkbutton('options');
if (opts.selected){
console.log(opts.text + ' selected');
}
});