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

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

5 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 2
Rahul asked on 16 Jul 2012, 02:35 PM
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.

5 Answers, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 2
answered on 16 Jul 2012, 06:53 PM
hello Telerik,

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

Thanks & Regards
Rahul
0
Rahul
Top achievements
Rank 2
answered on 20 Jul 2012, 01:31 PM
Hello Telerik,

         I'm still waiting for solution
0
Rahul
Top achievements
Rank 2
answered on 30 Jul 2012, 09:29 AM
I'm still waiting for solution
0
Rahul
Top achievements
Rank 2
answered on 17 Aug 2012, 04:13 AM
I'm still waiting for solution
0
Rahul
Top achievements
Rank 2
answered on 23 Aug 2012, 04:34 AM
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
Tags
GridView
Asked by
Rahul
Top achievements
Rank 2
Answers by
Rahul
Top achievements
Rank 2
Share this question
or