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

Insert Row - Problem with Custom Styling

7 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 12 Jan 2011, 08:21 PM
Hello,

I have been using the RadGridView for a project and I am having an issue with custom templating and styling.  I have set up custom styles for the RadGridView, GridViewRows, and a few other controls.

The problem I am having is that my GridViewRow style is not being applied to the "Click here to add new row" row, nor the editable row that appears when you click it.

To further compound everyone's confusion, when I create a basic custom style and apply it to the "NewRowStyle" property, it messes up the way the normal rows as well as the headers of the grid display.


Am I missing a step on applying custom templates and styles?

Thank you.



(For further information, I am using the latest Q3 trial release for WPF.  Development is in Visual Studio 2010).

7 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 13 Jan 2011, 02:49 PM
Hi Jason,

 
If you need to change the appearance of this row you need to edit the template of GridViewNewRow with defined TargetType GridViewNewRow, the style targeted at GridViewRow will not be applied to this row.
You may find attached sample project that demonstrates how to modify GridViewNewRow.

All the best,
Vanya Pavlova
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
Jason
Top achievements
Rank 1
answered on 13 Jan 2011, 04:17 PM
Hi Vanya,

Thank you, that solved that problem.

I have one additional question to ask, though.  When I click on the insert row and the cells go into edit mode, I can't seem to adjust the styling of those cells.  They still show up with the default white background with gold border and black text.  I've gone up and down the custom templates I have set up for both the standard RadGridViewRow as well as the NewRow you just provided and can't seem to find where to adjust those specific colors.  Could you help point me in the right direction please?

Thanks!
~Jason
0
Vanya Pavlova
Telerik team
answered on 14 Jan 2011, 02:20 PM
Hello Jason,

 
You may achieve this result through handling RadGridView's BegginingEdit event as it is shown below:

private void RadGridView1_BeginningEdit(object sender, Telerik.Windows.Controls.GridViewBeginningEditRoutedEventArgs e)
    {
         
        var row=e.Row as GridViewNewRow;
        if(row!=null)
        {
            var cells=row.ChildrenOfType<GridViewCell>().ToList();
            foreach(var cell in cells)
            {
                cell.Background=new SolidColorBrush(Colors.Blue);
                cell.Foreground=new SolidColorBrush(Colors.Yellow);
                                    //here you may refer your own defined style
                                    //cell.Style=this.Resourses["st1"] as Style;
            }
        }
    }

You may also use the following help article that will show you how to control GridViewCell's appearance in its different states:
http://www.telerik.com/help/wpf/gridview-styling-cell.html

 

Best wishes,
Vanya Pavlova
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
Jason
Top achievements
Rank 1
answered on 19 Jan 2011, 05:02 PM
Hi Vanya,

I've been working with this for a few days but I still cannot for the life of me obtain the results that I want.

When I insert a new row, and the first cell goes into edit mode, it always has a white background, orange border, and blue highlight over the black text.  I created a custom style via expression blend but it does not apply at all when the cell is in edit mode.  I am trying to adjust it so that, when you are editing (and thus typing into a cell), it will still be a black background with white text.  Am I missing a step somewhere? 

Thanks,
~Jason
0
Vanya Pavlova
Telerik team
answered on 21 Jan 2011, 04:37 PM
Hi Jason,

 
This occurred because the GridViewCell is in edit mode and the Background of the cell is changed. The white background comes from default editing element, which is a TextBox. In this case you need to handle PreparingCellForEdit event of RadGridView and customize the TextBox in the way you need.

Please find attached a sample project that demonstrates the previous approaches.

Greetings,
Vanya Pavlova
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
David
Top achievements
Rank 1
answered on 06 Nov 2012, 04:30 AM
Hi Telerik,

Attached app is working. However, how can we make sure the AddRow always on the bottom of the grid even after grouping and sorting?
0
David
Top achievements
Rank 1
answered on 06 Nov 2012, 04:30 AM
Hi Telerik,

Attached app is working. However, how can we make sure the AddRow always on the bottom of the grid even after grouping and sorting?
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Jason
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or