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

RadGridView works too slow

6 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vyacheslav Diliger
Top achievements
Rank 1
Vyacheslav Diliger asked on 14 Apr 2011, 09:57 AM
Hi all.

I have a problem with RadGridView perfomance.

Can you help me, how can I make it faster?

My datasource is List<> of MyObjects.

Most of columns are custom columns with overrided functions (CreateCellElement, CreateCellEditElement, etc.)

Usually I have less than twenty columns.

And even when datasource has less than 300 items grid works too slow.
I mean filtering, sorting, scrolling and columns reordering.

Your's demos here http://demos.telerik.com/silverlight/#GridView/UIVirtualization and
here http://demos.telerik.com/silverlight/#GridView/Performance
works much more faster.

My working machine is laptop with 4GB of memory and AMD Turion 64 X2 1.9 GHz processor.

What can be the cause of the problem?

P.S. And also I want to ask:
I need to hide the filtering window when user clicks filter button, how can I make it? (It is very important)

Thank you.

6 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 14 Apr 2011, 02:15 PM
Hello Vyacheslav,

 I believe the culprit can be your custom columns. Would you mind posting the source code for your custom column implementation?

Best wishes,
Yavor Georgiev
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
Vyacheslav Diliger
Top achievements
Rank 1
answered on 15 Apr 2011, 08:32 AM
Hello, Yavor Georgiev 

For example this is my custom implementation of column with drop-down control:

    public class CustomRefBookColumn : GridViewBoundColumnBase
    {
        SchemaElem schemaElem { get; set; }
        public CustomRefBookColumn(SchemaElem sch)
        {
            schemaElem = sch;
            SortMemberPath = sch.Name + "DisplayValue";
            FilteringControl = new ListBoxFilteringControl(sch.Name);
        }
        
        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            var g = new Grid();
            var tb = new TextBlock();
            var cb = new RefBookElemControl(dataItem, schemaElem);
            cb.HideLable();
            cb.Visibility = Visibility.Collapsed;
            tb.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("CurrentText"), Source = cb });
            g.Children.Add(tb);
            g.Children.Add(cb);
            g.Background = new SolidColorBrush(Colors.Transparent);
            return g;
        }

        public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
        {
            var grid = (Grid) cell.Content;
            var tb = grid.Children[0];
            var cb = new RefBookElemControl((BaseElement)dataItem, schemaElem);
            cb.HideLable();
            tb.Visibility = Visibility.Collapsed;
            cb.Visibility = Visibility.Visible;
            grid.Children.Remove(cb);
            return cb;
        }

        public override object GetNewValueFromEditor(object editor)
        {
            var cb = editor as RefBookElemControl;
            if (cb != null && cb.CurrentText != null)
            {
                return cb.CurrentText;
            }
            return base.GetNewValueFromEditor(editor);
        }
    }
0
Vyacheslav Diliger
Top achievements
Rank 1
answered on 15 Apr 2011, 08:54 AM
And also today I have another problem.
When I migrate to RadControls 2011 Q1 the context menu dont work on the ColumnHeader.
And raise an exception: 

15.04.2011 10:39:54.331: Значение не попадает в ожидаемый диапазон.
   в MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   в MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
   в MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
   в Telerik.Windows.Controls.RadContextMenu.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   в System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   в System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   в System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   в Telerik.Windows.Controls.RadContextMenu.TriggerEventFired()
   в Telerik.Windows.Controls.RadContextMenu.OnEventTriggered(Object sender, EventArgs e)
   в Telerik.Windows.Controls.RadContextMenu.OnElementWithContextMenuMouseClick(Object sender, MouseButtonEventArgs e)
   в MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   в MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

Here is a bit of code where I attaching the ContextMenu to column header:
column.Header = new TextBlock()
                   {
                       Text = schElem.GetTitle(),
                       Foreground = new SolidColorBrush(Colors.Blue),
                       Tag = column,
                       FontWeight = FontWeights.Bold
                   };
                   RadContextMenu.SetContextMenu((TextBlock)column.Header, columnmenu);
                   ((TextBlock)column.Header).MouseMove += ColumnHeader_MouseMove;

Thank you.
0
Yavor Georgiev
Telerik team
answered on 15 Apr 2011, 09:42 AM
Hi Vyacheslav,

 I have a small suggestion which can speed up your custom column. Instead of creating a new RefBookElemControl every time CreateCellElement is called, why don't you try and check if the Content property of the supplied GridViewCell is already a RefBookElemControl and re-use that? This is what all our columns do internally - it saves all the time it takes for the framework to create a new visual element and place it in the tree.

All the best,
Yavor Georgiev
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
Vyacheslav Diliger
Top achievements
Rank 1
answered on 15 Apr 2011, 10:10 AM
Thank you for fast reply.
And what about other my questions (context menu and hiding the filter pop-up) ?

I already tried to do like you said.
And in that case I had another problem.

In the CreateCellElement method 
I often got the GridViewCell cell with reference to RefBookElemControl in another cell

I was very confused when I saw the same controls in the different cells and decide to reject the re-using content of GridViewCell.
And also when I edit any cell some another cells in this column also was affected :(
0
Yavor Georgiev
Telerik team
answered on 15 Apr 2011, 11:34 AM
Hello Vyacheslav,

 Regarding the context menu problem, please take a look at this example. If you have more questions on the topic, please open another thread , we'll be able to help you more efficiently this way.

 The GridViewCell that is passed to the CreateCellElement method is the cell that is currently being re-used by our UI virtualization engine - it will be the cell that contains the object CreateCellElement returns. If you have problems implementing cell content re-use in your custom columns, you can open a separate support ticket and attach your application there and I will be happy to walk you through optimizing your implementation.

 Please take a look at this blog post in order to see how you can customize the built-in filtering control.

Best wishes,
Yavor Georgiev
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
Vyacheslav Diliger
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Vyacheslav Diliger
Top achievements
Rank 1
Share this question
or