How to Use DomainDataSource in DataForm

10 posts, 0 answers
  1. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 04 Apr 2011 Link to this post

    Hello to everyone.

    I would like to ask if someone has already implemented the DataForm using data coming from DomainDataSource using the GetTableName queries that is generated by VS.

    I have managed to use it using a the DDS and display teh data, however, when i display the related data such as the country lists which is ralated from the Supplier table through a foriegn key.  I am not able to display the existing/default value. But, i can click the country combo and the then the options of the country name cann be seen and displayed.

    Would like to ask if someone can point me on what i am doing wrong, or what i am missing?

    Thanks in advance.  Here is how i am declarin the RadComboBox:

    <telerik:RadComboBox Height="23" Name="CategoryCombo" Grid.Row="0" Grid.Column="4"
                         ItemsSource="{Binding Data, ElementName=categoryDataSource}"
                         SelectedValuePath="cat_idno" DisplayMemberPath="cat_desc"
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 07 Apr 2011 Link to this post

    Hello Almond,

    I have prepared a CRUD example with RadDataForm and RIA services, utilizing our new RadDomainDataSource. Please, refer to it and inform us if this approach meets your requirements.

    Regards,
    Ivan Ivanov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 10 Apr 2011 Link to this post

    Hello Ivan,

    Much thanks for you code. I will try and test it within the day. Just one question, is there any way to populate the combobox using the queries that were automatically generated in the DomainServices. I noticed that you created a EmployeeID lists in the code behind to populated the combobox.  What i want to do is populate the combobox using the queries in the DomainServices like GetEmployeeID.

    Is that possible? I am currently trying to implement what i want to do, however, I am still unable to do so :(

    Hope someone can help me and provide light on how to go about what i want to implement.

    Thanks in advance :)
    almond
  5. Leos
    Leos avatar
    57 posts
    Member since:
    Jul 2010

    Posted 11 Apr 2011 Link to this post

    You must add new RadDomainDataSource with Autoload="true" (or with Load in constructor) and then bind "ItemsSource" of ComboBox to  "DataView" of this RDDS (and DisplayMemberPath, SelectedValuePath and DataMemberBinding ).
    If you plan to use DataTemplate instead of AutoGeneration, you need place this RDDS to (Page, UserControl,...) resource block and map to ComboBox as StaticResource.

    Schematically:
    RDDS 1  - Company
    CompanyId
    CompanyName
    CompanyStateId   (foreign key to States)

    RDDS 2 - States
    StateId
    StateName

    When you want add Company you want to combobox with States, so:

    ComboBox.ItemsSource = rdds2.DataView
    ComboBox.DisplayMemberPath = StateName (what will be displayed in combobox)
    ComboBox.SelectedValuePath  = StateId (what is key in "combobox")
    ComboBox.DataMemberBinding  = Binding CompanyStateId, Mode=TwoWay (main data field to this ComboBox)

  6. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 12 Apr 2011 Link to this post

    Hello Almond,

    This is our recommended approach, when dealing with foreign key fields in RadDataForm. Of course, if this solution doesn't meet your requirements, you are free to experiment.

    Greetings,
    Ivan Ivanov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 12 Apr 2011 Link to this post

    Hello Ivan,

    I finally was able to have it working with some experimenting, just like what you've said. Now, I am just doing some tweeking with the DataFormCheckBoxFields. My table structure has a field name Accredited and data is saved as Y for Yes and N for No. When I tried to have it binded with the DataFormCheckBox, it does not check the box even if the data contains Y.  Does the DataFormCheckBoxField only relate to Boolean? It seems to me i'll be needing a converter for this one. Once i have solved the DataFormCheckBoxFields issue, I will then now try the Add, Edit and Delete Functionality of the DataForm.

    Hope you guys can help me with my CheckBox dilemma and thanks in advance once again for the help.

    almond 
  8. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 12 Apr 2011 Link to this post

    Hello Almond,

    Since DataFormCheckBox field operates with boolean data, you should use a converter to solve this case. Please, refer to the attached project.

    Kind regards,
    Ivan Ivanov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  9. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 12 Apr 2011 Link to this post

    Much thanks for the quick response Ivan.

    We'll try and check the zip file you sent and then apply it with current project and we'll keep you posted.

    Thanks once again. :)

    almond
  10. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 14 Apr 2011 Link to this post

    Hello Ivan,

    I have successfully implemented DataFormCheckBox field, much thanks once again the help in the forum. Now, I have a problem when adding a new record.  Basically, my scenario is am displaying a GridView and I am using a child window for the Adding and Editing of records. I am encountering NullReferenceException was Unhandled by user code when trying to add a new records and the problem is occuring in the Converter code. Its occuring at the return value.ToString() == "T" ? true : false;
    Please see complete code of converter below:

    public class AccreditedConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value.ToString() == "T" ? true : false;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //throw new NotImplementedException();
            //return value.ToString() == "True" ? "T" : "F";
            //MessageBox.Show(value.ToString());
            return value.ToString() == "True" ? "T" : "F";



    The funny thing is tha the error doesnt occur when I am trying to edit an exisiting records.  I think i just need to add a default value in the check box field before I call the Add process.  Can someone teach me on how to assign a default value for an object in a dataform? 

    Hope someone can enligthen me with my problem.  Again, thank in advance for the help.

    regards,
    almond
  11. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 18 Apr 2011 Link to this post

    Already solved my problem by just placing an if statement in the Convert Function now all is set.

    Thanks again for the help given by Leos and Ivan.

    Till next time :)

    kind regards,
    almond
Back to Top
DevCraft banner