Open rthomps7 opened 5 years ago
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 (cordova-lib@8.1.1) Cordova Platforms : none Cordova Plugins : no whitelisted plugins (1 plugins total)
On Wed, Jun 12, 2019 at 9:46 AM Robert Thompson notifications@github.com 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 https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/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 cordova-wheel-selector-plugin
. I'm just installing with cordova and then trying to run window.SelectorCordovaPlugin.showSelector
.
Ionic:
ionic (Ionic CLI) : 4.5.0
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.2
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic 5.3.0, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 32 other plugins)
System:
Android SDK Tools : 26.1.1
ios-sim : 7.0.0
NodeJS : v8.12.0
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
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 (/Users/DQ/.nvm/versions/node/v10.20.0/lib/node_modules/@ionic/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-lib@9.0.1)
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.
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 notifications@github.com 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 (/Users/DQ/.nvm/versions/node/v10.20.0/lib/node_modules/@ionic/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-lib@9.0.1) 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 https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/52#issuecomment-640818918, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPVJRXG7SRNGEHDGVSKEHTRVUZ7PANCNFSM4HXLDEMA .
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 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 notifications@github.com 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 https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/52#issuecomment-642337359, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPVJRQ4PDRIEURAAVJ7UR3RWARGRANCNFSM4HXLDEMA .
Correct. I can confirm with these versions:
"cordova-wheel-selector-plugin": "^1.1.7",
"@ionic-native/wheel-selector": "^5.26.0",
using Ionic version 6.10.0
and Cordova version 9.0.0
the documentation here https://ionicframework.com/docs/native/wheel-selector works as expected with regards to defaultItems
.
defaultItems: [
{index:0, value: this.jsonData.numbers[2].description},
{index: 1, value: this.jsonData.fruits[3].description}
]
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
should be an NSDictionary (Hash), not an array. So I have to set defaultItems
in Javascript this way to make it work:
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 defaultItems
on Android, I can't get any of the default values show up.
@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.
defaultItems: {
0: data.numbers[2].description,
1: data.fruits[2].description
}
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.