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

Distinguishing the newly added but unsaved rows of RadGridView in Silverlight

9 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramyashree
Top achievements
Rank 1
Ramyashree asked on 19 Jan 2011, 05:39 AM
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

9 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 21 Jan 2011, 01:03 PM
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>>
0
Ramyashree
Top achievements
Rank 1
answered on 25 Jan 2011, 05:30 AM
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
0
Veselin Vasilev
Telerik team
answered on 31 Jan 2011, 02:15 PM
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>>
0
Howell
Top achievements
Rank 1
answered on 20 Jun 2011, 11:37 PM
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.
0
Milan
Telerik team
answered on 21 Jun 2011, 07:48 AM
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
0
Howell
Top achievements
Rank 1
answered on 21 Jun 2011, 04:15 PM
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?
0
Milan
Telerik team
answered on 22 Jun 2011, 07:57 AM
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
0
David Lattimore-Gay
Top achievements
Rank 1
answered on 28 Dec 2011, 10:15 PM
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 ? 
0
Vanya Pavlova
Telerik team
answered on 29 Dec 2011, 09:29 AM
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 >>

Tags
GridView
Asked by
Ramyashree
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Ramyashree
Top achievements
Rank 1
Howell
Top achievements
Rank 1
Milan
Telerik team
David Lattimore-Gay
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or