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

How to Use DomainDataSource in DataForm

9 Answers 134 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Almond
Top achievements
Rank 1
Almond asked on 04 Apr 2011, 10:59 AM

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"

9 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 07 Apr 2011, 02:04 PM
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
0
Almond
Top achievements
Rank 1
answered on 11 Apr 2011, 03:07 AM
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
0
Leos
Top achievements
Rank 1
answered on 11 Apr 2011, 12:48 PM
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)

0
Ivan Ivanov
Telerik team
answered on 12 Apr 2011, 09:53 AM
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
0
Almond
Top achievements
Rank 1
answered on 12 Apr 2011, 10:16 AM
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 
0
Ivan Ivanov
Telerik team
answered on 12 Apr 2011, 11:58 AM
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
0
Almond
Top achievements
Rank 1
answered on 12 Apr 2011, 05:31 PM
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
0
Almond
Top achievements
Rank 1
answered on 15 Apr 2011, 04:46 AM
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
0
Almond
Top achievements
Rank 1
answered on 18 Apr 2011, 07:17 AM
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
Tags
DataForm
Asked by
Almond
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Almond
Top achievements
Rank 1
Leos
Top achievements
Rank 1
Share this question
or