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

Row-Style depending on Content?

3 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Monika Kogler
Top achievements
Rank 1
Monika Kogler asked on 05 Mar 2010, 02:31 PM
I have following problem: i have a grid with several rows. Several user can edit the content at the same time. To avoid problems with saving data, rows which are currently editing have to be locked.
What i have until now, is a column with the username who is editing the row. If there is no editing, the cell has no value.
What I want: the style of currently editing rows should differ from the other rows e.g. font-style should be italic und light-gray. And the user should not have the possibility to select this row. Please help!
Thx

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Mar 2010, 10:27 AM
Hi,

You can use the approach demonstrated on this blog post to achieve your goal.

Kind regards,
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.
0
Monika Kogler
Top achievements
Rank 1
answered on 14 Mar 2010, 02:44 PM
That's not exactly what I needed: I can use this approche to format the cell with the value, but not the whole row. But I need to style the whole row depending on one cells value. So i can not assign the same converter to each column, because the value which is needed for the formating is only known in one cell. Is there any other approach?

And the second problem is not discussed in the blog at all: how can i make it impossible for the user to select one row?

Thx
0
Milan
Telerik team
answered on 16 Mar 2010, 08:00 AM
Hi Monika Kogler,

You can pretty much reuse the PriceToColorConverter of the sample project to format rows instead of cells. You just need to create a binding for the Background property of every row - you even will not have to create a custom cell style. You could try something like:

public MainPage()
{
    InitializeComponent();
    this.RadGridView1.ItemsSource = GetSampleListOfProducts();
    this.RadGridView1.RowLoaded += new EventHandler<RowLoadedEventArgs>(RadGridView1_RowLoaded);
}
  
void RadGridView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
    var row = e.Row as GridViewRow;
  
    if (row != null)
    {
        Binding binding = new Binding("Price");
        binding.Converter = new PriceToColorConverter();
  
        row.SetBinding(Control.BackgroundProperty, binding);
    }
}

That way the background of every row will be bound to the Price property and the background will be formatted accordingly. 

In regard to the second question you can use the CanUserSelect property to disable UI selection. Unfortunately, setting this property to false will disable all UI selection (not just for a particular row). Could you share more details about this requirement so that we can try to provide you with a better solution.


Sincerely yours,
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.
Tags
GridView
Asked by
Monika Kogler
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Monika Kogler
Top achievements
Rank 1
Milan
Telerik team
Share this question
or