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

Button or Link Column for Silverlight GridView

13 Answers 348 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mark
Top achievements
Rank 1
mark asked on 18 May 2009, 08:42 PM
I tried searching the web and forums, but I can't find much on how to add a button or link column to the gridview for Silverlight control.  Does anyone have sample code?  xaml sample would be great?  I am trying to let the user click a button or link to delete a row in the grid.  I'm still new to Silverlight and the Telerik controls so forgive me if this is a stupid question.

thanks

13 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 19 May 2009, 06:13 AM
Hello mark,

You can use CellTemplate property of GridViewColumn/GridViewDataColumn. Please check this demo for more info:
http://demos.telerik.com/silverlight/#GridView/CellEditTemplate

<telerik:GridViewDataColumn HeaderText="Name" DataMemberBinding="{Binding Name}">
  <telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
       <Button Content="Delete" />
     </DataTemplate>
   </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>


Sincerely yours,
Vlad
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
mark
Top achievements
Rank 1
answered on 19 May 2009, 08:46 PM
Thank you very much for the response.  That is what I was looking for.  Although, when I tried to implement it, there was no CellTemplate object on the GridViewDataColumn object.  The intellisense is working, but I do not see that object.  Am I missing something?  Here is my namespace declaration:

xmlns

 

:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

 


Here is my entire namespace definition just as an FYI:

<

 

UserControl xmlns:telerikMedia="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.MediaPlayer"

 

 

xmlns:expressionLight="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ExpressionLight"
xmlns:shinyBlue="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ShinyBlue" xmlns:bureauBlack="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.BureauBlack" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

 

 

xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

 

 

xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

 

 

x:Class="ApprovedTitlesControl.Page" Background="Black"

 

 

xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"

 

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"

 

 

xmlns:display="clr-namespace:Cokkiy.Display;assembly=Cokkiy.Display.Carousel"

 

 

Width="auto" Height="auto" >

 



Thanks

0
Vlad
Telerik team
answered on 20 May 2009, 05:49 AM
Hi mark,

Do you have our latest official release?

Regards,
Vlad
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
mark
Top achievements
Rank 1
answered on 20 May 2009, 04:55 PM
No, I currently have the trial software.  I am building a prototype for my managers to prove that we can accomplish with Silverlight(and hopefully your controls) what we need to accomplish over the web.  I think the prototype so far has proven what we need to, so hopefully we will buy your controls in the next few days.  As long as I know that this is functional in the newer builds, that should be good enough.  Thanks for your help on this.

0
mark
Top achievements
Rank 1
answered on 10 Jun 2009, 09:21 PM
hi there...I can get the delete button to appear in the column now, but when it gets clicked, I'm not sure how to get the id of the item that is bound to that row.  Do you have any sample code for that(or just an explanation).  I'm sure it's something simple, but I am having difficulty figuring it out.  I am binding a List<Customer> to the grid.

thanks again.
0
mark
Top achievements
Rank 1
answered on 10 Jun 2009, 09:22 PM
hi there...I can get the delete button to appear in the column now, but when it gets clicked, I'm not sure how to get the id of the item that is bound to that row.  Do you have any sample code for that(or just an explanation).  I'm sure it's something simple, but I am having difficulty figuring it out.  I am binding a List<Customer> to the grid.

thanks again.
0
Vlad
Telerik team
answered on 11 Jun 2009, 05:26 AM
Hi mark,

You can get the row using our extension methods and the row DataContext is your business object:

GridViewRow row = ((Button)sender).ParentOfType<GridVIewRow>();
if(row != null)
{
    Customer c = (Customer)row.DataContext;
}


Best wishes,
Vlad
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
Deven
Top achievements
Rank 1
answered on 18 Jun 2009, 09:19 AM
I am using SL3 and the respective Telerik controls.
I have the following namespaces in the xaml.

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

I am not able to see CellTemplate under GridViewColumn or GridViewDataColumn. I see CellStyle, but that is not what I am looking for. What am I missing here?

0
Vlad
Telerik team
answered on 22 Jun 2009, 07:09 AM
Hi Deven,

Please check if you have our latest SL3 build:
http://www.telerik.com/account/latest-internal-builds.aspx

Best wishes,
Vlad
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
Steven
Top achievements
Rank 1
answered on 15 Apr 2011, 09:51 AM
Hi,

I am using SL 4 with RadGridView but I could not find you extension method ParentOfType<T>

Did you remove it ?
Regards,
S
0
Vlad
Telerik team
answered on 15 Apr 2011, 09:56 AM
Hello,

 This method is part of Telerik.Windows.Controls namespace.

Best wishes,
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
Steven
Top achievements
Rank 1
answered on 15 Apr 2011, 09:58 AM
Thank you !
0
Matt
Top achievements
Rank 1
answered on 29 Jul 2011, 10:50 PM
Vlad:

That template really doesn't seem to quite do what it needs to.  I find that when I select the row, I can see an edit box behind the button, and if I click on it, the row goes into edit mode and I can type into that box.  How do I put a button in the grid and disable editing for that cell?
(I tried setting IsReadOnly = true for the column, but when I did that, I did not get button clicks)
Tags
GridView
Asked by
mark
Top achievements
Rank 1
Answers by
Vlad
Telerik team
mark
Top achievements
Rank 1
Deven
Top achievements
Rank 1
Steven
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or