This question is locked. New answers and comments are not allowed.
Hi,
Is this a bug or I did something wrong?
I just used usual way to load Ria service data into gridview, by defualt, it suppose to support Sort when clicking column header.
But looks it doesn't work.
I have an application built under 2010 Q3, not sp1, it has this feature automatically when using Ria Service.
Is this a bug or I should do more work to make it working under 2010 Q3 SP1?
Thanks,
Bill
Is this a bug or I did something wrong?
I just used usual way to load Ria service data into gridview, by defualt, it suppose to support Sort when clicking column header.
But looks it doesn't work.
I have an application built under 2010 Q3, not sp1, it has this feature automatically when using Ria Service.
Is this a bug or I should do more work to make it working under 2010 Q3 SP1?
Thanks,
Bill
8 Answers, 1 is accepted
0
MiddleTommy
Top achievements
Rank 1
answered on 23 Feb 2011, 06:47 PM
I am using Ria and the latest Telerik controls and sorting on columns works for me.
How are you supplying data to the grid? I use EntitySet, EntityCollection or ObservableCollection as the ItemsSource I bind to my grid
How are you supplying data to the grid? I use EntitySet, EntityCollection or ObservableCollection as the ItemsSource I bind to my grid
0
wg
Top achievements
Rank 1
answered on 24 Feb 2011, 04:54 AM
Hi Tommy,
Thanks for your reply.
I am also using EntitySet, EntityCollection. The weird thing is The old applicaiton which is working under 2010 Q3, is not working after upgrading to 2010 Q3 SP1.
I also made an example, you may want to take a look. The grid view version is: 2010.3.1314.1040
Thank you very much.
Bill
Thanks for your reply.
I am also using EntitySet, EntityCollection. The weird thing is The old applicaiton which is working under 2010 Q3, is not working after upgrading to 2010 Q3 SP1.
I also made an example, you may want to take a look. The grid view version is: 2010.3.1314.1040
Thank you very much.
Bill
0
MiddleTommy
Top achievements
Rank 1
answered on 24 Feb 2011, 04:12 PM
I will check it out.
As a side note you shouldn't post your's or microsoft's or telerik's or other's DLLs or PDB files in you test app.
I got in trouble for doing that once (By accident). I would take it down and repost it with out the obj or bin folder from any project.
It also cuts down on size alot.
I think you can only post pictures to the forums. If you want to post a test app you have to open a support ticket.
As a side note you shouldn't post your's or microsoft's or telerik's or other's DLLs or PDB files in you test app.
I got in trouble for doing that once (By accident). I would take it down and repost it with out the obj or bin folder from any project.
It also cuts down on size alot.
I think you can only post pictures to the forums. If you want to post a test app you have to open a support ticket.
0
wg
Top achievements
Rank 1
answered on 24 Feb 2011, 05:10 PM
Hi Tommy,
Thanks for your advice, you are right. I have already taken it out from that site.
Thanks,
Bill
Thanks for your advice, you are right. I have already taken it out from that site.
Thanks,
Bill
0
MiddleTommy
Top achievements
Rank 1
answered on 24 Feb 2011, 09:57 PM
Ah ha you were not using an EntitySet as your ItemsSource. You are using the DomainDataSource.
Personally I never much cared for it. But you are right It does appear that Sorting is broken when a DomainDataSource is used as you ItemsSource. Terlerik needs to check into it (Hint, Hint).
As a work around I use the MVVM pattern. Column sorting works just fine(however it is not server side sorting).
Sorry I couldnt be more help. In the Example Below you could try using the new Rad..CollectionView... thingy (It looks very promising ro MVVM) Also did you know that the RadGridView has its own IsBusy property you can bind to?
public class MyViewModel:INotifyPropertyChanged
{
TestDomainContext ctx;
public MyViewModel()
{
ctx = new TestDomainContext();
ctx.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(IsBusyPropertyChanged);
var q = ctx.GetContactsQuery();
ctx.Load(q);
}
public EntitySet<Contact> Contacts
{
get
{
return ctx.Contacts;
}
}
public bool IsBusy
{
get
{
return DataContext.IsLoading || DataContext.IsSubmitting;
}
}
protected void IsBusyPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsLoading" || e.PropertyName == "IsSubmitting")
{
OnPropertyChanged("IsBusy");
}
}
protected void OnPropertyChanged(string prop)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
}
-------------------------------------------------------------------------------------------------
---------------In your Page-------------------------------------------------------
<telerik:RadGridView AutoGenerateColumns="False"
Grid.Row="1"
IsBusy="{Binding IsBusy}"
ItemsSource="{Binding Contacts}" CanUserFreezeColumns="False" CanUserResizeColumns="True" HorizontalAlignment="Stretch" IsFilteringAllowed="True" IsReadOnly="True" Name="gv" RowHeight="30" RowIndicatorVisibility="Collapsed" SelectionMode="Extended" ShowGroupPanel="False" VerticalAlignment="Stretch" >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
--------------------------In your Page Code Behind
private MyViewModel vm;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DataContext = vm = new MyViewModel();
}
Personally I never much cared for it. But you are right It does appear that Sorting is broken when a DomainDataSource is used as you ItemsSource. Terlerik needs to check into it (Hint, Hint).
As a work around I use the MVVM pattern. Column sorting works just fine(however it is not server side sorting).
Sorry I couldnt be more help. In the Example Below you could try using the new Rad..CollectionView... thingy (It looks very promising ro MVVM) Also did you know that the RadGridView has its own IsBusy property you can bind to?
public class MyViewModel:INotifyPropertyChanged
{
TestDomainContext ctx;
public MyViewModel()
{
ctx = new TestDomainContext();
ctx.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(IsBusyPropertyChanged);
var q = ctx.GetContactsQuery();
ctx.Load(q);
}
public EntitySet<Contact> Contacts
{
get
{
return ctx.Contacts;
}
}
public bool IsBusy
{
get
{
return DataContext.IsLoading || DataContext.IsSubmitting;
}
}
protected void IsBusyPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsLoading" || e.PropertyName == "IsSubmitting")
{
OnPropertyChanged("IsBusy");
}
}
protected void OnPropertyChanged(string prop)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
}
-------------------------------------------------------------------------------------------------
---------------In your Page-------------------------------------------------------
<telerik:RadGridView AutoGenerateColumns="False"
Grid.Row="1"
IsBusy="{Binding IsBusy}"
ItemsSource="{Binding Contacts}" CanUserFreezeColumns="False" CanUserResizeColumns="True" HorizontalAlignment="Stretch" IsFilteringAllowed="True" IsReadOnly="True" Name="gv" RowHeight="30" RowIndicatorVisibility="Collapsed" SelectionMode="Extended" ShowGroupPanel="False" VerticalAlignment="Stretch" >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="FirstName" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="LastName" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
--------------------------In your Page Code Behind
private MyViewModel vm;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DataContext = vm = new MyViewModel();
}
0
wg
Top achievements
Rank 1
answered on 25 Feb 2011, 04:34 AM
Hi Tommy,
Thank you very much. You really helped me a lot. Also the IsBusy of RadGridView, I didn't know that before...
I tried your ViewModel code, it is working, but like you said, it is Client Side sorting,hum... maybe I need wait a new version of telerik silverlight control.
Thank you for your time, Tommy, I have a code snippets you may want to know, but of course you may already have it.
And for raise property change event, can use as this way,
It could avoid typing mistake for property name somehow.
Thank you again,
Bill
Thank you very much. You really helped me a lot. Also the IsBusy of RadGridView, I didn't know that before...
I tried your ViewModel code, it is working, but like you said, it is Client Side sorting,hum... maybe I need wait a new version of telerik silverlight control.
Thank you for your time, Tommy, I have a code snippets you may want to know, but of course you may already have it.
private void OnPropertyChanged<T>(Expression<Func<T>> exp){ //the cast will always succeed MemberExpression memberExpression = (MemberExpression)exp.Body; string propertyName = memberExpression.Member.Name; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }}
And for raise property change event, can use as this way,
private bool _HasValue = false;public bool HasValue{ get { return _HasValue; } set { _HasValue = value; OnPropertyChanged(() => HasValue); }}Thank you again,
Bill
0
Accepted
MiddleTommy
Top achievements
Rank 1
answered on 25 Feb 2011, 04:30 PM
Thanks I had always thought there was a better way to pass around propertychanged info. I often think for such a static language we pass strings around alot.
I found the new thingy from Telerik: QueryableDomainServiceCollectionView<T>
In the View Model use this instead of the EntitySet<Contact> Contacts Property. (I have not tried it yet so I cant give any code) It may help with Server side sorting.
Also I didnt think of it before but you could go back to the non-MVVM way of doing things and try using RadDomainDataSource in xaml instead
I still prefer the MVVM pattern as it alows me to keep my UI "dumb" and keep the smarts in the VM where I can test it easier.
Check it out at.
http://blogs.telerik.com/blogs/posts/10-12-24/introducing_raddomaindatasource_for_silverlight.aspx
I found the new thingy from Telerik: QueryableDomainServiceCollectionView<T>
In the View Model use this instead of the EntitySet<Contact> Contacts Property. (I have not tried it yet so I cant give any code) It may help with Server side sorting.
Also I didnt think of it before but you could go back to the non-MVVM way of doing things and try using RadDomainDataSource in xaml instead
I still prefer the MVVM pattern as it alows me to keep my UI "dumb" and keep the smarts in the VM where I can test it easier.
Check it out at.
http://blogs.telerik.com/blogs/posts/10-12-24/introducing_raddomaindatasource_for_silverlight.aspx
0
wg
Top achievements
Rank 1
answered on 28 Feb 2011, 03:15 PM
Hi Tommy,
I tried RadDomainDataSource, still no luck. Now I have already switched back to 2010 Q3, and it is working well.
I am still learning MVVM, yes, it is good. But for our due day and it is a legacy project which even doesn't have any Unit Test, I am not ready to use it on our current small project. But I will try to use this pattern on the next project.
Again, thank you very much for your help.
Have a good day,
Bill
I tried RadDomainDataSource, still no luck. Now I have already switched back to 2010 Q3, and it is working well.
I am still learning MVVM, yes, it is good. But for our due day and it is a legacy project which even doesn't have any Unit Test, I am not ready to use it on our current small project. But I will try to use this pattern on the next project.
Again, thank you very much for your help.
Have a good day,
Bill