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

[Solved] Save button not displayed when editing in details row.

2 Answers 165 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.
Ole
Top achievements
Rank 1
Ole asked on 14 Sep 2010, 03:54 PM
Hi,

I have
<telerik:RadButton Width="150" Content="Save insert/edit" Margin="0,0,5,0"
                               Command="telerikGrid:RadGridViewCommands.CommitEdit"  Click="RadButton_Click" CommandTarget="{Binding ElementName=CostPlanInfoGridView}"  />

bound to a radgridview.

How ever when editing data in the detailsrow, the save button stays disabled.

Here is my full code

<navigation:Page xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="PriceBank.Views.ChapterSetup" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           mc:Ignorable="d"
           xmlns:local="clr-namespace:PriceBank"
           xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
           xmlns:my="clr-namespace:PriceBank.Web.Services" 
           xmlns:dataFormToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"     
           d:DesignWidth="640" d:DesignHeight="480"
           Title="ChapterSetup Page" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
        <RowDefinition Height="27" />
        <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <!--<local:PriceAreaListProvider x:Key="priceAreaListProvider" />-->
        </Grid.Resources>
  
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,5,0,0">
            <telerik:RadButton Width="150" Content="Delete selected rows" Margin="0,0,5,0" 
                               Command="telerikGrid:RadGridViewCommands.Delete" CommandTarget="{Binding ElementName=CostPlanInfoGridView}"  />
            <telerik:RadButton Width="150" Content="Add new row" Margin="0,0,5,0" 
                               Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=CostPlanInfoGridView}"  />
            <telerik:RadButton Width="150" Content="Save insert/edit" Margin="0,0,5,0"
                               Command="telerikGrid:RadGridViewCommands.CommitEdit"  Click="RadButton_Click" CommandTarget="{Binding ElementName=CostPlanInfoGridView}"  />
            <!--<telerik:RadButton Width="150" Content="Save insert/edit" Margin="0,0,5,0"  Click="RadButton_Click" />-->
            <telerik:RadButton Width="150" Content="Cancel insert/edit"
                               Command="telerikGrid:RadGridViewCommands.CancelRowEdit" CommandTarget="{Binding ElementName=CostPlanInfoGridView}"  />
        </StackPanel>
              
              
        <telerik:RadGridView  x:Name="CostPlanInfoGridView" AutoGenerateColumns="False" SelectionMode="Extended"
                             Margin="0,5,0,0" Grid.Row="1"  ItemsSource="{Binding ElementName=DomainDataSourceChapterSettings, Path=Data, Mode=OneWay}" RowDetailsVisibilityChanged="CostPlanInfoGridView_RowDetailsVisibilityChanged"  ActionOnLostFocus="None">
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn></telerik:GridViewToggleRowDetailsColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Audkenni, Mode=TwoWay}" SortMemberPath="Audkenni"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Heiti, Mode=TwoWay}" SortMemberPath="Heiti"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Heiti_E, Mode=TwoWay}" SortMemberPath="Heiti_E"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Hofundur, Mode=TwoWay}" SortMemberPath="Hofundur"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Verkkaupi, Mode=TwoWay}" SortMemberPath="Verkkaupi"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Stofndagur, Mode=TwoWay}" SortMemberPath="Stofndagur"></telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding VerdSvaediID, Mode=TwoWay}" SortMemberPath="VerdSvaediID"></telerik:GridViewDataColumn>
                <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Template, Mode=TwoWay}"></telerik:GridViewCheckBoxColumn>
                 
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.RowDetailsTemplate >
                <DataTemplate >
                      
                    <Grid >
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition/>
                              
                        </Grid.ColumnDefinitions>
                        <Grid.Resources>
                            <Style x:Key="DetailsLabel110" TargetType="dataInput:Label" BasedOn="{StaticResource DetailsLabelRadGrid}">
                                <Setter Property="Width" Value="110"/>
                            </Style>
                            <Style x:Key="DetailsLabel80" TargetType="dataInput:Label" BasedOn="{StaticResource DetailsLabelRadGrid}">
                                <Setter Property="Width" Value="80"/>
                            </Style>
                            <Style x:Key="RowDetailsStyle" TargetType="telerik:DetailsPresenter">
                                <Setter Property="Background" Value="White" />
                                <Setter Property="Foreground" Value="Black" />
                            </Style>
  
                        </Grid.Resources>
  
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="0"   LabelPosition="Left" LabelStyle="{StaticResource DetailsLabel110}"  >
                            <telerik:RadComboBox  x:Name="cmbPriceArea"   ItemsSource="{Binding ElementName=DomainDataSourcePriceAreas, Path=Data, Mode=OneWay}"  DisplayMemberPath="Verdsvaedi" SelectedValuePath="ID"  SelectedValue="{Binding VerdSvaediID, Mode=TwoWay}"></telerik:RadComboBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="1" Grid.Row="0"  LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel80}"  >
                            <TextBox Text="{Binding Path=Heiti_E, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
                        </dataFormToolkit:DataField>
                        <!--<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Heiti_E, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>-->
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" IsTabStop="False">
                            <TextBox   Text="{Binding Heiti, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"  LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" >
                            <TextBox   Text="{Binding Lysing, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"  LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" >
                            <TextBox    Text="{Binding Lysing_E, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="4"  LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" >
                            <TextBox  Text="{Binding Hofundur, Mode=TwoWay,NotifyOnValidationError=True}" ></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="1" Grid.Row="4"  LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel80}" >
                            <TextBox  Text="{Binding Verkkaupi, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="2" LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" >
                            <TextBox   Text="{Binding Kaflaskipting, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <dataFormToolkit:DataField Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="2" LabelPosition="Auto" LabelStyle="{StaticResource DetailsLabel110}" >
                            <TextBox    Text="{Binding Kaflaskipting_e, Mode=TwoWay,NotifyOnValidationError=True}"></TextBox>
                        </dataFormToolkit:DataField>
                        <!--<StackPanel Grid.Column="0" Grid.Row="7"><sdk:Label Target=""></sdk:Label>    </StackPanel>-->
                        <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:BuildingCostDomainContext, CreateList=true}" Height="0"  Name="DomainDataSourcePriceAreas" QueryName="GetTbl_VerdsvaediQuery" Width="0" >
                        <riaControls:DomainDataSource.DomainContext>
                            <my:BuildingCostDomainContext />
                        </riaControls:DomainDataSource.DomainContext>
                    </riaControls:DomainDataSource>
                          
                    </Grid>
                </DataTemplate>
                  
                  
            </telerik:RadGridView.RowDetailsTemplate
  
