This is a migrated thread and some comments may be shown as answers.

Add/Remove TKDataFormOptionsEditor options on demand

5 Answers 62 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marc
Top achievements
Rank 1
Marc asked on 30 Jun 2016, 12:10 PM

hello,

i need to implement (via Xamarin.iOS) a cascading OptionsEditor within DataForms, this means i need to change the corresponding TKEntityProperty.ValueProvider and/or TKDataFormsOptionsEditor.Options property on the fly depending on the users input.

This works as intended, the second OptionsEditor get populated with the correct values but if the user tries to select a option form within the second OptionsEditor the whole thing crashes and burns within the TKDataFormOptionsEditor (see stack trace and the end)

As we can clearly see an underlying NSArray somewhere inside TKDataFormOptionsEditor seems to be empty but shouldn't be ...

To my actual questions, is changing the available options inside a TKDataFormOptionsEditor after the editor has already been initialized/used even a supported usage scenario? If yes is there some sample code available that shows the proper way to do this (Xamarin/C# preferred)?

tia

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSRangeException Reason: *** -[__NSArrayI objectAtIndex:]: index 5 beyond bounds [0 .. 0]
Native stack trace:
0   CoreFoundation                      0x0000000180eeedc8 <redacted> + 148
1   libobjc.A.dylib                     0x0000000180553f80 objc_exception_throw + 56
2   CoreFoundation                      0x0000000180dcf098 CFRunLoopRemoveTimer + 0
3   TempusClientUniversaliOS            0x00000001001f61d0 -[TKDataFormOptionsEditor setValue:] + 164
4   TempusClientUniversaliOS            0x000000010011e920 -[TKDataFormEditor observeValueForKeyPath:ofObject:change:context:] + 200
5   Foundation                          0x00000001817ebf64 <redacted> + 304
6   Foundation                          0x00000001817eba8c <redacted> + 404
7   Foundation                          0x00000001818961ac <redacted> + 732
8   Foundation                          0x00000001817eafc0 <redacted> + 64
9   Foundation                          0x000000018180ed60 <redacted> + 268
10  TempusClientUniversaliOS            0x000000010011ea24 -[TKDataFormEditor setValue:] + 148
11  TempusClientUniversaliOS            0x00000001001f6178 -[TKDataFormOptionsEditor setValue:] + 76
12  TempusClientUniversaliOS            0x00000001001f63e4 -[TKDataFormOptionsEditor setSelectedIndex:] + 100
13  TempusClientUniversaliOS            0x00000001001899c0 -[TKDataFormOptionsViewController tableView:didSelectRowAtIndexPath:] + 308
14  UIKit                               0x000000018617bdc4 <redacted> + 1316
15  UIKit                               0x00000001862397d4 <redacted> + 376
16  UIKit                               0x00000001862f70c8 <redacted> + 292
17  UIKit                               0x0000000186304a80 <redacted> + 92
18  UIKit                               0x00000001860365a4 <redacted> + 96
19  CoreFoundation                      0x0000000180ea4728 <redacted> + 32
20  CoreFoundation                      0x0000000180ea24cc <redacted> + 372
21  CoreFoundation                      0x0000000180ea28fc <redacted> + 928
22  CoreFoundation                      0x0000000180dccc50 CFRunLoopRunSpecific + 384
23  GraphicsServices                    0x00000001826b4088 GSEventRunModal + 180
24  UIKit                               0x00000001860ae088 UIApplicationMain + 204
25  TempusClientUniversaliOS            0x00000001014e8614 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 324
26  TempusClientUniversaliOS            0x00000001014677bc UIKit_UIApplication_Main_string___intptr_intptr + 44
27  TempusClientUniversaliOS            0x000000010146777c UIKit_UIApplication_Main_string___string_string + 172
28  TempusClientUniversaliOS            0x00000001003a50a0 Tempus_Client_UniversaliOS_Application_Main_string__ + 128
29  TempusClientUniversaliOS            0x000000010066bff4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
30  TempusClientUniversaliOS            0x0000000100283cc0 mono_jit_runtime_invoke + 1648
31  TempusClientUniversaliOS            0x00000001002eca4c mono_runtime_invoke + 140
32  TempusClientUniversaliOS            0x00000001002f1400 mono_runtime_exec_main + 400
33  TempusClientUniversaliOS            0x00000001003a0d58 xamarin_main + 1952
34  TempusClientUniversaliOS            0x0000000101e4af74 main + 96
35  libdyld.dylib                       0x000000018096a8b8 <redacted> + 4

5 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 05 Jul 2016, 08:46 AM
Hi, Marc,

Thank you for writing.

To reload the editor after you change the valuesProvider property you should call the reloadData method of TKDataForm. Possible reason for this exception is because the editor is not reloaded. It would be great if you could send me a sample project where the issue can be reproduced so I can investigate it further. Thank you in advance for your cooperation.


Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Yunuen Sanchez
Top achievements
Rank 1
answered on 10 Aug 2016, 06:07 PM

Where's the best part to call reloadData on DataForm?

I changed the ValuesProvider of the second Options Editor on DidEditProperty (looking for the change on the first Editor), and call the reloadData method here as well. The Options Selection did something weird, it opened a new Controller with the same information and then get back. I went back to the dataform main screen and the ValuesProvider of the second editor was successfully reloaded; but how can avoid the "refresh behavior" after calling the reloadData? Should I call it somewhere else?

Thanks!

0
Adrian
Telerik team
answered on 15 Aug 2016, 01:43 PM
Hello, Yunuen,

Probably this behavior is caused because when you call reloadData in DidEditProperty the options view controller is still in the navigation controller's stack. Maybe a possible solution is to raise a flag in DidEditProperty and then using this flag you could call reloadData when the controller is popped from the stack like in viewWillAppear for example. I hope this helps.

Regards,
Adrian
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Yunuen Sanchez
Top achievements
Rank 1
answered on 17 Aug 2016, 11:00 PM
Thanks Adrian, that did the trick!
0
Adrian
Telerik team
answered on 18 Aug 2016, 10:33 AM
Hi, Yunuen,

I am glad that I could help. 

Regards,
Adrian
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DataForm
Asked by
Marc
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Yunuen Sanchez
Top achievements
Rank 1
Share this question
or