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

It takes a long long time!!!!

3 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 04 Mar 2010, 02:48 PM

Hello....

I am currently working with a grouped RadGridView in which I must add three Sum AggregateFunctions.

The code that I use to do this is the following

radGridInvoiceDetails.ItemsSource = null;
if (CurrentMaster != null)
{
    var collection = from d in dc.InvoiceDetails
                     where d.IdInvoiceMaster == CurrentMaster.Id
                     orderby d.IdProductType, d.ProductDescription, d.BillNumber
                     select d;
                    
    radGridInvoiceDetails.ItemsSource = collection.ToList();
}

GroupDescriptor descriptor = new Telerik.Windows.Data.GroupDescriptor();

descriptor.Member = "ProductFamilyDescription";
descriptor.SortDirection = ListSortDirection.Ascending;
radGridInvoiceDetails.GroupDescriptors.Add(descriptor);

descriptor = new Telerik.Windows.Data.GroupDescriptor();
descriptor.Member = "ProductDescription";
descriptor.SortDirection = ListSortDirection.Ascending;

var sumFunction = new Telerik.Windows.Data.SumFunction();
sumFunction.ResultFormatString = "{0:N2}";
sumFunction.SourceField = "ProductQuantity";
sumFunction.Caption = "Totale Quantità";
descriptor.AggregateFunctions.Add(sumFunction);

sumFunction = new Telerik.Windows.Data.SumFunction();
sumFunction.ResultFormatString = "{0:N2}";
sumFunction.SourceField = "TotalBill";
sumFunction.Caption = "Totale Imponibile";
descriptor.AggregateFunctions.Add(sumFunction);

sumFunction = new Telerik.Windows.Data.SumFunction();
sumFunction.ResultFormatString = "{0:N2}";
sumFunction.SourceField = "TotalVAT";
sumFunction.Caption = "Totale Con IVA";

descriptor.AggregateFunctions.Add(sumFunction);

radGridInvoiceDetails.GroupDescriptors.Add(descriptor);

The result of this is wonderful but it takes up to 90 seconds to load less than 1500 records.

I have read something about QueryableCollectionView but I did not find enough to understand if and how it can help me.

Is there any suggestion to spend less time to have the same result??

Thanks a lot in advance...

Nick

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Mar 2010, 08:09 AM
Hi Nick,

Can you post more info about how the grid is declared (XAML) in your case? You will get such slowness if the grid is inside StackPanel or ScrollViewer since in this case RadGridView will be measured with infinity height and rows virtualization will be off.

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
Nick
Top achievements
Rank 1
answered on 05 Mar 2010, 09:03 AM

Hi Vlad,

this is the XAML code of the radgridview, even if I must say that this loss of time is when the lines of code of my previous post
are executed.

