-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for default items appears to be invalid #52
Comments
What version of ionic are you using? I've been trying to get an example
project using the version below, but am getting error messages when
installing the native plugin. Might be they (ionic native team) have
recently changed something.
Ionic:
Ionic CLI : 5.0.3
(/usr/local/lib/node-v10.15.3-linux-x64/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.5.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 8.1.2 ([email protected])
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (1 plugins total)
…On Wed, Jun 12, 2019 at 9:46 AM Robert Thompson ***@***.***> wrote:
I was having trouble with defaultItems crashing my app, and found out the
docs seem wrong?
Docs here
<https://github.com/jasonmamy/cordova-wheel-selector-plugin#default-items>
show this:
var config = {
title: "Select something",
items:[
[data.numbers],
[data.fruits]
],
defaultItems: [
//the number '2'
{index:0, value: data.numbers[2]},
//the value 'Pear'
{index:1, value: data.fruits[2]}
]
};
But I couldn't get it working until I tried this:
var config = {
title: "Select something",
items:[
[data.numbers],
[data.fruits]
],
defaultItems: {
0: data.numbers[2].description,
1: data.fruits[2].description,
}
};
Am I missing something? I'll roll with what's working now, but I'm
concerned something else is awry.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#52?email_source=notifications&email_token=ACPVJRUN2KCZEJYLWCCCIELP2ER5PA5CNFSM4HXLDEMKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZDTXIA>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACPVJRQE7QTQ2JDI5BJ2M4TP2ER5PANCNFSM4HXLDEMA>
.
|
My info is below, but it's pretty unrelated ionic for me. I'm not using anything ionic related to invoke
|
I'm having issues with setting the default value as well using Ionic for Android. Here's my
I've tried to use the way the docs show:
And the way it seems to works for others:
The caveat is for me I only have 1 item in my item list instead of 2. If anyone has any suggestions please let me know. |
Can you try with more than 1 item in the list and see if that works? It's
possibly a bug with only having 1 item in the list?
Thanks, Jason
…On Mon, Jun 8, 2020 at 12:14 PM David Quon ***@***.***> wrote:
I'm having issues with setting the default value as well using Ionic for
Android. Here's my ionic info.
Ionic:
Ionic CLI : 6.10.0 ***@***.***/cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0
Cordova:
Cordova CLI : 9.0.0 ***@***.***)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.0, (and 17 other plugins)
Utility:
cordova-res : not installed
native-run : 1.0.0
System:
Android SDK Tools : 26.1.1 (/Users/DQ/Library/Android/sdk)
NodeJS : v10.20.0 (/Users/DQ/.nvm/versions/node/v10.20.0/bin/node)
npm : 6.14.5
OS : macOS Catalina
Xcode : Xcode 11.5 Build version 11E608c
I've tried to use the way the docs show:
defaultItems: [
//the number '2'
{index:0, value: data.numbers[2]},
]
And the way it seems to works for others:
defaultItems: {
0: data.numbers[2].description,
}
The caveat is for me I only have 1 item in my item list instead of 2. If
anyone has any suggestions please let me know.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPVJRXG7SRNGEHDGVSKEHTRVUZ7PANCNFSM4HXLDEMA>
.
|
So I tried these without it working with
Then I tried this and it worked:
And then I tried this and it worked:
So the Thanks for the great plugin @jasonmamy and support. 👏🍻 |
So to summarize, the docs are ok and we don't need to update them?
Thanks!
…On Wed, Jun 10, 2020, 5:35 PM David Quon ***@***.***> wrote:
So I tried these without it working with items: [entries, entries],:
defaultItems: { "0": item.displayValue, "1": item.displayValue },
defaultItems: [{ "0": item.displayValue , "1": item.displayValue }],
defaultItems: [{ "0": item.displayValue }, { "1": item.displayValue }],
Then I tried this and it worked:
items: [entries, entries],
defaultItems: [
{ index: 0, value: item.displayValue },
{ index: 1, value: item.displayValue }
],
And then I tried this and it worked:
items: [entries],
defaultItems: [
{ index: 0, value: item.displayValue }
],
So the tldr; is that it seems that the documented way of setting
defaultItems for Ionic works as specified in the documentation. Not sure
why it didn't work for me the other day though as I'm nearly 💯 I tried
this. ¯_(ツ)_/¯
https://ionicframework.com/docs/native/wheel-selector
Thanks for the great plugin @jasonmamy <https://github.com/jasonmamy> and
support. 👏🍻
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPVJRQ4PDRIEURAAVJ7UR3RWARGRANCNFSM4HXLDEMA>
.
|
Correct. I can confirm with these versions:
using Ionic version
Thanks for the support @jasonmamy. 👍 |
I also have the same issue reported at the beginning of this issue. I'm using version 1.1.7 of this plugin on iOS. After debugging into the Objective-C code, I found that in this segment https://github.com/jasonmamy/cordova-wheel-selector-plugin/blob/1.1.7/src/ios/SelectorCordovaPlugin.m#L50-L58 if (defaultItems) {
NSString *value = [defaultItems objectForKey:columnIndexString];
NSUInteger index = [[_items objectAtIndex:columnIndex] indexOfObject:value];
if (NSNotFound != index) {
initialValueIndex = index;
}
}
[_itemsSelectedIndexes setValue:@(initialValueIndex) forKey:columnIndexString];
[_pickerView selectRow:initialValueIndex inComponent:columnIndex animated:NO];
defaultItems: [
'0': this.jsonData.numbers[2].description},
'1': value: this.jsonData.fruits[3].description}
] |
On Android, using the same code, I can only get the second item showing the default value correctly. I tried to debug into the Java code but can't seem to find anything helpful. When I revert to the documented way to set |
@edmondchui I have the same issue, did you figure it out on Android? |
I can confirm the only way to make it work on Android is to provide a JSON object, not an array of objects.
|
I was having trouble with
defaultItems
crashing my app, and found out the docs seem wrong?Docs here show this:
But I couldn't get it working until I tried this:
Am I missing something? I'll roll with what's working now, but I'm concerned something else is awry.
The text was updated successfully, but these errors were encountered: