How to display Tab Control inside Gridview

1 posts, 0 answers
  1. Zealous
    Zealous avatar
    2 posts
    Member since:
    Feb 2012

    Posted 30 Mar 2012 Link to this post

    Hi..
    I want to show tab control inside Gridview.
    I try it but it does not display tabcontrol inside Gridview. When i expand detail that time it does not display Tab control it just show gridview.
    Please help me.
    My Code is below.
    My Testpages.xaml is like

    <UserControl x:Class="RadGridView_SL4_AR_56.Testpages"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot">

            <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RowIndicatorVisibility="Collapsed"
                                 IsReadOnly="True" ShowGroupPanel="False" ColumnWidth="SizeToHeader" AlternationCount="2"
                                 ItemsSource="{Binding LstRecords}" >
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>
                        <telerik:RadTabControl >
                            <telerik:RadTabItem Header="WorkOrder">
                                <telerik:RadGridView Name="dgdWorkOrders" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed"
                                                                     ItemsSource="{Binding DetailItem}"
                                                                     AutoGenerateColumns="True">
                                </telerik:RadGridView>
                            </telerik:RadTabItem>
                            <telerik:RadTabItem Header="Inspection">
                                <telerik:RadGridView Name="dgdInspection" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed"
                                                            ItemsSource="{Binding DetailItemDet}" AutoGenerateColumns="True">
                                </telerik:RadGridView>
                            </telerik:RadTabItem>
                        </telerik:RadTabControl>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
        </Grid>
    </UserControl>

    My Testpages.xaml.cs is like

    public partial class Testpages : UserControl, INotifyPropertyChanged
        {
            ObservableCollection<InspectionAuthorisationsList> lstRecords = new ObservableCollection<InspectionAuthorisationsList>();
            public ObservableCollection<InspectionAuthorisationsList> LstRecords
            {
                get { return lstRecords; }
                set
                {
                    lstRecords = value;
                    RaisePropertyChanged("LstRecords");
                }
            }
            public Testpages()
            {
                InitializeComponent();
                var definition = RadGridView1.TableDefinition;
                var d = new GridViewTableDefinition();
                d.Relation = new PropertyRelation("DetailItem");
                definition.ChildTableDefinitions.Add(d);
                definition = d;
                for (int i = 0; i < 10; i++)
                {
                    InspectionAuthorisationsList ia = new InspectionAuthorisationsList();
                    ia.ID = i;
                    ia.InspectionReference = String.Format("Name{0}", i);
                    if (i % 2 == 0)
                    {
                        ia.DetailItem = new List<RepairRequestsForInspectionAuthorisationsList>();
                        for (int j = 0; j < 2; j++)
                        {
                            RepairRequestsForInspectionAuthorisationsList mo1 = new RepairRequestsForInspectionAuthorisationsList();
                            mo1.InspectionID = j;
                            mo1.Problem = String.Format("Problem : {0}", j);
                            mo1.RequestID = i;
                            ia.DetailItem.Add(mo1);
                        }

                        ia.DetailItemDet = new List<RepairRequestsDetail>();
                        for (int k = 0; k < 2; k++)
                        {
                            RepairRequestsDetail mo1 = new RepairRequestsDetail();
                            mo1.InspectionID = i;
                            mo1.ProblemDet = String.Format("Problem Det : {0}", k);
                            mo1.DetID = k;
                            ia.DetailItemDet.Add(mo1);
                        }
                    }
                    lstRecords.Add(ia);
                }
                LstRecords = lstRecords;
                RadGridView1.ItemsSource = LstRecords;
            }

            protected virtual void RaisePropertyChanged(string propertyName)
            {
                var handler = this.PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }
            }
            public event PropertyChangedEventHandler PropertyChanged;
            private void RadGridView1_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
            {
                var grid = (GridViewDataControl)sender;
                grid.ShowGroupPanel = false;
                grid.AutoGenerateColumns = false;
                if (grid.Name == "")
                {
                    grid.Columns.Add(new GridViewDataColumn() { Header = "RequestID", DataMemberBinding = new Binding("RequestID") });
                    grid.Columns.Add(new GridViewDataColumn() { Header = "Problem", DataMemberBinding = new Binding("Problem") });
                }
                else
                {
                    grid.Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("ID") });
                    grid.Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("InspectionReference") });
                }
            }
        }
        public class InspectionAuthorisationsList
        {
            public int ID { get; set; }
            public string InspectionReference { get; set; }
            public List<RepairRequestsForInspectionAuthorisationsList> DetailItem { get; set; }
            public List<RepairRequestsDetail> DetailItemDet { get; set; }
        }
        public class RepairRequestsForInspectionAuthorisationsList
        {
            public int InspectionID { get; set; }
            public int RequestID { get; set; }
            public string Problem { get; set; }
        }
        public class RepairRequestsDetail
        {
            public int InspectionID { get; set; }
            public int DetID { get; set; }
            public string ProblemDet { get; set; }
        }
Back to Top