Loosing Template column data after adding new row in grid. [ This need to resolve very urgent. Please give me solution as soon as possible]

6 posts, 0 answers
  1. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 16 Jul 2012 Link to this post

    Hi All,

    Loosing Template column data after adding new row in grid.

    Here's my code for issue.

    <telerik:RadGridView x:Name="radGridCustomColumns" Margin="0,0,0,10" MaxHeight="400" HeaderRowStyle="{StaticResource BoldHeaderStyle}" RowIndicatorVisibility="Collapsed" telerik:StyleManager.Theme="Windows7" AlternateRowBackground="#EBEFF3" AlternationCount="2" ShowGroupPanel="False" GridLinesVisibility="None"  Width="Auto"  HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                  ShowColumnFooters="False" CanUserInsertRows="False" IsReadOnly="True"   ShowColumnHeaders="True" AutoGenerateColumns="False"
                                 Visibility="Visible" CanUserResizeColumns="False" CanUserFreezeColumns="False" IsFilteringAllowed="False" CanUserSortColumns="False">
                                        <telerik:RadGridView.Columns>
                                            
                                            <telerik:GridViewDataColumn Header="Components" DataMemberBinding="{Binding Components}" Width="12*">
                                                <telerik:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding Components}" Width="100" VerticalAlignment="Top" TextWrapping="Wrap" HorizontalAlignment="Left" ToolTipService.ToolTip="{Binding Components}"/>
                                                    </DataTemplate>
                                                </telerik:GridViewDataColumn.CellTemplate>
                                            </telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn Header="UI Columns" UniqueName="UIColumns"  Width="14*">
                                                <telerik:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBox Width="150" Height="25" VerticalAlignment="Top" TextWrapping="Wrap" Text="{Binding UIColumns,Mode=TwoWay}" HorizontalAlignment="Left"/>
                                                    </DataTemplate>
                                                </telerik:GridViewDataColumn.CellTemplate>
                                            </telerik:GridViewDataColumn>
    <telerik:GridViewDataColumn UniqueName="Action" Width="5*">
                                                <telerik:GridViewDataColumn.Header>
                                                    <TextBlock  Text="Actions" TextWrapping="Wrap"/>
                                                </telerik:GridViewDataColumn.Header>
                                                <telerik:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
                                                            <Image Name="imgAdd" Source="/QualityTrackingReportModule;component/Images/greenplus.png" MouseLeftButtonDown="imgAdd_MouseLeftButtonDown" Cursor="Hand" Margin="0,0,3,0"  Height="16" Width="16" />
                                                            <Image Name="imgEdit" Source="/QualityTrackingReportModule;component/Images/Edit.png" Cursor="Hand" Margin="0,0,3,0"  Height="16" Width="16" />
                                                            <Image Name="imgDelete"  Source="/QualityTrackingReportModule;component/Images/Delete.png" Cursor="Hand" Margin="0,0,0,0"  Height="16" Width="16" />
                                                        </StackPanel>
                                                    </DataTemplate>
                                                </telerik:GridViewDataColumn.CellTemplate>
                                            </telerik:GridViewDataColumn>
     
                                        </telerik:RadGridView.Columns>
                                    </telerik:RadGridView>
    Here's C# Code :-
    namespace QualityTrackingReportModule
    {
        public partial class QTRMUICustomization : Page
        {
           
            public QTRMUICustomization()
            {
                InitializeComponent();
     
               

                radGridCustomColumns.EnableColumnVirtualization = false;
                radGridCustomColumns.Width = App.Current.Host.Content.ActualWidth - 25;
     

                ObservableCollection<CustomColumns> lst = new ObservableCollection<CustomColumns>();
                lst.Add(new CustomColumns { Components = "HDL", UIColumns = "Custom" });
                lst.Add(new CustomColumns { Components = "LDL", UIColumns = "Custom" });
                lst.Add(new CustomColumns { Components = "Systolic BP", UIColumns = "Static" });
     
                radGridCustomColumns.ItemsSource = lst;
            }
     
            private void imgAdd_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                GridViewRow row = ((Image)sender).ParentOfType<GridViewRow>();
                row.IsSelected = true;
     
                object newRow = radGridCustomColumns.Items.AddNew();
                radGridCustomColumns.Items.Remove(newRow);
     
                int currentIndex = radGridCustomColumns.Items.IndexOf(radGridCustomColumns.SelectedItem);
                ((IList)radGridCustomColumns.ItemsSource).Insert(currentIndex + 1, newRow);
     
                // Select the new row
                radGridCustomColumns.SelectedItem = newRow;
                radGridCustomColumns.Items.MoveCurrentTo(newRow);
            }
        }
        public class CustomColumns
        {
            public string Components { get; set; }
            public string UIColumns { get; set; }
        }
    }

    For more information please find attached screenshot.
  2. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 16 Jul 2012 Link to this post

    hello Telerik,

    Its really urgent for me. I need solution by tomorrow morning.
    Please have a generous look.

    Thanks & Regards
    Rahul
  3. DevCraft banner
  4. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 20 Jul 2012 Link to this post

    Hello Telerik,

             I'm still waiting for solution
  5. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 30 Jul 2012 Link to this post

    I'm still waiting for solution
  6. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 16 Aug 2012 Link to this post

    I'm still waiting for solution
  7. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 22 Aug 2012 Link to this post

    Hello Telerik Team,

    Please close this thread as soon as possible.
    As I'm not getting any support at all on this issue.

    Thanks & Regards
    Rahul
Back to Top
DevCraft banner