item template in radgrid view

10 posts, 0 answers
  1. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 27 May 2010 Link to this post

    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.

  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 27 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 01 Jun 2010 Link to this post

    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
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 01 Jun 2010 Link to this post

    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.
  6. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 02 Jun 2010 Link to this post

    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

  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 02 Jun 2010 Link to this post

    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.
  8. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 03 Jun 2010 Link to this post

    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
  9. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 04 Jun 2010 Link to this post

    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
  10. AS
    AS avatar
    8 posts
    Member since:
    Aug 2010

    Posted 12 Aug 2010 Link to this post

    Hi Kevin, did you find a solution to the "gray color" of the disabled column?

    Thanks
  11. Thnghi
    Thnghi avatar
    9 posts
    Member since:
    Feb 2013

    Posted 01 Jul 2013 Link to this post

    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?
Back to Top
DevCraft banner