<!--ItemsSource="{Binding PriceAreaList, Source={StaticResource priceAreaListProvider}}"-->
  
        </telerik:RadGridView>
          
          
          
          
        <riaControls:DomainDataSource Height="0" AutoLoad="True" Name="DomainDataSourceChapterSettings"  Width="0" PageSize="5" QueryName="GetTbl_KostAaetlunQuery">
              
            <riaControls:DomainDataSource.DomainContext>
                <my:BuildingCostDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource >
  
          
    </Grid>
</navigation:Page>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using PriceBank.Web.Services;
using Telerik.Windows.Controls;
using System.Windows.Data;
  
namespace PriceBank.Views
{
     
    public partial class ChapterSetup : Page
    {
        BuildingCostDomainContext basicContext;
        public ChapterSetup()
        {
  
            ICommand deleteCommand = RadGridViewCommands.Delete;
            ICommand beginInsertCommand = RadGridViewCommands.BeginInsert;
            ICommand cancelRowEditCommand = RadGridViewCommands.CancelRowEdit;
            ICommand commitEditCommand = RadGridViewCommands.CommitEdit;
  
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ChapterSetup_Loaded);            
             
        }
  
        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
        private void ChapterSettingsDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {
  
            if (e.HasError)
            {
                System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }
  
        void ChapterSetup_Loaded(object sender, RoutedEventArgs e)
        {
            basicContext = new BuildingCostDomainContext();// used for maingrid
            App.Current.Resources.Remove("webContext");
            App.Current.Resources.Add("webContext", basicContext);
                          
        }
        RadComboBox combobox;
        private void CostPlanInfoGridView_RowDetailsVisibilityChanged(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
        {
            //combobox = e.DetailsElement.ChildrenOfType<RadComboBox>().First();
              
             
        }
  
        private void PriceAreassDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {
            //combobox.SelectedValue = new Binding("VerdSvaediID");
              
        }
  
        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
              
            DomainDataSourceChapterSettings.SubmitChanges();
              
        }
  
          
  
    }
}

Can someone help me in getting the save button displayed, when editing the details row.

Thanks

Ole

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 17 Sep 2010, 12:22 PM
Hello Ole,

The button is disabled because none of the cells of the row is in edit mode.
One of the solutions would be to put a cell into edit mode manually when any of the controls in the RowDetailsTemplate receives focus.

Find attached a sample solution.

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
0
Ole
Top achievements
Rank 1
answered on 17 Sep 2010, 01:16 PM
Hi,

Thanks for the solution.

However I figured out that putting this in the textbox changed event

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
       {         
           saveBtn.IsEnabled = true;            
       }

would be enourgh for me at least for now.

Again I must say thank you to you and the rest of the Telerik team for the impressive support that I am getting.

Have a nice weekend !

Best

Ole
Tags
GridView
Asked by
Ole
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Ole
Top achievements
Rank 1
Share this question
or