Telerik Forums
UI for Silverlight Forum
3 answers
59 views
RadDataServiceDataSource does not support service operations that return an IQuerable<T> ?
Muneeb
Top achievements
Rank 2
 answered on 22 Feb 2019
3 answers
97 views
Hi,
I have a raddataservicedatasource setup in my xaml like below:
<telerik:RadDataServiceDataSource x:Name="dataServiceDataSource" 
    AutoLoad="True"   QueryName="Accounts" Margin="320,21,320,193">
                <telerik:RadDataServiceDataSource.DataServiceContext>
                    <local:MyEntities />
                </telerik:RadDataServiceDataSource.DataServiceContext>
            </telerik:RadDataServiceDataSource>
I am trying to filter in the backend using FilterDescriptors but for some reason it never seems to go back to the server and apply the filter descriptors. Also the canload property is false after I add the descriptor to the data source.
Here is the code I am using to do the filtering:
AccountDetailsFilter = new FilterDescriptor("accountID_pk", FilterOperator.IsEqualTo, a.accountID);
dataServiceDataSource.FilterDescriptors.Add(AccountDetailsFilter);

Any advice would be greatly appreciated.
Muneeb
Top achievements
Rank 2
 answered on 22 Feb 2019
1 answer
55 views
Does the RadDataServiceDataSource currently support the Expand option?  It is listed, however I can't seem to get it to return any data from the expanded tables of an OData service.

<telerik:RadDataServiceDataSource x:Name="uxGridRadDS" AutoLoad="False" QueryName="TABLE_NAME_1" Expand="TABLE_NAME_2" LoadingData="RadDataServiceDataSource_LoadingData" LoadedData="RadDataServiceDataSource_LoadedData" />

Thanks,
Travis
Dimitrina
Telerik team
 answered on 04 Nov 2014
1 answer
29 views
Hi, I've been using QDSCV for some time, it’s really great, but still I have several questions trying to seek the answers:
1.      Document says the LoadingData event is the last place that we can change the query, but the fact is if you change the query there, the paging function may act improperly, because the custom query is appended after the Take and Skip, if the custom query contains a Where method,  a wrong TotalEntityCount value will be returned. So I think why doesn’t QDSCV build the entity query after the LoadingData event, or add an BuildingQuery event, so we can prepend custom Linq queries?  Please don’t tell me to use the FilterDescriptor, I really don’t like that.
2.      Why QDSCV makes every thing internal? we can’t build our own QDSCV class base on it.
3.      I can’t get the correct page index in the LoadedData event after change page, and the MovePageTo... calls function improperly.
Dimitrina
Telerik team
 answered on 01 Apr 2014
2 answers
43 views
As others I had to sort before the RadDataPager paging takes action so I solved like this:
  • I created the MyNorthwindContext like in the documentation
  • Then I added a property with my sort, something like
    public class MyNorthwindContext : NorthwindEntities
    {
        public MyNorthwindContext() : base(new Uri("http://services.odata.org/Northwind/Northwind.svc", UriKind.Absolute)){}
     
        public DataServiceQuery<Category> SortedCategories
        {
            get
            {
                if ((this._SortedCategories == null))
                {
                    this._SortedCategories = base.CreateQuery<Category>("Categories")
                        .AddQueryOption("$orderby", "CategoryID desc");
                }
                return this._SortedCategories;
            }
        }
        private DataServiceQuery<Category> _SortedCategories;
    }

  • so

    <telerik:RadDataServiceDataSource Name="categoriesDataSource" QueryName="SortedCategories" AutoLoad="True">

Is that ok?
Maya
Telerik team
 answered on 19 Dec 2013
3 answers
24 views
Hi,
I am using RadDomainDataSource and WCF Services to get data from ms sql database. But I have problem with sorting because I want to implement my own sort logic (natural sort of numbers stored as nvarchar). How can I do that?

Any advice would be greatly appreciated.
With regards 
Mark
Dimitrina
Telerik team
 answered on 16 Aug 2013
13 answers
166 views
Hello Telerik,

