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

Server side paging sorting example

8 Answers 300 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yjh
Top achievements
Rank 1
yjh asked on 21 May 2010, 05:02 PM
Can Telerik provide example of Server side paging and sorting without WCF RIA Service using last build of RadControls ?

8 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 25 May 2010, 08:28 AM
Hello,

Please find attached modified example with our latest binaries.

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.
0
yjh
Top achievements
Rank 1
answered on 26 May 2010, 09:49 AM

Thanks Vlad.

I add three line code to file MyDataContext.cs to make page and sort work as I expected.

    public class MyDataContext
    {
        private int _pageIndex = 0;

        NorthwindServiceSoapClient _Client;
        public NorthwindServiceSoapClient Client
        {
            get
            {
                if (_Client == null)
                {
                    _Client = new NorthwindServiceSoapClient();
                }

                return _Client;
            }
        }

                    Client.GetCustomersCompleted += (s, args) =>
                    {
                        collection.SuspendNotifications();
                        collection.Clear();
                        collection.AddRange(args.Result.Data);
                        collection.ResumeNotifications();

                        _Data.SetIsLoading(false);

                        _Data.Refresh();

                        _Data.SetTotalItemsCount(args.Result.Count);

                        _Data.MoveToPage(_pageIndex);

                        _Data.CollectionChanged += CollectionChanged;
                    };

        void Refresh()
        {
            _pageIndex = _Data.PageIndex;

            Client.GetCustomersAsync(_Data.PageIndex * _Data.PageSize, _Data.PageSize,
                _Data.SortDescriptors.ToDynamicLinq(),
                _Data.FilterDescriptors.ToDynamicLinq(),
                _Data.GroupDescriptors.ToDynamicLinq());
        }

0
yjh
Top achievements
Rank 1
answered on 31 May 2010, 03:04 AM
      public override int TotalItemCount
        {
            get
            {
                return itemCount;
            }
            protected set
            {
                //base.TotalItemCount = value;
            }
        }

I set a breakpoint at TotalItemCount's getter, found it is accessed alomost one hundred times before RadGridView loaded, is that correct?
0
Vlad
Telerik team
answered on 01 Jun 2010, 09:47 AM
Hello,

Since the count is cached there will be no problem to call it multiple times.

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.
0
Stephen
Top achievements
Rank 1
answered on 24 Sep 2012, 05:18 PM
The latest binaries for Silverlight has broken server side paging/sorting sample.  Can we get an updated version now that the ColumnFilterDescriptor is internal?
http://www.telerik.com/community/forums/silverlight/gridview/known-issues-and-breaking-changes---radgridview.aspx
0
Vlad
Telerik team
answered on 25 Sep 2012, 05:31 AM
Hello,

 Here is an example how to update the code:

        public static string ToDynamicLinq(this IColumnFilterDescriptor source)
        {
            var result = new List<string>();


            foreach (var item in source.DistinctFilter.DistinctValues)
            {
                result.Add(String.Format("{0} == {1}", source.Column.UniqueName, item.GetType() == typeof(string) ? 
                    String.Format(@"""{0}""", item) : item));
            }


            return String.Join(" || ", result.ToArray());
        }

Regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Rajat Panwar
Top achievements
Rank 1
answered on 23 Nov 2012, 06:14 AM
Hello

I am using these two methods to try convert VirtualQueryableCollectionView.FilterDescriptors to dynamic linq
public static string ToDynamicLinq(this FilterDescriptorCollection source)
        {
            var result = new List<string>();
 
            foreach (var d in source.OfType<IColumnFilterDescriptor>())
            {
                result.Add(d.ToDynamicLinq());
            }
             
            return String.Join(" && ", result.ToArray());
        }
 
public static string ToDynamicLinq(this IColumnFilterDescriptor source)
        {
            var result = new List<string>();
 
            foreach (var item in source.DistinctFilter.DistinctValues)
            {
                result.Add(String.Format("{0} == {1}", source.Column.UniqueName, item.GetType() == typeof(string) ?
                    String.Format(@"""{0}""", item) : item));
            }
 
            return String.Join(" || ", result.ToArray());
        }

But it does not seams to work. The problem I could see was that in foreach loop, the descriptor are not of type IColumnFilterDescriptor (Check attached image)

rather they are of type Filterdescriptor so extension method taking IColumnFilterDescriptor is not called.

Can you help me achieve filtering. because as of now no matter what filter I apply, ToDynamicLinq() always returns empty string.

A bit on the background why I need this scenario. We have a plain WCF service which is called by Silverlight application. At some places we need to achieve server side filtering and sorting with the help of raddatafilter.
If required you can post any other approach to achieve this but constraint is that we need to use plain wcf only.

Thanks and Regards,
Rajat Panwar
0
Rajat Panwar
Top achievements
Rank 1
answered on 27 Nov 2012, 05:15 AM
We need Server side filtering using pain WCF services and RadDataFilter.
Current examples are outdated and do not work with latest Silverlight libraries from teleik. Above post explains the problem we are facing.

Thanks and Regards,
Rajat Panwar
Tags
GridView
Asked by
yjh
Top achievements
Rank 1
Answers by
Vlad
Telerik team
yjh
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Rajat Panwar
Top achievements
Rank 1
Share this question
or