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

DataForm as RadGridView RowDetailTemplate

5 Answers 212 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Apr 2011, 03:33 AM
I am finding unusual behavior in using the DataForm in conjunction with the RadGridView.

First, I bind my RadGridView to a different IEnumberable from my ViewModel:
public IEnumerable<SubRegionFactor> SubRegionFactors
{
    get { return RIAService_Main_MSWPW.SubRegionFactors; }
}

<telerik:RadGridView Grid.Row="1" x:Name="domainListEditor" IsReadOnly="False" ItemsSource="{Binding SubRegionFactors}" 
                             CanUserFreezeColumns="False" RowIndicatorVisibility="Visible" 
                             HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanUserInsertRows="True"
                             RowDetailsVisibilityMode="VisibleWhenSelected" AutoGenerateColumns="false"  ShowInsertRow="True"
                             AddingNewDataItem="domainListEditor_addRow" RowEditEnded="domainListEditor_RowEditEnded" SelectionChanged="domainListEditor_SelectionChanged">


Then I use the DataForm as a RowDetailsTemplate
<telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <telerikDataForm:RadDataForm x:Name="domainListDataForm" CurrentItem="{Binding}" 
                                                 Header="Edit Settings:" 
                                                 AutoGeneratingField="DomainList_AutoGeneratingField"
                                                 Width="600"/>
                </DataTemplate>
            </telerik:RadGridView.RowDetailsTemplate>


What happens next is the strange part.

In one page - it works as expected for both adding and editing rows.
In the next page - editing a row works fine, but new rows just disappear
In a third example - adding a row and editing a row both save the new/chaged data, but the added row will not refresh that area of the screen, so it looks like the new row did not collapse. 


Any thoughts or ideas?

5 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 22 Apr 2011, 02:24 AM
Update:  For the rows that were "disappearing", the insert row was not adding a record to the ViewModel.  I had to trap this on the end of editing to make sure it was added before submitting changes on the ViewModel.  This is a cheap workaround, and I wish I had time to discover why sometimes it adds the record and other times does not.

if (App.AppContext.HasChanges == false) App.AppContext.SubRegionFactors.Add(item);


For the other issue where the new row would not collapse - the RadGridView row was stuck thinking the row was the RowInEdit - it turned out this was because some columns exposed for editing in the DataForm were set IsReadOnly="True" in the RadGridView.  Setting all columns used in the DataForm to IsReadOnly="False" solved the issue.  Not ideal, as I'm trying to drive the user to make edits in the DataForm, but will have to do for now.



0
Maya
Telerik team
answered on 26 Apr 2011, 12:01 PM
Hello Robert,

I have tried to reproduce the behavior you described, but unfortunately I was not able to. May you take a look at the sample attached to verify whether there are any discrepancies based on your settings ?
  

All the best,
Maya
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
Robert
Top achievements
Rank 1
answered on 28 Apr 2011, 05:40 PM
The difference is you are using autogenerated columns.  I am only showing relevant columns to the user.  However, I want to control which columns they can edit.  So I mark columns which I will not allow to appear in  the DataForm as IsReadOnly="true".

<!-- Specify the Columns to display for this domain List-->
<telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn Header="Building Type" DataMemberBinding="{Binding BuildingType.BuildingTypeName}" IsReadOnly="false"/>
    <telerik:GridViewDataColumn Header="Circulation Factor" DataMemberBinding="{Binding CircFactor}" IsReadOnly="false"/>
    <telerik:GridViewDataColumn Header="Contingency Factor" DataMemberBinding="{Binding ContigencyFactor}" IsReadOnly="false"/>
    <telerik:GridViewDataColumn Header="Load Factor" DataMemberBinding="{Binding LoadFactor}" IsReadOnly="true"/>
    <telerik:GridViewDataColumn Header="Created By" DataMemberBinding="{Binding CreatedBy}" IsReadOnly="true"/>
    <telerik:GridViewDataColumn Header="Created Date" DataMemberBinding="{Binding CreatedDate}"  IsReadOnly="true"/>
    <telerik:GridViewDataColumn Header="Modified By" DataMemberBinding="{Binding ModifiedBy}"  IsReadOnly="true"/>
    <telerik:GridViewDataColumn Header="Modified Date" DataMemberBinding="{Binding ModifiedDate}" IsReadOnly="true"/>
</telerik:RadGridView.Columns>

In the DataForm I only show the columns I want them to be able to edit.
private void DomainList_AutoGeneratingField(object sender, AutoGeneratingFieldEventArgs e)
        {
            try
            {
                /* This is the list of Columns we want to display in the Edit window, and their display names */
                Dictionary<string, string> showColumns = new Dictionary<string, string>();
                showColumns.Add("CircFactor", "Circulation Factor");
                showColumns.Add("ContingencyFactor", "Contingency Factor"); 
                showColumns.Add("LoadFactor", "Load Factor");
                showColumns.Add("BuildingType", "Building Type");
  
                /* Reject all the ones we don't want to display */
                if (!showColumns.ContainsKey(e.PropertyName))
                {
                    e.Cancel = true;
                }
                /* Rename the ones we do want to display */
                else
                {
                    e.DataField.Label = ((string)e.DataField.Label).Replace(e.PropertyName, showColumns[e.PropertyName]);
                }
              catch { //do something here}
}


If I happen to make once of the GridView columns IsReadOnly="true" and allow that field to be edited in the DataForm, the row will not get out of edit mode until you click off to another row, and click back on to the original row, and then click off the original row for the second time.

0
Maya
Telerik team
answered on 29 Apr 2011, 09:33 AM
Hello Robert,

I have updated the sample so that the columns are defined rather than auto generated, but still I was not able to get the behavior you described.  May take a look at the sample attached and this small video to verify whether I am reproducing the steps correctly or I am missing something ?

Regards,
Maya
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
Chetan
Top achievements
Rank 1
answered on 05 Dec 2012, 11:47 AM
This is quite old post,

I am evaluating same thing, just query is  if added data fields in the data form then nothing is display in detail template in edit mode.
Actually I would need this beacause I want to add drop down, radio button, date picker in same with MVVM pattern.
version: 2012 Q3 sp1

 

<radGrid:RadGridView.RowDetailsTemplate>
<DataTemplate>
<toolkit:DataForm x:Name="editdeviceTypes" Style="{StaticResource DataFormStyle}" AutoEdit="True" IsEnabled="True" 
CurrentItem="{Binding}"  AutoGenerateFields="False">
<StackPanel Orientation="Vertical">
<toolkit:DataField Label="ddd" >
<TextBox Text="{Binding DeviceType1}" ></TextBox>
</toolkit:DataField>
<toolkit:DataField Label="dddweeee">
<TextBox Text="{Binding DeviceType1}" ></TextBox>
</toolkit:DataField>
</StackPanel>
</toolkit:DataForm>
</DataTemplate>
</radGrid:RadGridView.RowDetailsTemplate>
Tags
DataForm
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Maya
Telerik team
Chetan
Top achievements
Rank 1
Share this question
or