I have a radio button:
Options: [null,"N","U"], displaying [All, New, Used] on the ui.
I can set the onAttach to widget.value = "N" or "U" and it works perfectly. If I set onAttach to widget.value = null, the UI has no selection.
How can I force the first option, "All" to always be selected onAttach?
Related
I have a boolean field for which I am using a radio group for which allowNull=true and no default value has been set. It currently looks like the below
I want the same to look like below (as I don't want to show the null option)
Note: Want to achieve this without changing the allowNull value and also without setting default value to true or false.
Adding the following to the onAttach event handler did the trick for me:
setTimeout(function(){
var elem = widget.getElement();
var children = elem.children[1];
var grandChildren = children.children;
var grandChild = grandChildren[0];
grandChild.parentNode.removeChild(grandChild);
},100);
i'm creating a x number of buttons runtime in this way:
btn is Control
btn <- ControlCreate(name,typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn..Caption = name
btn..Process[trtClick] = buttonAction
the buttonAction code is:
Info("You pressed: " + btn..Caption)
But the result of the buttonAction is always the last button name I create, for eg. I create a button named "Luca" and when I click it the result is: You pressed: Luca. Then i create a new button named "Antonio" but when I press "Luca" button the output is You pressed Antonio. How can I assign one button action runtime for every button?
Did you try to create a control per button ?
Where did you run the creation of the buttons ?
Like:
btn1 is Control
btn1 <- ControlCreate("test1",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn1..Caption = "test1"
btn1..Process[trtClick] = buttonAction
btn2 is Control
btn2 <- ControlCreate("test2",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn2..Caption = "test2"
btn2..Process[trtClick] = buttonAction
What result do you get ?
I don't have the last version of Windev for tests.
I'm afraid "btn" became shared to the windows when you use
<- ControlCreate
I was implementing a toggle button for a checkbox group in R Shiny today and I came across something interesting that I don't fully understand. My first approach to creating the toggle button was to write a javascript script that switched the checkboxes' checked attribute, so true became false and false became true, when the user clicked the button. This worked and when I ran the shiny app and pressed the toggle button, the checkboxes were flipped. However, if I displayed the selections, using renderText(), shiny did not react to my changes. If, however, I clicked one of the checkbox groups Shiny would update to the appropriate checkboxes.
I then changed my javascript code so that instead of setting the checked attribute, it used jQuery's .click() to click each checkbox. This approach worked exactly as I hoped so that when I pressed the toggle button, the checkboxes were flipped and the text was updated. I'm curious to know why this is though. My suspicion is that shiny listens for click events but can't listen for attributes that are changed programmatically. My explanation isn't too great so I created a small shinyapps app demonstrating the difference in the toggle button behavior. The first toggle button uses .click() and works and the second one uses the checked attribute and does not update reactively. The code I used to demonstrate the differences is below:
ui.R
library(shiny)
fruit = c("apple", "banana", "orange", "pear", "peach")
shinyUI(fluidPage(
tags$script(src = "toggle_button.js"),
titlePanel("Test"),
sidebarLayout(
sidebarPanel(
checkboxGroupInput("fruit_list",
"Select a fruit",
choices = fruit,
selected = fruit),
fluidRow(
actionButton("toggleButton_1", "Toggle 1"),
actionButton("toggleButton_2", "Toggle 2")
)
),
mainPanel(
textOutput("string")
)
)
))
server.R
library(shiny)
shinyServer(function(input, output) {
output$string <- renderText({
paste(input$fruit_list, sep = ", ")
})
})
www/toggle_button.js
$(document).ready(function() {
$("#toggleButton_1").click(function() {
var fruit_boxes = $("#fruit_list :checkbox");
for (var i = 0; i < fruit_boxes.length; i++) {
fruit_boxes[i].click();
}
});
$("#toggleButton_2").click(function() {
var fruit_boxes = $("#fruit_list :checkbox");
for (var i = 0; i < fruit_boxes.length; i++) {
fruit_boxes[i].checked = !fruit_boxes[i].checked;
}
});
});
If you're interested in diving into how shiny javascript works, one good resource is how to build custom input objects.
After reading that and learning how to write an input, you'll understand the code for the checkbox input. Look specifically at the subscribe function: it tells javascript to call shiny with "hey, I just updated!" when the "change" event gets triggered. So that's your answer: the change event is triggered when you manually click on an input (or using jquery click achieves a similar result), but when you simply change the value manually, the event isn't triggered.
You can test this by adding your own callback on change, and seeing that the change event only gets triggered with a click but not with a manual value change. To take this one step further, this means you can manually tell shiny to update the value by calling $(".checkbox").trigger("change"). Try adding that line after changing the value , and now it'll work (though I wouldn't do this, it's for illustration purposes)
I want the validation for kendo AutoComplete when user does not select any value from AutoComplete Value that is populated.
For Little Bit background say I do have two controls one as Kendo AutoComplete and other is Input box if user types something in the AutoComplete the values is populated and he does not select any value and switch to next control it must give a validation message that please select the value from the AutoComplete.
and Also if the user type any string in the AutoComplete and Switch to next control it must also give the validation that "hey,this value is not in the AutoComplete" so that it must not save any other data other than AutoComplete datas that is being Populated.
Heres how your auto complete is defined
#(Html.Kendo().AutoComplete()
.Name("countries")
// etc.
On submit button click event
<script>
$("#btnSubmit").click(function(){
var autoCompleteValue = $("#countries").val();
if (autoCompleteValue == "" || autoCompleteValue == null){
return false; //cancels submit action
}
// else let submit go through
});
</script>
The null check is probably useless, cuz if it doesn't have a value it's usually equal to ""
The .val() solution did not work for me, because the .val() value of the control is still the text I entered (custom text, not any of the AutoComplete values), and that's wrong.
Solution is in preventing the custom input of Kendo AutoComplete. See this link:
Kendo UI - Prevent Custom User Input in the AutoComplete
I am using Flex3.0. in this i am craeting a custom component for an Alert.and for that alert i am applying styles. but when i opening the alert through the application i want to set focus on Alert button.means when i press enter button there are two buttons in alert YES and NO.i need to focus on YES button. any one help me if any reffer url also please provide me
Thanks,
Praveen
you need to set the defaultButtonFlag: (its the last parameter)
Alert.show('alert', 'alert', Alert.NO|Alert.YES, this, null, null, Alert.NO);
From the APIDocs:
show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4):Alert
[static] Static method that pops up the Alert control.
In a regular Alert.show call this means you can specify the last argument as Alert.YES to make it the default selection. With a custom component, you can call setFocus() on the particular element within your custom Alert component that you want to select (i.e.: in call setFocus() within the custom Alert component's creationComplete event).
So a sample implementation of a YES/NO Alert box would be (split code over two lines to avoid scroll bars):
Alert.show("sample text","sample title",
Alert.YES|Alert.NO,null,null,null,Alert.YES);
Hope this helps.