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

[Solved] Associating editor to GridView row programatically

5 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ketaki
Top achievements
Rank 1
Ketaki asked on 13 May 2009, 11:18 AM
Hi,

Is there is any way of binding the editor programatically to a gridview "row" similar to the column?
We can achieve following association of editor with column:
e.g. ((GridViewDataColumn)this.RadGridView1.Columns[3]).EditorSettings = comboBoxEditorSettings; 

But I want to bind the editor to each row in a datagrid view.
Scenario: There is a data grid with 2 columns. First column shows Name and second column shows the value. This value will decide which editor should be associated (which internally will be decided on enum value.)
e.g. Value = 1(enum), bind ComboBoxEditor, Value = 2(enum) bind DateTimeEditor
I searched on telerik forums but did not find anything useful for this particular scenario.

Any suggestions?

5 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 16 May 2009, 07:00 AM
Hello Ketaki,

This functionality is not supported by the RadGridView out of the box, but you can do that with a few lines of code.
You can hook for the RadGridView.BeginningEditEvent which occurs before real creation of the editor, so there you can change EditorSettings of the cell's parent column. I'm attaching a sample project for your reference.

P.S. Note that changing EditorSettings of a column will affect every cell in that column. Type of the GridViewCell.Editor depends on the current value of the GridViewDataColumn.EditorSettings.

All the best,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ketaki
Top achievements
Rank 1
answered on 18 May 2009, 05:41 AM
Hi Nedyalko,
 
Definately the example you have given is helpful. Thanks.
I might need your help in case there are some unknown areas.
One question which I forgot to mention in the previous post is: Can we also associate browse button to the row instead of editors in few cases?

Also, is there any provision to apply alternate styles to the rows of a grid and also for treeview?
If yes, can you provide me guildline for doing it?

Thanks,
Ketaki
0
Nedyalko Nikolov
Telerik team
answered on 21 May 2009, 08:45 AM
Hi Ketaki,

You can take a look at this online example which demonstrates how to add hyperlink in a GridViewCell, of course if you prefer browse button the idea is the same.

If you need just "Zebra effect" you can use RadGridView.UseAlternateRowStyle to enable default alternation (available for Office_Black and Vista themes after 2009_Q1_SP2). The RadGridView.RowStyle property allows you to customize look and feel of all rows. If you need some special "Zebra effect", you can use also RadGridView.AlternateRowStyle, but do not forget to enable RadGridView.UseAlternateRowStyle.

P.S. The 2009_Q1_SP2 will be available later today, along with the release there will be a very nice help topic about UI customizations.

Best wishes,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jtby
Top achievements
Rank 1
answered on 08 Jul 2009, 08:19 PM
cannot get alternating rowstyle as you describe - I just get the gridview with office black default theme, and no alternating rows - all rows look the same.  Any ideas?

<

 

grid:RadGridView Name="callGrid"

 

 

CanUserInsertRows="False"

 

 

UseAlternateRowStyle="True"

 

 

IsReadOnly="True"

 

 

Margin="11,1,11,11"

 

 

Height="auto" Width="auto">

 

 

 

</grid:RadGridView>

 

 

Private Sub setCallsGrid()

 

 

   callGrid.ItemsSource = GetCalls()

 

   callGrid.UseAlternateRowStyle =

True

 

 

 

 

 

End Sub

 

 

 

 

 

 

Private Function GetCalls() As ObservableCollection(Of ECall)

 

 

      Dim calls As New ObservableCollection(Of ECall)()

 

 

      Dim i As Integer

 

 

 

 

 

      For i = 1 To 100

 

 

         Dim c1 As New ECall

 

         c1.Address =

"muffin street"

 

 

 

 

         calls.Add(c1)

 

      Next

 

 

 

 

 

      Return calls

 

 

End Function

 

0
Nedyalko Nikolov
Telerik team
answered on 09 Jul 2009, 03:21 PM
Hello jtby,

Indeed Office_Black theme which came with 2009.1.413 version has no build in template for alternation row.
Please try the latest version. Everything seems to be OK with "alternation rows" functionality.

Sorry for the inconvenience caused.

All the best,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Ketaki
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Ketaki
Top achievements
Rank 1
jtby
Top achievements
Rank 1
Share this question
or