DataFormComboBoxField loses the selected value in edit mode

10 posts, 0 answers
  1. Matteo Gugliotta
    Matteo Gugliotta avatar
    16 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2012 Link to this post

    Hi, 
    I have a problem with a DataFormComboBoxField generated in code behind as suggested by your example

    Here is the code for generate the field
    e.DataField = GetComboField(columnFieldProp, e.DataField.DataMemberBinding);
    e.DataField.Loaded += delegate(object o, RoutedEventArgs eventArgs)
    {
          var field = o as DataFormComboBoxField;
          foreach (RadComboBox child in field.ChildrenOfType<RadComboBox>())
           {
                var comboBox = child;
                if (comboBox != null)
               comboBox.SetBinding(RadComboBox.SelectedValueProperty, e.DataField.DataMemberBinding);
           }
    };



    private DataFormComboBoxField GetComboField(ToolColumnFieldProp columnFieldProp, Binding dataBinding)
            {
                DataFormComboBoxField combo = new DataFormComboBoxField();
                combo.SelectedValuePath = columnFieldProp.ComboBoxSelectedPath;
                combo.DisplayMemberPath = columnFieldProp.ComboBoxDisplayPath;           
                object context = Code.Utility.CreateInstance(columnFieldProp.ComboBoxAssemblyName, columnFieldProp.ComboBoxContextNameSpace);
                combo.ItemsSource = Code.Utility.GetComboBoxItemSource(context);          
                combo.DataMemberBinding = dataBinding;          
                return combo;
            }

    XAML
    <telerik:RadDataForm x:Name="rdDataForm"  Header="{Binding Title}" CurrentItem="{Binding Current, Mode=TwoWay}" telerik:StyleManager.Theme="Office_Blue"
                        ItemsSource="{Binding List, Mode=TwoWay}" AutoGeneratingField="rdDataForm_AutoGeneratingField"   Grid.Row="0" AutoCommit="False"
                          EditEnded="rdDataForm_EditEnded" DeletedItem="rdDataForm_DeletedItem"  CommandButtonsVisibility="Cancel,Commit" LabelPosition="Beside"
                         >
         
    </telerik:RadDataForm>

    The ComboBoxField is correctly generated, and correctly bound to selected value. 
    The problem is that when i go in edit mode, the combobox loses the selected value.

    I have the same identical problem in the GridView that is bound to same collection.

    Could you please help me?

    Best regards
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Apr 2012 Link to this post

    Hello Matteo,

    I have tried to reproduce the issue, but since I do not have all the necessary code, I was not able to get close to the scenario you described. Will it be possible to share a bit more code-snippets so that I could test it on my side ?
    On the other hand, why do you need to work with the RadComboBox inside DataFormComboBoxField ? Why not using directly the field ?  

    Regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Matteo Gugliotta
    Matteo Gugliotta avatar
    16 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2012 Link to this post

    Hi Maya,

    I can try to send you maybe via e-mail a little project, but it is part of a big and complicated project. Anyway if you need i will try to reproduce it.

    Anyway, i'm not using rad combobox, but i have just created a DataFormComboBoxField  
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Apr 2012 Link to this post

    Hello Matteo,

    I am attaching a sample project here with a RadDataForm and a DataFormComboBoxField. Could you reproduce the same behavior on it by implementing your own custom code ?  

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Matteo Gugliotta
    Matteo Gugliotta avatar
    16 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2012 Link to this post

    HI Maya,

    I have downloaded your project and i see that you are using the property dataField.IsComboboxEditable = true;

    However, i do not have this property available in my version of silverlight control RadControls for Silverlight, v.2012.1.326.1050
    your version is 1.4....

    I am not able to download from your site this internal build.

    Where i can find the download link?
    (i do no want to use automatically upgrade from inside vs2010)

    best regards
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Apr 2012 Link to this post

    Hi Matteo,

    Indeed, we have included such a property in order to meet our customers' feature requests. 'IsComboboxEditable' property in contained in our internal builds. You can download them in your Telerik account.


    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Matteo Gugliotta
    Matteo Gugliotta avatar
    16 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2012 Link to this post

    Hi Maya,

    Thanks, it does not solve my issue but anyway upgrade controls to last version :-)

    I will try to create a test project and then back to you
  9. kannan
    kannan avatar
    2 posts
    Member since:
    Oct 2014

    Posted 02 Oct 2014 Link to this post

    I am facing the same issue, Could some one help me, I have grid view & data form where I have set auto generate columns as false for the data form and grid has auto generate columns true.

    In read only mode, it is working fine, but when I switch to edit mode, the dataform combobox having the item source bound but loses it selected value. then when I go to next record in the grid, the previous record loses it's value associated to the dataform combobox.

  10. Boris
    Admin
    Boris avatar
    276 posts

    Posted 06 Oct 2014 Link to this post

    Hello Kannan,

    I tried to reproduce a similar behavior as in your description, however I was unsuccessful. Could you please examine the attached example and let us know how it goes? Perhaps there are some differences between the attached sample and your scenario. 

    Regards,
    Boris Penev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. kannan
    kannan avatar
    2 posts
    Member since:
    Oct 2014

    Posted 07 Oct 2014 in reply to Boris Link to this post

    Thank you Penev,

    But I have gone through and do not see I am missing anything.however I fixed it by adding a combobox inside the dataformdatafield which worked!!!

    Thanks
    kannan M
Back to Top
DevCraft banner