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

Binding Data to multipleRadgridview(heirarchical grids)

4 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pravalika
Top achievements
Rank 1
Pravalika asked on 11 Jun 2013, 06:41 AM
Hello all,



Please Help me In coding..

we Have Binded the data to Radgridview using Wcf Service Method,
then have to bind the childgridview using the Id Present in column of Parent Row of ParentGridview,for that we need to pass the Id as parameter to next Method of Service Call(Code Required )
and the same repeats till The Id Value Gets null.

That means we need a minimum 3 childgridviews,and this has to be done using wcf methods.

Please its very urjent.kindly help me out in this scenario.
(Here we are using only one sqltable data)


Thanks you in adv


4 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 13 Jun 2013, 02:54 PM
Hi Pravalika,

 Would you please specify, what exact problems with RadGridView you have encountered, while implementing your project? Please, feel free to send us a sample project that illustrates your scenario, so that we could debug it on our side.

Regards,
Ivan Ivanov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pravalika
Top achievements
Rank 1
answered on 14 Jun 2013, 07:34 PM
Have Sent Sample Project In detail:
0
Pravalika
Top achievements
Rank 1
answered on 14 Jun 2013, 07:37 PM

 

 Sample Data:

I have Table Named    Empdata:

 ReoprtId           Id            Name          Salary

AR                     AB           John               7000

AM                  AC           Rahul               8000

AM                 AP             Sneha             8000

KD                  AD          Saniya               7000

AR                  KD           manasa            7000

AP                  Ak            Monika            6000

AM               AR              Jyothi              8000

Ak                RD                Nisha             5000

AC                 A               Aasha               4000

  -                  AM             Kabir                10000

Here Kabir Is Main supervisor  Whose ID is AM( as he doesn’t have a REOPRTID of  any other Person to reoprt)

and  employess who have ID of Kabir are reporting to Kabir in the organization and in the same way based on the ReoprtID  of Empid s we can get employees reopting their supervisors.

Here we abserve the 2 Persons(sneha  Rahul and jyothi ) Reporting to Kabir (as they have REoprtid of Kabir  )

Manasa and john…………………………….>Jyothi

Saniya…………….>manasa

Mounika…………..>sneha

Nisha……………….>mounika

Aasha……………….>Rahul

 

 

 

Please Find Org Chart Attched

Now I need The Hierarchal radchart for representing the  employess who are reporting to their supervisors:

My xaml:

   <telerik:RadGridView x:Name="RadGridView1"

                           RowStyleSelector="{StaticResource rowStyleSelector}"

                                                 Margin="0" GroupRenderMode="Flat"

                                                 RowIndicatorVisibility="Collapsed"

                                         RowDetailsVisibilityMode="VisibleWhenSelected"

                                                 IsReadOnly="True"

                                                 Width="736"

                                                 Height="285"

                                                 AutoGenerateColumns="False"

                               CanUserFreezeColumns="True"

                                                 CanUserResizeColumns="True"

                                         ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible">

                        <telerik:RadGridView.Columns>

                            <telerik:GridViewToggleRowDetailsColumn />

 

                            <telerik:GridViewDataColumn Header=" ReoprtId           "

                                                                            DataMemberBinding="{Binding ReoprtId           }" />

                            <telerik:GridViewDataColumn Header=" Id  "

                                                                            DataMemberBinding="{Binding Id  }" />

                            <telerik:GridViewDataColumn Header=" Name "

                                                                            DataMemberBinding="{Binding Name }" />

                            <telerik:GridViewDataColumn Header="salary"

                                                                            DataMemberBinding="{Binding salary }"

                                            Width="*"/>

 

 

 

                        </telerik:RadGridView.Columns>

 

                        <telerik:RadGridView.RowDetailsTemplate>

 

                            <DataTemplate>

                                <telerik:RadTabControl x:Name="RadTabControl1"

                                                                        Width="702"

                                                                        HorizontalAlignment="Center"

                                                                        Margin="8"

                                                                        VerticalAlignment="Center"

                                          

                                           telerik:TouchManager.IsTouchHitTestVisible="False">

                                    <telerik:RadTabItem Header="Details"

                                                                            DataContext="{Binding}"

                                                                            Margin="10,0,0,0"

                                                                            Height="24">

                                        <Grid Width="Auto"

                                                         HorizontalAlignment="Stretch">

                                            <Grid.RowDefinitions>

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition />

                                                <RowDefinition Height="15" />

                                            </Grid.RowDefinitions>

                                            <Grid.ColumnDefinitions>

                                                <ColumnDefinition Width="Auto" />

                                                <ColumnDefinition Width="Auto" />

                                                <ColumnDefinition Width="Auto" />

                                            </Grid.ColumnDefinitions>

                                            <Border Grid.Column="0"

                                                                     Grid.RowSpan="6"

                                                                     Grid.Row="0"

                                                                     VerticalAlignment="Top"

                                                                     HorizontalAlignment="Stretch"

                                                                     Height="115"

                                                                     Width="115"

                                                                     Margin="15"

                                                                     BorderThickness="1">

 

 

                                            </Border>

                                            <TextBlock Text=" ReoprtId  : "

                                                                        Margin="5,10,0,0"

                                                                        Foreground="Black"

                                                                        FontWeight="Bold"

                                                                        Grid.Row="0"

                                                                        Grid.Column="1" />

                                            <TextBlock Text="{Binding ReoprtId           }"

                                                                        Margin="5,10,0,0"

                                                                        Foreground="Black"

                                                                        Grid.Row="0"

                                                                        Grid.Column="2" />

                                            <TextBlock Text=" Id  : "

                                                                        Margin="5,0,0,0"

                                                                        Foreground="Black"

                                                                        FontWeight="Bold"

                                                                        Grid.Row="1"

                                                                        Grid.Column="1" />

                                            <TextBlock Text="{Binding Id  }"

                                                                        Foreground="Black"

                                                                        Margin="5,0,0,0"

                                                                        Grid.Row="1"

                                                                        Grid.Column="2" />

                                            <TextBlock Text=" Name "

                                                                        Margin="5,0,0,0"

                                                                        Foreground="Black"

                                                                        FontWeight="Bold"

                                                                        Grid.Row="2"

                                                                        Grid.Column="1" />

                                            <TextBlock Text="{Binding Name }"

                                                                        Foreground="Black"

                                                                        Margin="5,0,0,0"

                                                                        Grid.Row="2"

                                                                        Grid.Column="2" />

 

                                            <TextBlock Text="salary "

                                                                             Foreground="Black"

                                                                        Margin="5,0,0,0"

                                                                        FontWeight="Bold"

                                                                        Grid.Row="3"

                                                                        Grid.Column="1"  />

                                            <TextBlock Text="{Binding Salary

}"

                                                                             Margin="5,0,0,0"

                                                                        Foreground="Black"

                                                                        Grid.Row="3"

                                        </Grid>

                                    </telerik:RadTabItem>

                                    <telerik:RadTabItem Header=”Otheremps"   Margin="10,0,0,0"

                                                                            Height="24">

                                       

