Bi-Directional binding to radio button within a radio group -> Max Call Stack - qooxdoo

I'm getting Uncaught RangeError: Maximum call stack size exceeded exception if i try to make a bidirectional binding between a property and a radio button.
I created a playground example: tinyurl.com/hfl9gy8
If I try to toogle the property by the toggle button I am getting the exception. This happens only from true to false. false to true works perfectly.
Is it a bug or did I miss something?

If you have several qx.ui.form.RadioButtonsand add them to a qx.ui.form.RadioGroup with default properties, then the group manager enforces that exactly one radio group item hast to be selected.
So if you take only one radio button from the group, in your playground sample the radio button labeled red, and set it to false, then the group manager does not allow that, because then there would be no selection (neither red nor green) at all. Deselecting the red radio button does not mean that the green one will be selected automatically.
Binding only one boolean value (false/true) to only one radio button in a radio group does not work here.
You could set the property allowEmptySelection to true for the qx.ui.form.RadioGroup, which will make your playground sample work, but only by deselectong and selecting the red button, having no button selected at all in the radio group.
Conclusion: a radio group is not something you could "toggle".

Related

ExtJS - RadioGroup shows two selected items except one

Dears,
I have implemented a pop-up window to be shown by clicking a trigger-button of a textbox, and it has a radioGroup in it. in some cases I have to check the radio based on user input.
The problem is that if I try to invoke radioGroup.setValue() before opening the popup once, I face with two selected items in radioGroup. The issue doesn't occur if open-close the popup before trying to set the checked radio.
Is it a rendering issue or something like that?!

How to get the selected radio button in the Kendo Grid

I have a kendo grid with a column consisting of radio buttons.
I want to make the radio buttons act as radio buttons(check only 1) and get the selected 1.
Here is a sample Demo
You were pretty close. First a few things about radios:
Radio buttons are grouped using the name attribute
Radio buttons are bound to labels via the for attribute on the label element matched with the id attribute on the radio button
The problem with your code is that all radios have the same id, which is why clicking any radio button toggles the first one ... because the first element found with that id is grabbed, with the assumption that there'd only be one.
In order to fix this, you need a unique id for each radio button, and you can do that by referencing the EmployeeID in the data source using the #: EmployeeID# notation, as exemplified in the docs
Therefore your template would look like this:
template: '<input type="radio" name="customer" id="customer_#: EmployeeID#" class="k-radio"><label class="k-radio-label" for="customer_#: EmployeeID#"></label>'
Please find working example here: https://dojo.telerik.com/aRuQubep/5
Hope this does the job :)

Enable/Disable button based on checkbox input via GroupBox

Could someone point me in the right direction on how to enable/disable a button when at least one checkbox is checked in each group box.

Difference between togglebutton and radiobutton controls in xaml?

I am a newbie to the programming. So I am always confusing the differences between these controls.Difference between Togglebutton and Radiobutton controls in Xaml?
Let's take a real example for this
Toggle Button: As the name suggest a button whose state can be toggled from on to off or vice-versa. For example a Switch in your home to turn a particular light on or off.
Radio Button: Its name comes from the concept of buttons in Radio where for first station you press first button and for second station you press second button and so forth. So you can choose from multiple options. But at a time only one will be selected.
Toggle Button : Like you can use ON/OFF [Change between states]
Radio Button : Select one from list [Select one from group of option]
ToggleButton has two positions right and wrong, but for multiple
RadioButton with the same Groupname property, only one can be true at a time.
If radio button and toggle button are not part of the toggle group, their behaviour is same.
If radio button and toggle button are part of the toggle group, radio buttons can’t be deselected, but toggle button can.

Implementation of menu buttons in WPF/MVVM/Prism

I have a Region in the top left of the WPF application which I want to be my global button bar where the user chooses which screen they want to view, and the appropriate content will then be displayed in the main region. THere will also be a sub navigation region in the top right with sub-menu options within that screen, eg if the user clicked "Maintenance" from the main menu, the sub menu would show options for New, Update, Delete, Edit etc.
What I want to have is a way to create a custom menu bar by simply specifying a list of Text button names, and ICommand/Parameter pairs for the action to invoke on button click. The natural way to do this would be have a MenuButtonViewModel class with dependency properties Title, Command and CommandParameter. One more would also be needed, IsSelected, so there is some visual way for the user to see which screen you are currently on, so it needs to behave like a toggle button, but where only one button in the group can be selected at a time. I can then have a UserControl where the content of the bar binds to an ObservableCollection and uses data templates to render the button bar.
I have tried a few ways of doing this so far but cannot figure out a way that gives me the visual behaviour I want. These are my requirements
1) Button to change background to a different Brush OnMouseOver
2) When button is selected, a different Brush is displayed as the background until a new button in the group is selected, like a togglebutton IsSelected behaviour
3) Only one button in the group can be selected at a time
The ways I have tried to do this so far are
1) Extending RadioButton with my own class, adding dependency properties for command and commandparameter. Setting all controls to have the same group Id. Data template to override display of radio button to make it look like a visual button with triggers for mouseover and isselected.
This works fine, except for one thing. Once you select a radio button in a group, there is no way to deselect all options in the radio button group. So if you navigate to "maintenance" and then click the sub menu for "Countries" for example, then you are displayed the country maintenance screen. If you then go to a different area of the app and select "Deal Entry" from the main menu, you are taken to the deal entry screen. If you then click "Maintenance", it displays the generic "maintenance" content and brings back the sub menu control for maintenance, where "Country" is selected in the radio button group, but this is undesirable. When you navigate back to Maintenance, it should deselect all sub menu options, display the generic maintenance landing page content and let you select a sub menu option before displaying that screens content. The first time you load Maintenance, nothing is selected, but once you have chosen an option, then there is no way to have nothing selected again when you reload the maintenance screen.
2) I then tried extending a ListBox, styling it with a horizontal stackpanel for the content, each listboxitem is a menubuttonViewModel. This allows me to only select a single option at a time and to clear the selection when you navigate away from the page. It also lets me change the background when you mouse over each listboxitem.
The bit I can't get working with the listbox is to have the background different on the IsSelected trigger. There seems to be some trigger on the default ListBoxItem template that overrides anything you specify in CSS so no matter what trigger I put on the listboxitem or menubuttonviewmodel style, the background simply does not change. I think I need to redefine the data and content template for listboxitem, but only have it apply for this listbox, so it can't be a global template change to all listboxitems - as I want to be able to use listboxes elsewhere in the app without inheriting this behaviour.
Can anyone give their thoughts on these two approaches and how to perhaps solve the issues I'm having to make one of them work in the way I want, particularly if you can advise how I can override the content/data template for the listboxitems in my style so they do not use the default triggers, and I can get the IsSelected trigger working for me?
If I understood correctly, you would want to clear the selection on the RadioButtons from the Sub-Menu each time you navigate back from another Main Menu option.
In order to solve this, you could have every Radio Button "unchecked" by manually setting the RadioButton´s IsChecked property value to false. A possible solution could be the following:
If you want to clear any checked option from the Sub-Menu everytime you navigate to a different section of the Main Menu, you could first notify to the Sub-Menu´s ViewModel by publishing an event using the EventAggregator after selecting and clicking a different MainMenu button, from the SelectionChangedEventHandler method of the Main Menu´s ViewModel.
Therefore, the Sub-Menu EventHandler of the published event would update each RadioButton´s IsChecked property value to false, which it could be accomplished by using a "Two-Way" Binding between each IsChecked property defined on the View, and each boolean "RadioButton1IsChecked" property implemented on the ViewModel.
I hope this helped you.

Resources