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

hierachical (mater-detail) grid join with mvc data on client side problem

6 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
serkanp
Top achievements
Rank 1
serkanp asked on 22 Apr 2011, 09:01 PM
hi i have a problem :)
i am very new on silverlight..
i am good on directx, directshow, winforms, actionscript etc.. but silverlight is very very interesting for me now..

 i have an application works on winforms and i am converting all forms to silverlight from stratch.. (on winforms i am also using telerik radgrid)
the winforms works fast and good..
i am using silverlight because 1- some of our clients uses mac and 2- i am making many changes on application, i dont want to deploy each time ..
on silverlight, i have a problem, maybe it is not a big problem but i couldn't find a way to solve better..

i have 2 table
schedules and schedules_details

schedules table have scheduleID   column
and schedules_details table also have a column named scheduleID
i used telerik orm to connect to sql 2008 express R2 on serverside..
i use linq query to get data from that 2 tables. put them in a single class.
i get data with mvc to silverlight, because i get a large data and i am compressing that single class containing 2 table, with ICSharpCode.SharpZipLib for on serverside and decompressing it with ICSharpCode.SharpZipLib for silverlight. (without compressing, the data is 20mb, when i compress it, it becomes 300kb so i dont want to use ria,domain etc services, i am fine with mvc) .
schedules table have 3 row
and the childs have more than 1.000 rows for each.. each row have 30 columns..

i get them to my silverlight application without any problem. i have each table data.
when i show them seperately on 2 different grid, i can see data without any problem.
4.000 rows of schedules_details comes very fast when i show it seperately on a grid.

but when i put them in hierachical view, it becomes very very very slow..
i see schedules rows fast but when i click on any rows (+) sign to drill down.. it takes more than 3 minutes to show the child.
is there any better way to join those 2 tables and show them faster?
or can you show me an example to join that 2 table and show them simpler as hierachical?

here is the xaml :
<telerik:RadGridView Margin="0,0,0,0" ShowGroupPanel="False" ShowColumnHeaders="True" IsReadOnly="True" IsBusy="False" Name="ScheduleGrid">
                                                    <telerik:RadGridView.ChildTableDefinitions>
                                                        <telerik:GridViewTableDefinition />
                                                    </telerik:RadGridView.ChildTableDefinitions>
                                                    <telerik:RadGridView.HierarchyChildTemplate>
                                                        <DataTemplate>
                                                            <telerik:RadGridView ScrollMode="Deferred" DataLoadMode="Asynchronous" AutoGenerateColumns="True" Name="childGrid" Loaded="childGrid_Loaded" ShowGroupPanel="False" ShowColumnHeaders="True" IsReadOnly="True" IsFilteringAllowed="False" CanUserResizeColumns="False" CanUserFreezeColumns="False" >
                                                            </telerik:RadGridView>
                                                        </DataTemplate>
                                                    </telerik:RadGridView.HierarchyChildTemplate>
                                                </telerik:RadGridView>


and here is the c# code:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            initSettings();
            client.getScheduleForDeviceCompleted += new EventHandler<silverlightservices.getScheduleForDeviceCompletedEventArgs>(client_getScheduleForDeviceCompleted);
            client.getScheduleForDeviceAsync(1); //1 is the id of schedule
        }
 
public silverlightservices.SilverlightServicesstgetSchedule st = new silverlightservices.SilverlightServicesstgetSchedule();
        void client_getScheduleForDeviceCompleted(object sender, silverlightservices.getScheduleForDeviceCompletedEventArgs e)
        {
            Wrappers w = new Wrappers(); //i have a wrapper class to decompress and deserialize
            st = (silverlightservices.SilverlightServicesstgetSchedule)w.DecompressAndDeserialize(st.GetType(), e.Result);
            ScheduleGrid.ItemsSource = null;
            ScheduleGrid.AutoGenerateColumns = true;
            ScheduleGrid.ItemsSource = st.schedule;
//also i have st.scheduledetail  ,
//two table comes with data as i wanted. problem starts here.
//i couldn't join them. so i use child loaded event

        }
 
private void childGrid_Loaded(object sender, RoutedEventArgs e)
        {
             var dataControl = (GridViewDataControl)sender;
            var schedule = (silverlightservices.Schedules)dataControl.ParentRow.DataContext;
//now i get the schedule row
            var detail = new List<schedules_details>();
            var worker = new BackgroundWorker();
            worker.DoWork += (object s, DoWorkEventArgs args) =>
            {
                (from i in st.scheduledetail
                  where i.scheduleID==schedule.scheduleID
                     ).ToList().ForEach(detail.Add);
 
            };
            worker.RunWorkerAsync();
            worker.RunWorkerCompleted += (object s, RunWorkerCompletedEventArgs args) =>
            {
                dataControl.ItemsSource = null;
                dataControl.AutoGenerateColumns = true;
                dataControl.ItemsSource = detail;
            };
        }

i also attached a screenshot, there are 3 split panel. at the right side, you will see the master detail.. 3 rows of schedules, and 1 drilled child..

sorry for my english, it is not my native language.. :))

Serkan

6 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 26 Apr 2011, 08:13 AM
Hi,

 Please define Height for your child grids to improve the performance. 

Regards,
Vlad
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
serkanp
Top achievements
Rank 1
answered on 26 Apr 2011, 10:08 AM
hi Vlad,
thanks for the solution :) simple and effective solution..
it works perfect now..
by the way, what do you think the method i used?
is there any simpler way to show hierachical data?
0
Vlad
Telerik team
answered on 26 Apr 2011, 11:25 AM
Hi Serkan,

 In my opinion it will be better if you avoid events and handle the entire hierarchy with pure MVVM. You can create for example a lazy loaded property for child items and just bind to this structure. 

Kind regards,
Vlad
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
serkanp
Top achievements
Rank 1
answered on 26 Apr 2011, 11:44 AM
thanks for the reply..
but how will i match/assing master and child id ?
i couldnt understand on your examples given with setup..
 can you give a simple example?

thanks
Serkan
0
Accepted
Vlad
Telerik team
answered on 26 Apr 2011, 11:58 AM
Hello,

 You can check for example this blog post

Regards,
Vlad
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
serkanp
Top achievements
Rank 1
answered on 26 Apr 2011, 12:07 PM
thank you very much... :))
case closed... class dismissed :))
Tags
GridView
Asked by
serkanp
Top achievements
Rank 1
Answers by
Vlad
Telerik team
serkanp
Top achievements
Rank 1
Share this question
or