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

[Solved] Using default values with WCF-RIA entities binding

1 Answer 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
m v klingeren
Top achievements
Rank 1
m v klingeren asked on 18 Oct 2010, 09:13 AM
We're using a DomainService for our Silverlight business application, and bind the respective Itemsource of our
datagrids to the <riaControls:DomainDataSource> queries or trough LoadOperation for the DomainContext. That works fine..

Now in the datagrid, we define our collumns (autogeneratecolumns = false). And use DataBinding to bind to the right part of the entities
(In this example i just left 1 column, we have more of course..)

 <grid:RadGridView.Columns>
                <grid:GridViewDataColumn Header="Begindatum" DisplayIndex="2" DataMemberBinding="{Binding BeginDate, Mode=TwoWay}" DataFormatString="{}{0:d}" />
 </grid:RadGridView.Columns>

Now when a new item is added trough the 'ShowInsertRow' bar.. we would like to change the default value of it. So the date will be 01-01-2000, for example instead of 01-01-0001

in case of binding with a ComboboxColumn

<grid:GridViewComboBoxColumn DisplayIndex="2" Header="Part" ItemsSource="{Binding Data, Source={StaticResource ddsParts},Mode=TwoWay}" DataMemberBinding="{Binding Mode=TwoWay, Path=Part_PartID, NotifyOnValidationError=True}" DisplayMemberPath="Omschrijving" SelectedValueMemberPath="PartID" />   

We would also like to be able to make a predefined selection.

Can you please help us with this?


Kind regards,
Milco              

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 18 Oct 2010, 03:29 PM
Hi m v klingeren,

You can subscribe to the AddingNewDataItem event of RadGridView and set the properties you need of the object that is about to be added. This way the combobox item will be pre-selected as well:

private void clubsGrid_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
    e.NewObject = new Club()
    {
        Established = new DateTime(2010, 10, 10),
        Name = "Chelsea" // this will preselect the combobox
    };
}


Greetings,
Veselin Vasilev
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
Tags
GridView
Asked by
m v klingeren
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or