<StackPanel x:Name="panelInvoices" Visibility="Collapsed">
    <GroupBox Header="Lista fatture" >
    .....
    some other controls
    ......
    ......
    </GroupBox>
    <GroupBox Header="Dettaglio fattura" Margin="0,3,0,0">
        <telerik:RadGridView x:Name="radGridInvoiceDetails"
                             ShowGroupPanel="False"
                             AutoGenerateColumns="False"
                             Height="265"
                             Width="920"
                             ItemsSource="{Binding}"
                             HorizontalAlignment="Center">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="ProductFamily" DataMemberBinding="{Binding ProductFamilyDescription}"
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   IsVisible="False"/>
                <telerik:GridViewDataColumn Header="Prodotto"      DataMemberBinding="{Binding ProductDescription}"      
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   IsVisible="False"/>
                <telerik:GridViewDataColumn Header="Numero"        DataMemberBinding="{Binding BillNumberString}"        
                                                                   IsReadOnly="True" IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Data"          DataMemberBinding="{Binding BillDate}"                
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:dd/MM/yyyy}"/>
                <telerik:GridViewDataColumn Header="Qta"           DataMemberBinding="{Binding ProductQuantity}"         
                                                                   IsReadOnly="True" IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Prz.Uni"       DataMemberBinding="{Binding ProductFee}"              
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Tot.Prod"      DataMemberBinding="{Binding ProductTotal}"            
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Scontato"      DataMemberBinding="{Binding ProductDiscountedTotal}"  
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Trasporto"     DataMemberBinding="{Binding TransportTotal}"          
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Scontato"      DataMemberBinding="{Binding TransportDiscountedTotal}"
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Sconto totale" DataMemberBinding="{Binding TotalDiscountAmount}"     
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Imponibile"    DataMemberBinding="{Binding TotalBill}"               
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="IVA"           DataMemberBinding="{Binding VATString}"               
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn Header="Totale"        DataMemberBinding="{Binding TotalVAT}"                
                                                                   IsReadOnly="True"
                                                                   IsFilterable="False"
                                                                   HeaderTextAlignment="Center"
                                                                   Width="Auto"
                                                                   DataFormatString="{}{0:N2}"
                                                                   TextAlignment="Right"/>
                <telerik:GridViewDataColumn x:Name="columnView"
                                            IsFilterable="False"
                                            IsSortable="False"
                                            Width="40"
                                            IsReadOnly="True">
                    <telerik:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadButton x:Name="buttonView"
                                               Click="buttonView_Click"
                                               Background="White"
                                               BorderBrush="White"
                                               Loaded="buttonView_Loaded">
                                <Image Height="20"
                                       Width="20" 
                                       Source=".../...//Edit.png"/>
                                <Button.ToolTip>
                                    <StackPanel Orientation="Horizontal">
                                        <Image  Source=".../...//Edit.png"/>
                                        <Label Content="Visualizza la bolla"/>
                                    </StackPanel>
                                </Button.ToolTip>
                            </telerik:RadButton>
                        </DataTemplate>
                    </telerik:GridViewColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </GroupBox>
</StackPanel>

I also add further information about some of the binding properties

public String ProductFamilyDescription
{
    get
    {
        String value = String.Empty;
        var query = from pt in DataContextFactory.GetDataContext().ProductsTypes
                    where pt.Id == this.IdProductFamily
                    select pt;
        if (query.Count() > 0)
        {
            value = query.First().Description;
        }
        return value;
    }
}
public Decimal ProductTotal
{
    get
    {
        return (Decimal)(this._ProductQuantity) * this._ProductFee;
    }
}

public Decimal ProductDiscountedTotal
{
    get
    {
        return (Decimal)(this._ProductQuantity) * this.ProductDiscountedFee;
    }
}
//where this is
public Decimal ProductDiscountedFee
{
    get
    {
        Decimal fee = this._ProductFee;
        var query = from o in DataContextFactory.GetDataContext().QuarryDiscountOperationTypes
                    where o.Id == this._IdProductDicountOperation
                    select o;
        if (query.Count() > 0)
        {
            switch (query.First().Action.Trim())
            {
                case "%":
                    fee = fee - (fee * (Decimal)this._ProductDiscoutQuantity);
                    break;
                case "=":
                    fee = (Decimal)this._ProductDiscoutQuantity;
                    break;
                case "-":
                    fee -= (Decimal)this._ProductDiscoutQuantity;
                    break;
                default:
                    break;
            }
        }
        return fee;
    }
}

public Decimal TotalDiscountAmount
{
    get
    {
        return this.ProductDiscountAmount + this.TransportDiscountAmount;
    }
}
//where both the property are sums and multiplications of linq class members

Thanks a lot
Nick

 

0
Vlad
Telerik team
answered on 10 Mar 2010, 04:48 PM
Hello Nick,

I've checked your code and while your grid indeed is inside StackPanel you have specified Height and because of this the grid will be measured normally (not with infinity). Can you check if you have any invalid bindings (exceptions in the Visual Studio output) and let me know?

Greetings,
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.
Tags
GridView
Asked by
Nick
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Nick
Top achievements
Rank 1
Share this question
or