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

item template in radgrid view

9 Answers 248 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kevin Tran
Top achievements
Rank 1
Kevin Tran asked on 27 May 2010, 12:32 PM
hi support,
I have a requirement in which i have to display a link in gridview, if user clicks on it i have to open a pop up with java script . How can i do that.

Thanks.

9 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 27 May 2010, 03:44 PM
Hi Kevin Tran,

 Please check out the following article.

Regards,
Yavor Georgiev
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
Kevin Tran
Top achievements
Rank 1
answered on 01 Jun 2010, 10:59 AM
Hi support,
Thanks for your quick response. I need to disable column in radgridview through code. Grid is in sharepoint webpart and i am populating data with WCF
I tried following code, 
 void client_SalesDeskManagerViewCompleted(object sender, SalesDeskManagerViewCompletedEventArgs e) 
        { 
            try 
            { 
               /* ColumnFilterDescriptor ColumnFilter =
             new ColumnFilterDescriptor((IDataFieldDescriptor)this.gvMain.Columns["Status"]);
                ColumnFilter.FieldFilter.Filter1.Operator = FilterOperator.IsNotEqualTo;
                ColumnFilter.FieldFilter.Filter1.Value = "Closed";
                this.gvMain.FilterDescriptors.Add(ColumnFilter);
                ColumnFilterDescriptor ColumnFilter1 =
              new ColumnFilterDescriptor((IDataFieldDescriptor)this.gvMain.Columns["Status"]);
                ColumnFilter1.FieldFilter.Filter1.Operator = FilterOperator.IsNotEqualTo;
                ColumnFilter1.FieldFilter.Filter1.Value = "Disengaged- AM not prepared/ready for service";
                this.gvMain.FilterDescriptors.Add(ColumnFilter1);*/ 
 
                ColumnFilterDescriptor columnfilter = new ColumnFilterDescriptor((IDataFieldDescriptor)this.gvMain.Columns["Status"]); 
                columnfilter.DistinctFilter.DistinctValues.Add("Assigned"); 
                columnfilter.DistinctFilter.DistinctValues.Add("In Progress"); 
                columnfilter.DistinctFilter.DistinctValues.Add("On Hold- Waiting on CPS/SAB"); 
                columnfilter.DistinctFilter.DistinctValues.Add("On Hold- Waiting on AM response"); 
                columnfilter.DistinctFilter.DistinctValues.Add("On Hold- Customer meeting delay"); 
                columnfilter.DistinctFilter.DistinctValues.Add("Delivered - Final"); 
                columnfilter.DistinctFilter.DistinctValues.Add("New"); 
 
                this.gvMain.FilterDescriptors.Add(columnfilter); 
                
                var result = e.Result; 
              
                gvMain.ItemsSource = e.Result; 
                int count = 0; 
                GridViewHeaderRow headerRow = this.gvMain.ChildrenOfType<GridViewHeaderRow>().FirstOrDefault(); 
                if (headerRow != null
                { 
                    GridViewCellBase cell = (from c in headerRow.Cells 
                                             where c.Column.UniqueName == "Assigned" 
                                             select c).FirstOrDefault(); 
                    if (cell != null
                    { 
                        cell.IsEnabled = false
                        MessageBox.Show("header"); 
                    } 
                } 
                foreach (object item in this.gvMain.Items) 
                { 
                    GridViewRow row = this.gvMain.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow; 
                    if (row != null
                    { 
                        GridViewCellBase cell = (from c in row.Cells 
                                                 where c.Column.UniqueName == "Assigned" 
                                                 select c).FirstOrDefault(); 
                        if (cell != null
                        { 
                            cell.IsEnabled = false
                        } 
                        count++; 
                    } 
                } 
                MessageBox.Show(count.ToString()); 
                
                //textBox1.Text = "success"; 
                //gvMain.ToExcelML(); 
 
            } 
            catch (Exception ex) 
            { 
                MessageBox.Show(ex.ToString()); 
                textBox1.Text = ex.ToString(); 
            } 
            finally 
            { 
                gridProgress.Visibility = Visibility.Collapsed; 
            } 
        } 
 

But i am always getting count as zero , I tried to find out cell-formatting event ,but i could not find out that event. I am using Q1 2010 version. In which event i can disable cell.
Thanks
0
Yavor Georgiev
Telerik team
answered on 01 Jun 2010, 02:28 PM
Hi Kevin Tran,

 You can access the columns in the RadGridView.Columns property. If you wish to disable the cells of a column, just set the IsReadOnly property of the column to true and it will propagate to its cells.

All the best,
Yavor Georgiev
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
Kevin Tran
Top achievements
Rank 1
answered on 02 Jun 2010, 02:41 PM
Hi Support,
Read only wont serve my purpose As Column i want to disable is hyperlink column , For particular users i want Hyperlink should be disabled.

Thanks

0
Vlad
Telerik team
answered on 02 Jun 2010, 02:43 PM
Hi,

You can use CellStyleSelector or CellTemplateSelector to style or instantiate different template with desired hyperlink settings.

Greetings,
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
Kevin Tran
Top achievements
Rank 1
answered on 03 Jun 2010, 01:31 PM
Hi support,

I appreciate your help, But i really want to know
  • Is there a possibility to disable column in code behind. though i am able to disable column header through code, 
  • Is there any documentation available for new version Q1 2010.
  • Why cell formatting event is not available in q1 2010 version, 
  • How to use cellstyleselector property? can you suggest me some articles

Thanks
0
Kevin Tran
Top achievements
Rank 1
answered on 04 Jun 2010, 07:16 AM
Hi,
Finally i was able to disable column through code.
 void gvMain_RowLoaded(object sender, RowLoadedEventArgs e) 
        { 
            if (e.Row is GridViewHeaderRow) 
            { 
                 
            } 
            else 
            { 
                if (e.Row != null
                { 
                    GridViewCellBase cell = (from c in e.Row.Cells 
                                             where c.Column.UniqueName == "Assigned" 
                                             select c).FirstOrDefault(); 
                    if (cell != null
                    { 
                        cell.IsEnabled = false
                    } 
                } 
            } 
 
        } 

But the disable column will be in grey colour which is bit odd. So i am trying to change that , Once i am finished i will update with that.

Hope it will help someone 

Thanks
0
AS
Top achievements
Rank 1
answered on 12 Aug 2010, 10:46 PM
Hi Kevin, did you find a solution to the "gray color" of the disabled column?

Thanks
0
Thnghi
Top achievements
Rank 1
answered on 01 Jul 2013, 08:51 AM
Hi,

I change GridViewRow template by my custom template like that:
 
<ControlTemplate x:Key="CustomRowTemplate"
                         TargetType="gridView:GridViewRow">
            <Border x:Name="rowsContainer"
                    Background="Transparent"
                    BorderBrush="{StaticResource BasicBrush}"
BorderThickness="0,0,0,1"
                    Padding="1">
                <Grid Width="Auto"
  HorizontalAlignment="Stretch">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition MinWidth="150" Width="Auto" />
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Border Grid.Column="0"
Grid.RowSpan="3"
Grid.Row="0"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Height="60"
Width="60"
Margin="15,0"
BorderThickness="1"
CornerRadius="1"
BorderBrush="Black">
                        <Image Source="{Binding Picture, Converter={StaticResource BinaryImageConverter}}"
HorizontalAlignment="Center"
VerticalAlignment="Center"></Image>
                    </Border>

                    <TextBlock Text="Device Name: "
Margin="5,0,0,0"
FontWeight="Bold"
Grid.Row="0"
Grid.Column="1"
VerticalAlignment="Center"
   HorizontalAlignment="Left" />
                    <TextBlock Text="{Binding SourceDeviceName}"
   Margin="5,0,0,0"
   Grid.Row="0"
   Grid.Column="2"
   VerticalAlignment="Center"
   HorizontalAlignment="Left" />

                    <TextBlock Text="Source: "
   Margin="5,0,0,0"
   FontWeight="Bold"
   Grid.Row="1"
   Grid.Column="1"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />
                    <TextBlock Text="{Binding SourceId}"
   Margin="5,0,0,0"
   Grid.Row="1"
   Grid.Column="2"
   VerticalAlignment="Center"
   HorizontalAlignment="Left" />

                    <TextBlock Text="Status: "
   Margin="5,0,0,0"
   FontWeight="Bold"
   Grid.Row="2"
   Grid.Column="1"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />
                    <TextBlock Text="{Binding StatusId}"
   Margin="5,0,0,0"
   Grid.Row="2"
   Grid.Column="2"
   VerticalAlignment="Center"
   HorizontalAlignment="Left" />

                    <Border Grid.Column="3"
Grid.Row="0"
Grid.RowSpan="3"
Width="1"
Background="{StaticResource BasicBrush}"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"
Margin="0,10" />

                    <TextBlock Text="Vendor: "
   Margin="5,0,0,0"
   FontWeight="Bold"
   Grid.Row="0"
   Grid.Column="4"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />
                    <TextBlock Text="{Binding VendorId}"
   Margin="5,0,0,0"
   Grid.Row="0"
   Grid.Column="5"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />

                    <TextBlock Text="Brand: "
   Margin="5,0,0,0"
   FontWeight="Bold"
   Grid.Row="1"
   Grid.Column="4"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />
                    <TextBlock Text="{Binding Brand}"
   Margin="5,0,0,0"
   Grid.Row="1"
   Grid.Column="5"
   HorizontalAlignment="Left"
   VerticalAlignment="Center" />

                </Grid>
            </Border>
        </ControlTemplate>
        <Style TargetType="gridView:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
            <Setter Property="Template" Value="{StaticResource CustomRowTemplate}" />

        </Style>

this overites VisualStateManager default and the gridview don't hightlight when mouse over or row selected. 
I just want to change item template of row and remain style such as: mouse over, slelected.

I try to use Itemtemplate in radgridview but it doesn't work.

Can any one help me?
Tags
GridView
Asked by
Kevin Tran
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Kevin Tran
Top achievements
Rank 1
Vlad
Telerik team
AS
Top achievements
Rank 1
Thnghi
Top achievements
Rank 1
Share this question
or