According to the documentation it is possible to:
In the XML markup, add the if attribute to an element and assign it to the property passed to the createController() method. Prefix the property name with the $.args namespace. Based on the property passed to the method, the application displays a different label.
So this means that if I put:
<Label if="Alloy.Globals.property" color="blue">Foobar</Label
Wont work?? Right now I´m not using the createController method, because it is added on the XML by a Require tag. Is there any way to do this?
As you can see in the docs there are some examples.
One of which:
<Alloy>
<Window>
<Label if="$.args.fooBar" color="blue">Foobar</Label>
<Label if="$.args.fooBaz" color="red">Foobaz</Label>
</Window>
</Alloy>
So yes, this will just work. As long as the property you provide is already set when rendering. Once your variable changes while the view is open it won't update it. For that you'll need data binding
Related
I need to use wicketstuff's StatelessAjaxSubmitLink but I can't find any way to customize the default label ("Submit Query"). The class does not inherit a setLabel() method. Is there a way how to get around this?
I guess you're looking for setBody.
UPDATE
If you are using your component with a HTML tag <input type="submit"/> , than you should use value attribute to set you desired label. In Wicket use AttributeAppender:
yourLink.add(AttributeAppender.append("value", "foo bar"));
See https://ci.apache.org/projects/wicket/guide/7.x/single.html#_modifing_tag_attributes
I believe I already know the answer to this, but in kendo are you able to bind a DOM element's visibility to the opposite of if a value in the observable is null or false?
For example: the normal behavior is to show a <div> that has content the user needs to manipulate as part of a "step". I want to give the user the option to skip this step. To do this, I add a checkbox that says "skip" and in it I bind its value to the property IsSkip:
<input id="checkbox-allow-skip" type="checkbox" data-bind="value: IsSkip" />
Can I then bind the <div>'s visibility to the opposite of IsSkip like this (pseudo code for data-bind):
<div id="optional-step" data-bind="visible: !IsSkip">
<!-- ... -->
</div>
Edit - I believe that it may be worth noting that currently I'm generating the onchange event of the checkbox and setting the value of a new property named CannotSkip to the opposite of IsSkip and binding the visibility to CannotSkip.
As you're probably already aware, you can't invert the value of the property within your binding expression as per your pseudo code due to the way the binding is constructed. However, the visible reference which appears in the binding expression is not a reference to a DOM attribute, it's actually a reference to a kendo binder which has a counterpart, the invisible binder which inverts the value for you. Hence the simplest solution to your problem is just this:
<div id="optional-step" data-bind="invisible: IsSkip">
<!-- ... -->
</div>
Eventually however, you're sure to encounter a situation where this won't solve the problem for you e.g. perhaps the visibility depends on the state of several flags? This type of scenario is best handled by binding to a function instead where you can execute whatever logic is necessary. The most important thing to remember when you use this approach is to manipulate any properties of your view-model using the get and set methods of the observable object. This ensures that any bindings to your function will be refreshed when any of those properties change; in kendo parlance this is known as a dependent method. You could solve your problem using this approach, like so:
var viewModel = kendo.observable({
IsSkip: false,
CannotSkip: function() {
return !this.get("IsSkip");
}
});
<div id="optional-step" data-bind="visible: CannotSkip">
<!-- ... -->
</div>
I'm trying to setup a RadioGroup component that has the Radio component with the 'Data' label initially checked. But when I use the following code:
<RadioGroup
onChange={(e) => {
this.store.setDataFilterSelection(e.target.value)
}}
>
<Radio label='Data'
defaultChecked
value='1'
className='radio-selectors' />
<Radio label='Description'
value='2'
className='radio-selectors' />
<Radio label='Data Source'
value='3'
className='radio-selectors' />
</RadioGroup>
I get the following warning in my console.
Blueprint.Radio contains an input of type radio with both checked and
defaultChecked props. Input elements must be either controlled or
uncontrolled (specify either the checked prop, or the defaultChecked
prop, but not both). Decide between using a controlled or uncontrolled
input element and remove one of these props. More info:
react-controlled-components
I've tried a couple of variations and can't seem to get it right, basically I want to be able to monitor a change in the Radio buttons, but I can't tie them into state as they've done in the example here: http://blueprintjs.com/docs/#components.forms.radio
defaultChecked is only supported in uncontrolled usage (this is a core React concept, not a Blueprint thing), whereas checked is only supported in controlled usage--this is what the React error is telling you.
But if you're using RadioGroup then all the Radio children are forced into controlled mode and all state should go through RadioGroup. However RadioGroup does not currently support a defaultValue prop so this is not actually possible. I'd call this a bug in Blueprint, so good find!
Please file an issue on the repo and we'll look into implementing this (or even better, submit a PR with the fix!)
I had same error and I used useState and set the value which we want to be default while declaring the state like
const [radio, setRadio] = useState('defaultValue');.
Since we cant use defaultChecked I used the above method to get the option to be default checked.
I cannot make working binding with ListView and template.
<ListView #userListView [items]="usersViewList" (itemTap)="onItemTap($event)">
<template let-user="item" let-i="index">
<GridLayout columns="auto">
<Label [text]="user.name" col="0"></Label>
</GridLayout>
</template>
</ListView>
at cration time user.name is assigned properly, but later if I call.
user.name = "other name";
Nothing happens.
Binding context is set to item in usersViewList correctly. But no changes are propagated to individual list item ever.
Thank for advice!
You can't call user.name "later" (guessing in your code behind component file?).
If you need to access the tapped item you can use the index of the tapped item and then you can grab it from your items array like
usersViewList[index].name
You have also itemTap which provides you with arguments where you8 can directly access the tapped index like show here
The best practice, in this case, is to compare your code with a sample that demonstrates the exact same case. Here you can find one. And many other examples are posted in this section of the same application.
When value of hasMoreCategories got as YES, apex:selectList controller is successfully rendered. But that will not execute loadValuesWithCategor method that comes under the apex:actionSupport. Does anyone have some idea about this issue? Code is as follow.
<!-- Panel for display category relate information -->
<apex:outputPanel id="categoryPanel">
<apex:outputLabel value="Category" rendered="{!hasMoreCategories=='YES'}" />
<!-- ControllerSRAndTesting: category -->
<apex:selectList label="Category" id="categoryList" value="{!categoryValue}" rendered="{!hasMoreCategories=='YES'}" size="1">
<apex:selectOptions value="{!jobCategorValues}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!loadValuesWithCategor}" rerender="itemsReqPageBlock, footer" />
</apex:selectList>
</apex:outputPanel>
Question : can you verify from the debug log that the 'loadValuesWithCategor' method is definitely not being executed when the selection is made?
Without knowing what the rest of your page looks like, it is difficult to know what the problem might be. You could have a required field on the screen that is not populated with the picklist selection is made and that could cause this type of problem.
I my self done some mistake, that is why that code has been behaved like that manner. That mean I have reset the value of hasMoreCategories as NO within loadValuesWithCategor method. Therefore even it was rendered due to value of rendered option is false , apex:selectList component does not existing on the UI. Thanks.
If you wants to call the methode by actionSupport do below task.
Remove "transient" from a declaration of a selectoption list.
Remove immediate attribute.