Im having trouble with the RadDomainDataServiceDataSource, it is asking me for the System.Data.Service.Client library but my Silverlight project don't use that library anymore.. It is using the Microsoft.Data.Service.Client.SL. I have the 2012.01.320 version of telerik silverlight Extensions.

When I remove the library and add the System.Data.Service.Client I got a problem with the Service Reference because it use the enumeration System.Data.Services.Common.DataServiceProtocolVersion

Please Help me with It


Thank you

Santiago Muñoz
Raja
Top achievements
Rank 1
 answered on 21 Feb 2013
0 answers
48 views
Hello,

I´m using lightswich fro creating  an oData Service. Consuming these data e.g. in a GridView works fine.

But i have no idea, how i can edit, update or insert new data.

Can anybody give me some hints?

Regards
Thomas
Thomas
Top achievements
Rank 1
 asked on 04 Feb 2013
1 answer
108 views
I've been implementing sucessfully the QueryableDataServiceCollectionView using a fully functional MVVM pattern.

I have a gridview, pager and a set of buttons (Save, Reject, Refresh) implementing the ICommand (with the CanExecute) so that they can automatically deactivate/active based on the CollectionView status property HasChanges.

Somehow, this works perfectly until i try to insert a new row using the RadGridView's builtin insert pivot row.

After i insert a record using the above method, the HasChanges property on the QueryableDataServiceCollectionView never gets updated again, even if I update some records.

My goal is to allow to user to produce a set of changes and then use the Submit or Reject changes in the CollectionView.

Facts:
All the CRUD operations are done using the RadGridView's builtin UI operations, there is no code involved for CRUD operations.
This behavior is happening without ever calling SubmitChanges, so there is no server interaction involved in this process.
I can successfully reproduce this behavior by executing the following steps:
1. Edit a row using the RadGridView's builtin edit feature (double click on the cell) and commit the changes to the CollectionView by pressing Enter. Notice that the HasChanges property has changed to True.
2. Undo the operation by calling RejectChanges on the CollectionView. Notice that the HasChanges property has changed to False.
3. Insert a new row using the RadGridView's builtin insert feature (ShowInsertRow="True") and commit the changes to the CollectionView by pressing Enter. Notice that the HasChanges property has changed to True.
4. Undo the operation by calling RejectChanges on the CollectionView. Notice that the HasChanges property has changed to False.
5. After this step, the CollectionView is somehow broken because the HasChanges will never get changed again and will be allways  defaulted to False. You can confirm this by making any change on the RadGridView (updating, inserting or deleting).

This is a issue in my case because it breaks the chain of my Save & Undo buttons making them to never get enabled again because the CanExecute event (ICommand) will allways return false, because HasChanges is allways false.

Here is my ViewModel:

