Distinguishing the newly added but unsaved rows of RadGridView in Silverlight

10 posts, 0 answers
  1. Ramyashree
    Ramyashree avatar
    29 posts
    Member since:
    Jan 2011

    Posted 18 Jan 2011 Link to this post

    Hi..

        I'm using Wcf Ria service and ADO .net Entity data model for Data Connection.... I can add the new rows to the grid and save them using the  Data context...  I want to distinguish the newly added rows which are not yet saved from the existing ones probably by setting different background colors to them .... Is there any way to do it..?

    Thanks & Regds.,
    Ramya
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 21 Jan 2011 Link to this post

    Hi Ramyashree,

    Here is one idea: you can define an additional property (in a partial class) to your entities, e.g. IsNew and set it to false to all the existing items.
    When you add a new entity - set this property to True.
    You should create a RowStyleSelector and return the correct style depending on the IsNew property as shown here.

    Hope this will get you started.

    Regards,
    Veselin Vasilev
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Ramyashree
    Ramyashree avatar
    29 posts
    Member since:
    Jan 2011

    Posted 24 Jan 2011 Link to this post

    Could you please guide me in detail on how to define that IsNew property...
    I have created another file in the web project in which a partial class with the name of my entity and defined a property called IsNew... But it is not recognised in my silverlight project....

    Thanks & Regds.,
    Ramya
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 31 Jan 2011 Link to this post

    Hi Ramyashree,

    Actually, the easiest way would be to add that additional property to your model.
    Find attached a sample project - I have added a new field to the Employees table, called IsNew.
    I have defined a partial class Employee in the silverlight project and initialized that property to True.

    Then, before submitting the changes to the server I set it to False.

    Please download the project and observe it.

    All the best,
    Veselin Vasilev
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  5. Howell
    Howell avatar
    10 posts
    Member since:
    Jul 2012

    Posted 20 Jun 2011 Link to this post

    Is there any other way on implementing this(without adding a property to the model)? We are trying to style the row based on the Entity.ChangeTracker.State using rowstyleselector. My problem is, if any status changed on the Entity.ChangeTracker.State it does not automatically reflected on the gridview rowstyle since entity.changetracker is not part of the property of the model.
  6. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 21 Jun 2011 Link to this post

    Hi Howell,

    In case you are using Ria Services you could easily create a style selector as the following one:

    public override Style SelectStyle(object item, DependencyObject container)
    {
        var en = item as Entity;
      
        if (en.EntityState == EntityState.New)
        {
            return this.NewStyle;
        }
        else
        {
            return base.SelectStyle(item, container);
        }
    }


    Regards,
    Milan
    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
  7. Howell
    Howell avatar
    10 posts
    Member since:
    Jul 2012

    Posted 21 Jun 2011 Link to this post

    Hi MIlan,

    Yes, I have already got this working. Just to give a overview on what going on, in my project I got a gridview and a save button, everytime you added a row in the gridview it change it's style green(using style selector) which mean it is newly added and it is not committed on the database unless you click on the save button. my problem is when I click on the save button that style on the gridview won't change even when the entitystate was already change. any idea?
  8. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 22 Jun 2011 Link to this post

    Hello Howell,

    Oh, okay. After the changes has been saved you can call the Rebind method of the grid which will reevaluate all Style Selectors for all rows. 

    Hope this helps.

    All the best,
    Milan
    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
  9. David Lattimore-Gay
    David Lattimore-Gay avatar
    1 posts
    Member since:
    Jan 2010

    Posted 28 Dec 2011 Link to this post

    I am using the MVVM design pattern, so to call the reBind on the grid just to get the RowStyleSelector proeprty to work on the Grid, seems somewhat archaic, I would rather have only the row that has changed get its Style changed, is there an approach that would avoid me having to call reBind ? 
  10. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Dec 2011 Link to this post

    Hi David,

     

    Generally if your underlying business object implements INotifyPropertyChanged interface, the changes will be handled correspondingly when using StyleSelectors. Otherwise you have to explictily call the Rebind method of RadGridView. You may check our online demos for further reference. 



    Kind regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top