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

who and why deleted my question about Change GenericListEditor at runtime

5 Answers 29 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.
Viktoras
Top achievements
Rank 1
Viktoras asked on 05 Mar 2014, 04:38 PM
I've sent sample solution which describe problem. Now thread is deleted. No answer, no thread, no problems?

Your last answer was:
Can you please try firing the PropertyChanged event
for the Object1Type property
when the other property changes? The DataForm should
detect this change and call the GenericListInfoProvider for
new items.

If that doesn't work, sending us a sample project that we can use to
investigate the case will be really helpful.

Thanks for your time.

Regards,

Deyan

Telerik 

5 Answers, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 06 Mar 2014, 08:43 AM
Hello Viktoras,

Please excuse us for the inconvenience. I am not sure what might have happened on your end but your question was answered yesterday. Please have a look at Deyan's answer below:

I have also attached the sample project he prepared for you.

Hi Viktoras,

Thanks for writing back and for the provided project.

I have been able to implement the scenario you require. For that purpose I have additionally implemented theIGenericListEditorConverter interface which is used to translate property values from the MainViewModel to the Data Form and vice-versa. Since an instance of the RadListPicker editor is provided in theConvert method, I am able to change it's data source there according to whether car or phone is selected.

So, in my GenericListInfoProvider implementation for the second list-picker I also use the Converter property from the interface to return an instance of that special type of converter. Take a look at the attached project.

The only issue I have encountered is that the ViewModelLocator which I am using the my conberter to acquire the MainViewModel instance always returns a new instance of it which is not correct. I therefore am not able to retrieve the correct selection - car or phone - so that I can generate a new data source.

I am attaching the modified version of your project for your reference.



Regards,
Victor
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Rob
Top achievements
Rank 2
answered on 23 Feb 2016, 07:48 PM
Where can I find the referenced "sample project" that demonstrates how to change the GenericListEditor at runtime?
0
Rosy Topchiyska
Telerik team
answered on 26 Feb 2016, 04:11 PM
Hi Rob,

I have attached the sample project again.

Regards,
Rosy Topchiyska
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
Rob
Top achievements
Rank 2
answered on 23 Jun 2016, 05:30 PM

Hello, this sample project does not seem to work correctly if the number of items in the "Things" list exceed the "InlineModeThreshold" for the list picker.

For example, if Thing1ValueConverter is modified as such...

        public object ConvertForEditor(RadListPicker editor, object value)
        {
            //string things = App.MainViewModel.Things;
            MainViewModel model = (MainViewModel)editor.DataContext;
            if (model == null) return value;
            string things = model.Things;
            if (things == null)
            {
                return value;
            }
            List<string> source = null;

            if (things == "car")
            {
                editor.ItemsSource = source = new List<string> { "bmw", "alfa", "1", "2", "3", "4", "5" };
            }
            else if (things == "phone")
            {
                editor.ItemsSource = source = new List<string> { "nokia", "sony", "1", "2", "3", "4", "5" };
            }
            return source[0];
        }

Then you can no longer pick the items from the list picker.

0
Rosy Topchiyska
Telerik team
answered on 28 Jun 2016, 08:48 AM
Hi Rob,

Thank you for contacting us.

The problem in the attached project is that the RadDataForm.CurrentItem is set to a new instance of MainViewModel class, rather than bound to the context of the page. This in the converter, when checking the value of ViewModelLocator.Main.Things, you will get incorrect value, because the main view model has not changed. If you update the following line of code, the items in the second picker should update correctly:
<telerikInput:RadDataForm Margin="12,0,12,12" x:Name="DataForm" CommitMode="OnFieldValueChange" CurrentItem="{Binding}">

I hope this helps. If you experience a different issue, please be more specific on the scenario: what happens when you try to select an item?

Regards,
Rosy Topchiyska
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
Tags
DataForm
Asked by
Viktoras
Top achievements
Rank 1
Answers by
Victor
Telerik team
Rob
Top achievements
Rank 2
Rosy Topchiyska
Telerik team
Share this question
or