public class ImdbTitlesViewModel : ViewModelBase
    {
        private ImdbDataContext _imdbContext;
 
        private QueryableDataServiceCollectionView<ImdbTitle> _imdbTitlesView;
        public QueryableDataServiceCollectionView<ImdbTitle> ImdbTitlesView
        {
            get { return _imdbTitlesView; }
        }
 
        public IEnumerable<ImdbTitle> ImdbTitles
        {
            get
            {
                return this._imdbTitlesView;
            }
        }
 
        private ImdbTitle _selectedTitle;
        public ImdbTitle SelectedTitle
        {
            get { return this._selectedTitle; }
            set {
                if (this._selectedTitle != value)
                {
                    this._selectedTitle = value;
                    RaisePropertyChanged("SelectedTitle");
                }
            }
        }
         
 
        private bool _isBusy;
        public bool IsBusy
        {
            get { return this._isBusy; }
            set
            {
                if (this._isBusy != value)
                {
                    this._isBusy = value;
                    RaisePropertyChanged("IsBusy");
                }
            }
        }
 
        public RelayCommand Startup { get; set; }
        public RelayCommand Refresh { get { return LoadImdbTitles; } set { LoadImdbTitles = value; } }
        public RelayCommand LoadImdbTitles { get; set; }
        public RelayCommand SaveChanges { get; set; }
        public RelayCommand RejectChanges { get; set; }
 
        /// <summary>
        /// Initializes a new instance of the ImdbTitlesViewModel class.
        /// </summary>
        public ImdbTitlesViewModel()
        {
            Startup = new RelayCommand(OnStartup);
            LoadImdbTitles = new RelayCommand(OnLoadImdbTitles, CanLoadImdbTitles);
            SaveChanges = new RelayCommand(OnSaveChanges, CanSaveChanges);
            RejectChanges = new RelayCommand(OnRejectChanges, CanRejectChanges);
 
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real": Connect to service, etc...
                this._imdbContext = new ImdbDataContext();
                this._imdbTitlesView = new QueryableDataServiceCollectionView<ImdbTitle>(this._imdbContext, this._imdbContext.ImdbTitles);
                this._imdbTitlesView.LoadedData += new EventHandler<Telerik.Windows.Controls.DataServices.LoadedDataEventArgs>(OnImdbTitlesViewLoadedData);
                this._imdbTitlesView.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnImdbTitlesViewPropertyChanged);
                this._imdbTitlesView.PageSize = 25;
                this._imdbTitlesView.AutoLoad = true;
                this._imdbTitlesView.SubmittedChanges += new EventHandler<Telerik.Windows.Controls.DataServices.DataServiceSubmittedChangesEventArgs>(OnImdbTitlesViewSubmittedChanges);
            }
        }
 
        void OnImdbTitlesViewSubmittedChanges(object sender, Telerik.Windows.Controls.DataServices.DataServiceSubmittedChangesEventArgs e)
        {
            if (e.HasError)
            {
                e.MarkErrorAsHandled();
                MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show("Changes saved successfully!", "Notification", MessageBoxButton.OK);
            }
        }
 
        void OnImdbTitlesViewPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("IsBusy"))
            {
                this.IsBusy = this._imdbTitlesView.IsBusy;
            }
 
            if(e.PropertyName.Equals("HasChanges"))
            {
                SaveChanges.RaiseCanExecuteChanged();
                RejectChanges.RaiseCanExecuteChanged();
            }
             
        }
 
        void OnImdbTitlesViewLoadedData(object sender, Telerik.Windows.Controls.DataServices.LoadedDataEventArgs e)
        {
            if (e.HasError)
            {
                e.MarkErrorAsHandled();
                MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButton.OK);
            }
        }
 
        private void OnStartup()
        {
            // We dont need to startup because the DataView has the property AutoLoad = true
            //GetImdbTitles();
        }
 
        private bool CanLoadImdbTitles()
        {
            return !IsBusy;
        }
 
        private void OnLoadImdbTitles()
        {
            // Execute the query.
            //this.RejectChanges.Execute(null);
            this._imdbTitlesView.Load(true);
            //this._imdbTitlesView.Load(true);
        }
 
        private bool CanSaveChanges()
        {
            if (this.IsBusy)
                return false;
 
            if (this._imdbTitlesView.HasChanges)
                return true;
 
            return false;
        }
 
        private void OnSaveChanges()
        {
            this._imdbTitlesView.SubmitChanges();
        }
 
        private void OnRejectChanges()
        {
            this._imdbTitlesView.RejectChanges();
        }
 
        private bool CanRejectChanges()
        {
            if (this.IsBusy)
                return false;
 
            if (this._imdbTitlesView.HasChanges)
                return true;
            else
                return false;
        }
 
 
        public override void Cleanup()
        {
            // Clean own resources if needed
            base.Cleanup();
        }
    }
Rossen Hristov
Telerik team
 answered on 29 Feb 2012
1 answer
88 views
Hello!

I'm using the RadDataServiceDataSource with RadGridView and RadDataPager, everthing is working fine except one thing. My DataServiceDataSource's query is a View located in my model file. Since ORDER BY clauses are not allowed in Views, I try to use SortDescriptor to sort the Items on GridView Ascending when it is loaded.

But when I test it, the data comes in a strange way, Example, my DataPager is set up to show 30 records per page, But with the SortDescriptor every page comes With "A" in it's start.

Is there a way to Sort the records in the GridView with DataPager and DataServiceDataSource?

Thanks
Rossen Hristov
Telerik team
 answered on 26 Dec 2011
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?