<local:OtherEmps />                                   

 

</telerik:RadTabItem>

                                    <telerik:RadTabItem Header="Chart"

                                                                            HorizontalContentAlignment="Stretch"

                                                                            HorizontalAlignment="Left" >

                                        <local:RadChart />

                                    </telerik:RadTabItem>

                                </telerik:RadTabControl>

                            </DataTemplate>

                        </telerik:RadGridView.RowDetailsTemplate>

 

                                  

                    </telerik:RadGridView>

 

 

Service1.svc:

 

public List<person> Getempdata()

        {

            List<person>  Persons = new List< person>();

            using (SqlConnection conn = new SqlConnection(con))

            {

                using (SqlCommand cmd = new SqlCommand())

                {

                    cmd.CommandText = "Select * from empdata where Reportid= AM ";

                    cmd.Connection = conn;

                    cmd.CommandType = System.Data.CommandType.Text;

                    conn.Open();

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())

                    {

                        person emp = new person ();

                        emp.Reportid = reader["BoxID"].ToString();

                        emp.Id = Convert.ToString(reader["CostCentre"]);

                        emp.Name= Convert.ToString(reader["Data_chgs"]);

                        emp.salary= reader["DepartmentHead"].ToString();

 

 

                        Persons.Add(emp);

                    }

                }

 

            }

            return Persons;

        }

 

 

MainPage.cs:

 

Called Wcf method:

And binded to Radgridview1

   private void LoadList()

        {

            myServiceClient client = new myServiceClient ();

 

            client.GetEmpnameCompleted += new EventHandler<GetEmpnameCompletedEventArgs>(client_GetEmpdataCompleted);

            client.GetEmpdataAsync();

        }

 

        void client_GetEmpdataCompleted(object sender, GetEmpdataCompletedEventArgs e)

        {

            Radgridview1.ItemsSource = e.Result;

           

        }

 

 

 

 

WE have Got 3 Employees who report to Kabir :

 

Gridview

 

  +        AP                      sneha              8000

-              -                Details                      otheremps                                                                                                    charts

Getting related data      (needs to display the employess who reports to sneha) ???                      ??

 

 

 

+ AC    Rahul     8000

 

 

+ AR    Jyothi    800000

 

 

 

 

In details tab we are getting correct data ..but

 

Now when we expand then we need  other employees who are reporting to these 3 employees and in that 3 radtabcontrols their details and otheremps and chart(heirarachylevel)

Chart…..>(radchart  usernames on x axix and their salaries on y axis)

 

 

 

That means what would be the code to in OtherEmps.xaml

 

 

{ we tried to write other wcf method, passed the reoprtid  as a parameter but when we call this method in mainpage.cs then we failed where exactly it needs to be captured when row expands of Particular emp…)

 

 

 

 

Please Help Me in Coding in the OtherEmps.xaml Present in the Radtabitem

 

 

 

 

 

 

                                   

 

 

                                          

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0
Ivan Ivanov
Telerik team
answered on 19 Jun 2013, 01:50 PM
Hello,

Please, refer to this blogpost that will help you to prepare a sample runnable project. We cannot debug your scenario by having only several loose code snippets. Generally, you can use RadGridView's RowDetainsVisibilityChanging event for such purposes.

Regards,
Ivan Ivanov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Pravalika
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Pravalika
Top achievements
Rank 1
Share this question
or