Hello Telrik Team,
I am working with RadGridView. I am facing some problems.
1. while working on gridviewcomboboxcolumn. I am able to bind grid and column both with itemsource but problem is if i click on cell then only values will be get displayed otherwise it will be blank. Please refer attached screen shots img1 and img2. Is it possible to show grid datamemberbinding values as selected values in combo box by default in perticular column.
2. how to apply style in GridView header. my problem is i want to increase header height ,text wrap and want to change header color, font size etc.
3. is it possible to add a blank row in grid by default?
4. is it possible to show all the controls as per columns in Radgridview footer. if it is possible then how to perform adding a new row functionality from footer?
5. how to open one HTML editor on click of a image button which is in Grid.
6. how to bind Listbox in Grid column?
7. how to align checkbox or others controls which are in grid column.
Please reply me ASAP.
Thanks
Chetan
4 Answers, 1 is accepted
1. Most probably the reason for this behavior is incorrect setting of the DateMemberBinding Property of the GridViewComboBoxColumn. You may take a look at this or this forum threads for further reference on the same issue.
2. You may define a style in the Resource section, targeting the GridViewHeaderCell:
<UserControl.Resources> <Style TargetType="telerik:GridViewHeaderCell"> <Setter Property="Background" Value="HotPink"/> <Setter Property="FontSize" Value="15" /> </Style> <Style TargetType="telerik:GridViewHeaderRow"> <Setter Property="Background" Value="HotPink" /> </Style></UserControl.Resources><telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"> <telerik:GridViewDataColumn.Header> <TextBlock TextWrapping="Wrap" Text="{Binding Number}" /> </telerik:GridViewDataColumn.Header></telerik:GridViewDataColumn>3. If you aim at prompting the user to insert new row, you can easily set the ShowInsertRow property of the grid to "True". Thus you will get the functionality of adding a new item using the grid UI.
4. I am not exactly sure what is the result you want to achieve, so I would need more details on it. In the mean time, you may take a look at our demos, demonstrating how to work and change the column footers.
5. You can just handle the Click event of that particular button and perform the desired actions.
6. I am not quite aware of what you mean bu binding ListBox on a column. Do you want to create something like the GridViewComboBoxColumn ?
7. There a couple of options here. You may either edit the CellEditTemplate/ CellTemplate of a particular column and align the content inside to be centered for example. Another possible approach may be to define a style, targeting GridViewCell and set it to the desired columns. For example:
<UserControl.Resources> <Style x:Key="MyCellStyle" TargetType="telerik:GridViewCell"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style></UserControl.Resources><telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsMarried}" CellStyle="{StaticResource MyCellStyle}" />Sincerely yours,
Maya
the Telerik team
Still i am having same problem in GridViewCheckBoxColumn.
this time i am sending you code also. please check and let me know ,What am I doing wrong? . I am doing everything in Xaml.
In RadGridView
<telerik:RadGridView x:Name="gridViewTaskPlanning"
Grid.Row="1" ItemsSource="{Binding TaskList}" Style="{StaticResource CustomGridHeaderStyle}" ShowColumnFooters="True" >
<telerik:RadGridView.Columns>
<telerik:GridViewComboBoxColumn
Header="Feature Name"
DataMemberBinding="{Binding FeatureID}"
SelectedValueMemberPath="FeatureID"
DisplayMemberPath="FeatureName"
ItemsSource="{Binding FeatureList}"
ItemTemplate="{StaticResource FeatureComboBoxCustomTemplate}"
IsSortable="True" Width="200" IsResizable="False" >
</telerik:GridViewComboBoxColumn>
</telerik:RadGridView.Columns>
RadGridView ItemSource - TaskList
ComboboxItemSource - FeatureList
Want to show FeatureName as displaymember.
FeatureID is in both Datasoucres.
in FeatureComboBoxCustomTemplate :
<DataTemplate x:Key="FeatureComboBoxCustomTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Feature Number"
FontWeight="Bold"
TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="Feature Name"
FontWeight="Bold" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="UseCase Name"
FontWeight="Bold" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding FeatureNumber}" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding FeatureName}" />
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding UseCaseName}" />
</Grid>
</DataTemplate>
Waiting for your reply ASAP
Thanks
Chetan
I tried to reproduce the issue you specified, but I was not able to. I am sending you the sample project I used for testing the problem. You may take a look at it and relate on it as a reference.
Maya
the Telerik team
Thanks for your reply . I got your code and applied same code but still same problem.i am not able to send my solution bez its size is more then 2MB but with this i am sending you Xaml, Xaml.cs.
please check and let me know where i am wrong.
Pleae rply ASAP.
Xaml code :------------------------
<UserControl xmlns:telerikEditor="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Editor" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="StackedBarChartControl.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls">
<UserControl.Resources>
<DataTemplate x:Key="FeatureComboBoxCustomTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Department: " TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="ID:" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DeptName}" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding DeptId}" />
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<telerik:RadButton x:Name="btnDelete" Margin="395,12,12,428" Content="Delete">
</telerik:RadButton>
<telerik:RadGridView x:Name="RadGrid" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<telerik:GridViewDataColumn Header="Day" DataMemberBinding="{Binding Day}" Width="*" />
<telerik:GridViewDataColumn Header="Allocated Hours" DataMemberBinding="{Binding AllocatedHours}" Width="50" >
<telerik:GridViewColumn.Header>
<TextBlock Text="Allocated Hours" VerticalAlignment="Center" TextWrapping="Wrap" />
</telerik:GridViewColumn.Header>
<telerik:GridViewColumn.Footer>
<TextBlock x:Name="TotalAllocatedHours" Text="Total is 300"></TextBlock>
</telerik:GridViewColumn.Footer>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Remaining Hours" DataMemberBinding="{Binding RemainingHours}" Width="*" />
<telerik:GridViewDataColumn Header="Calculated Hours" DataMemberBinding="{Binding CalculatedHours}" Width="*"/>
<telerik:GridViewDataColumn Header="Not Calculated Hours" DataMemberBinding="{Binding NotCalculatedHours}" Width="*" />
<telerik:GridViewComboBoxColumn Header="Department" Width="*"
DisplayMemberPath="DeptName"
SelectedValueMemberPath="DeptId"
DataMemberBinding="{Binding DepartMentId, Mode=TwoWay}"
ItemTemplate="{StaticResource FeatureComboBoxCustomTemplate}">
</telerik:GridViewComboBoxColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</UserControl>
xaml.cs -----
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
//using ChartDB;
using Telerik.Windows.Controls;
using System.Windows.Data;
namespace StackedBarChartControl
{
public partial class Shell : UserControl
{
public Shell()
{
InitializeComponent();
RadGrid.ItemsSource = ChartCollection.GetChartRecords();
((GridViewComboBoxColumn)(RadGrid.Columns[6])).ItemsSource = ChartCollection.GetComboBoxData();
}
}
#region Entity
public class ChartEntity
{
public DateTime Day { get; set; }
public double AllocatedHours { get; set; }
public double RemainingHours { get; set; }
public double CalculatedHours { get; set; }
public double NotCalculatedHours { get; set; }
public string DepartMentId { get; set; }
public string DepartMentName { get; set; }
}
public class DepartmentEntity
{
public int DeptId { get; set; }
public string DeptName { get; set; }
}
#endregion
#region Collection
public class ChartCollection
{
public static List<ChartEntity> GetChartRecords()
{
List<ChartEntity> chartCollection = new List<ChartEntity>();
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("10/08/2010"), AllocatedHours = 285.5, RemainingHours = 25.5, CalculatedHours = 22.3, NotCalculatedHours = 11.5, DepartMentName = "Technical" });
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("11/08/2010"), AllocatedHours = 185.5, RemainingHours = 125.5, CalculatedHours = 122.3, NotCalculatedHours = 21.5, DepartMentName = "Account" });
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("12/08/2010"), AllocatedHours = 385.5, RemainingHours = 225.5, CalculatedHours = 32.3, NotCalculatedHours = 16.5, DepartMentName = "HR" });
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("13/08/2010"), AllocatedHours = 85.5, RemainingHours = 345.5, CalculatedHours = 42.3, NotCalculatedHours = 19.5, DepartMentName = "HR" });
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("14/08/2010"), AllocatedHours = 485.5, RemainingHours = 65.5, CalculatedHours = 62.3, NotCalculatedHours = 41.5, DepartMentName = "Account" });
chartCollection.Add(new ChartEntity { Day = Convert.ToDateTime("15/08/2010"), AllocatedHours = 35.5, RemainingHours = 75.5, CalculatedHours = 52.3, NotCalculatedHours = 71.5, DepartMentName = "Technical" });
return chartCollection;
}
public static List<DepartmentEntity> GetComboBoxData()
{
List<DepartmentEntity> chartCollection = new List<DepartmentEntity>();
chartCollection.Add(new DepartmentEntity { DeptId = 1, DeptName = "HR" });
chartCollection.Add(new DepartmentEntity { DeptId = 2, DeptName = "Account" });
chartCollection.Add(new DepartmentEntity { DeptId = 2, DeptName = "Technical" });
return chartCollection;
}
}
#endregion
}
thanks
Chetan