8 Answers, 1 is accepted
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.
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());
}
{
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?
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.
http://www.telerik.com/community/forums/silverlight/gridview/known-issues-and-breaking-changes---radgridview.aspx
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());
}
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.
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
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