Get the picker value when another button is pushed - titanium

This is my index.xml
index.xml
<Window>
<Picker id="picker" type="Ti.UI.PICKER_TYPE_DATE" selectionIndicator="true" top="100"></Picker>
<Button id="button" onClick="clickSelDateBut" title="決定"
top="350" width="100" height="50" />
</Window>
I would like to get the picker value when button is clicked
For now my source code is here.
index.js
$.picker.addEventListener('change',function(e){
selDay = e.value.getDate();
selMonth = e.value.getMonth() + 1;
selYear = e.value.getFullYear();
});// keep the data when 'change' event happens..
function clickSelDateBut(e){
//using selDay selMonth selYear here
}
However,it's not cool.
I think I should pick up the data from picker when the button is clicked.
How can I make it?

If u want some button to be clicked and get its value then do something like this
$.button.addEventListener('click',function(e){
selDay = picker.value.getDate();
selMonth = picker.value.getMonth() + 1;
selYear = picker.value.getFullYear(); });
})

Related

Ionic 4 - How can I programmatically clear ion-searchbar?

I work with ion-searchbar on Ionic 4.
I would like to know how I can clear the content, if the user clicks on any other button (not the cancel button).
<ion-searchbar id="name_of_searchbar" animated placeholder='search' (ionChange)="buscar($event)">
</ion-searchbar>
In the function (any another button), I try with: document.getElementById ("name_of_searchbar"). innerHTML = "";
but although it modifies the content, it also removes the ion-searchBar
Thank you!
Add in search bar [(ngModel)]="searchValue"
<ion-searchbar [(ngModel)]="searchValue" animated placeholder='search' (ionChange)="buscar($event)">
</ion-searchbar>
And in ts file:
export class PageName {
searchValue:string;
constructor(){}
clearSearch(){
this.searchValue = "";
}
}
In the button you want the user to clear text with , put inside the button click example :
<ion-button color="primary" (click)="clearSearch()">empty search</ion-button>

Xamarin picker, not setting default value

I've got a picker on the screen, that has an initial value, as well as the option to change the item in the picker.
While my selectedItem is set, I don't see that on the picker on the screen, the picker has no value set, and it's not until I select a value, that it actually displays something in the picker on the screen (At this time the SelectedItem is also updated with the new value).
My xaml:
<Picker
ItemsSource="{Binding FeedbackTypes}"
SelectedItem="{Binding SelectedFeedbackType, Mode=TwoWay}"
ItemDisplayBinding="{Binding Name}">
</Picker>
My ViewModel properties:
private ValueName _selectedFeedbackType;
public ValueName SelectedFeedbackType
{
get { return _selectedFeedbackType; }
set
{
_selectedFeedbackType = value;
OnPropertyChanged(nameof(SelectedFeedbackType));
}
}
public ObservableCollection<ValueName> FeedbackTypes
{
get
{
var feedbackTypes = new ObservableCollection<ValueName>();
foreach (FeedbackType feedback in
Enum.GetValues(typeof(FeedbackType)))
{
feedbackTypes.Add(new ValueName
{
Value = feedback,
Name = feedback.ToName()
});
}
return feedbackTypes;
}
}
And in my ViewModel constructor I've got:
SelectedFeedbackType = new ValueName { Value = feedbackType, Name = feedbackType.ToName() };
The constructor works sets the SelectedFeedbackType correctly and if I don't make any changes to the picker, that is the value I get in there on submit, however, I do not see that value in the picker by default. The picker is empty until a selection is made.
I've also tried to bind the SelectedIndex value to the SelectedFeedbackType, however that one will not show the initially selected value either in the picker.
You could try to set defalut value of the Xamarin Picker.
You just set the selectedIndex(the first number of index is 0) of your picker like the following code.
Mypicker.SelectedIndex=1;
There is a code of demo.
GIF of demo when first running.
You can download this demo by the link.
https://developer.xamarin.com/samples/xamarin-forms/UserInterface/PickerDemo/
Then changed the code of MonkeysPage.xaml.
<Picker x:Name="Mypicker" Title="Baboon" ItemsSource="{Binding Monkeys}" ItemDisplayBinding="{Binding Name}" SelectedItem="{Binding SelectedMonkey}" />
Add the defaule value of Pickerin MonkeysPage.xaml.cs.
public MonkeysPage()
{
InitializeComponent();
BindingContext = new MonkeysPageViewModel();
Mypicker.SelectedIndex=1;
}
}

