who and why deleted my question about Change GenericListEditor at runtime

6 posts, 1 answers
  1. Viktoras
    Viktoras avatar
    3 posts
    Member since:
    Oct 2013

    Posted 05 Mar 2014 Link to this post

    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 
  2. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 06 Mar 2014 Link to this post

    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!

  3. DevCraft banner
  4. Rob
    Rob avatar
    11 posts
    Member since:
    Jan 2013

    Posted 23 Feb in reply to Victor Link to this post

    Where can I find the referenced "sample project" that demonstrates how to change the GenericListEditor at runtime?
  5. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 26 Feb Link to this post

    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
  6. Rob
    Rob avatar
    11 posts
    Member since:
    Jan 2013

    Posted 23 Jun in reply to Rosy Topchiyska Link to this post

    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.

  7. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 28 Jun Link to this post

    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
Back to Top
DevCraft banner