I cannot call another screen when I click on the image

I have two images to simulate the click on the button, but I want is when clicking the image and change call another screen. And the process does not happen because the application is stopping
<StackLayout>
<!-- Place new controls here -->
<Image Source="botaocadastrolivre.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{
tapCount++;
var imageSender = (Image)sender;
// watch the monkey go from color to black&white!
if (tapCount % 2 == 0)
{
imageSender.Source = "botaocadastrolivre.png";
}
else
{
imageSender.Source = "botaocadastroPresed.png";
Navigation.PushAsync(new Nova());
}
// Task.Delay(100)
//Navigation.PushAsync(new Nova());
}
Go to your App.xaml.cs file, find the line that says something like:
MainPage = new MainPage();
and change it into:
MainPage = new NavigationPage(new MainPage());
This will wrap your page into a navigation page and then the Navigation object will know how to navigate from one page to the other.
It might be wise to read up on navigation concepts in Xamarin.Forms: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/

How to get listbox column text with xul

I am new with xul,
I want to know how to get listbox column text with xul,
I search about listbox method and property, but I can't find about that
please help!
Thanks a lot!
You can see the reference page listbox - XUL
If you want to get the selected item, there is a property of the listbox called selectedItem that will return it.
Your listitem can be composed with multiple elements.
<listbox id="list">
<listitem class="listitem">
<listcell class="column1" value="value1" width="100"/>
<listcell class="column2" value="value2" width="100"/>
</listitem>
</listbox>
If you give this elements a class, you can access them doing the following:
var list = document.getElementById("list");
var listItem = list.selectedItem;
var column1Value = listItem.getElementsByClassName("column1")[0].getAttribute("value");
var column1Value = listItem.getElementsByClassName("column2")[0].getAttribute("value");

Flex 3: Hiding elements created by repeater

I have a repeater that creates a custom component named "Block." I need to make it so that when the user clicks a button, all of the blocks created by the repeater have their visible field set to false (and then true when the button is clicked again).
Here's some of the code I have right now:
<mx:Repeater id="indPositions" dataProvider="{projectPositions}" startingIndex="0">
<components:block height="24"
width="100%" id="thisBlock" visible="true" horizontalScrollPolicy="off"
oneDay="{oneDay}"
/>
</mx:Repeater>
Here's the button the user will click to show/hide the blocks:
<mx:Button id="showHideButton" label="Show Project" x="{addBlock.x + addBlock.width + 2}" click="showProjectSwitch();" />
Here's the function showProjectSwitch():
public function showProjectSwitch():void {
if (showHideButton.label == "Hide Project")
{
showHideButton.label = "Show Project";
indPositions.visible = false;
thisProject.height = 65;
}
else
{
showHideButton.label = "Hide Project";
indPositions.visible = true;
thisProject.height = projectHeight ;
}
}
I tried setting projectRP.visible="true/false", but it didn't work :(
I also tried wrapping a canvas around the repeater, but when I did that... the repeater only ran once despite the fact I have the startingIndex="0" and the count="16". I then removed the canvas tags and the repeater ran the correct number of times.
Anybody able to help me out?
The easiest way to achieve what you want is just to use databinding, same as you did for the "oneDay" value.
<mx:Repeater id="indPositions" dataProvider="{projectPositions}" startingIndex="0">
<components:block height="24"
width="100%" id="thisBlock" visible="true" horizontalScrollPolicy="off"
oneDay="{oneDay}"
visible="{showBlocks}"
/>
</mx:Repeater>
<mx:Boolean id="showBlocks" />
[Edit for additional clarity]
To change the visibility of the blocks, you need to set the value of showBlocks, like so:
showBlocks = true;
or
showBlocks = false;
Here's how i solved it... since the variable name of "thisBlock" is declared every time a block is made, all that information gets stored in an array. After learning this, i was able to create a for each loop in a function that was called when the show/hide button was pressed... the for each loop goes something like this:
for (var I:int = 0; i < dataprovidername.length; i++)
thisBlock[i].visible = true/flase;
Hope that can help somebody else out in the future.