Hi,
I want to display a column in which a cell is containing icon + some text. So i am using data template. It works at root level but when i load children, it migles up everything!
Is there any way out Or , how can i remove the first column separator ?
Please find attached images for more clarity on the issue.
I want to display a column in which a cell is containing icon + some text. So i am using data template. It works at root level but when i load children, it migles up everything!
Is there any way out Or , how can i remove the first column separator ?
Please find attached images for more clarity on the issue.
3 Answers, 1 is accepted
0
Hello Ishita,
Unfortunately with the supplied information I cannot figure out what is going on. Could you please try to isolate the problem you have in a demo project which we could debug locally? You can check this blog post for a reference, which shows you how to isolate a problem in a sample project.
As for your other question - Is there any way out Or , how can i remove the first column separator ?
You can set CanUserFreezeColumns property to False.
Regards,
Yoan
Telerik
Unfortunately with the supplied information I cannot figure out what is going on. Could you please try to isolate the problem you have in a demo project which we could debug locally? You can check this blog post for a reference, which shows you how to isolate a problem in a sample project.
As for your other question - Is there any way out Or , how can i remove the first column separator ?
You can set CanUserFreezeColumns property to False.
Regards,
Yoan
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

Ishita
Top achievements
Rank 1
answered on 12 Aug 2014, 08:46 AM
Data Template in another xaml page as per my project requirement:
<DataTemplate x:Key="TreeListViewDataTemplate_Icon">
<StackPanel x:Name="stkFirstColumn" Loaded="stkFirstColumn_Loaded" Orientation="Horizontal" DataContext="{Binding}">
<Image x:Name="ImgIcon" Width="16" Height="16" Stretch="Fill" Margin="5,0" Source="{Binding TreeList_IconImage, Converter={StaticResource ConvertByteArrayToImge}}" />
<TextBlock x:Name="TxtFirstColumn"/>
</StackPanel>
</DataTemplate>
Page Containing Treelistview :
public MainPage()
{
InitializeComponent();
#region Datatemplate
GridViewDataColumn column = new GridViewDataColumn();
column.Header = "Name";
if (radTreeListView.Columns.Count == 0)
{
EntityViewDataTemplate dt;
dt = new EntityViewDataTemplate(EntityViewDataTemplate.TemplateType.TreelistViewColumn);
dt.Convert_Parameter = "Name";
dt.TreeListViewIconDataTemplate.Loaded += new RoutedEventHandler(TreeListViewIconDataTemplate_Loaded);
column.CellTemplate = dt.TreeListViewDataTemplateIcon;
column.FilterMemberPath = "Name";
column.IsFilterable = true;
}
else
{
column.DataMemberBinding = new Binding("Name");
}
this.radTreeListView.Columns.Add(column);
#endregion Datatemplate
this.radTreeListView.ItemsSource = WarehouseService.GetWarehouseData();
}
void TreeListViewIconDataTemplate_Loaded(object sender, RoutedEventArgs e)
{
List<object> lstobj = ((List<object>)sender);
StackPanel stk = ((StackPanel)lstobj[0]);
var k = stk.DataContext;
if (k != null)
{
TextBlock TxtFirstColumn = stk.FindName("TxtFirstColumn") as TextBlock;
Image IconImage = stk.FindName("ImgIcon") as Image;
PropertyInfo[] props = k.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
if (lstobj[1] != null)
{
try
{
string data = props.Where(pi => pi.Name.ToLower() == lstobj[1].ToString().ToLower()).FirstOrDefault().GetValue(k, null) as string;
TxtFirstColumn.Text = data;
string source = props.Where(pi => pi.Name.ToLower() == "treelist_iconimage").FirstOrDefault().GetValue(k, null) as string;
Byte[] imgsource = Convert.FromBase64String(source);
if (imgsource is byte[])
{
MemoryStream memStream = new MemoryStream((Byte[])imgsource);
memStream.Seek(0, SeekOrigin.Begin);
BitmapImage empImage = new BitmapImage();
if (memStream.Length > 0)
empImage.SetSource(memStream);
IconImage.Source = empImage;
}
else
IconImage.Source = null;
}
catch (Exception)
{
}
}
}
}
This code leads loading data incorrectly.
How do i attach sample project here ? i tried changing extension but its not working :(
<DataTemplate x:Key="TreeListViewDataTemplate_Icon">
<StackPanel x:Name="stkFirstColumn" Loaded="stkFirstColumn_Loaded" Orientation="Horizontal" DataContext="{Binding}">
<Image x:Name="ImgIcon" Width="16" Height="16" Stretch="Fill" Margin="5,0" Source="{Binding TreeList_IconImage, Converter={StaticResource ConvertByteArrayToImge}}" />
<TextBlock x:Name="TxtFirstColumn"/>
</StackPanel>
</DataTemplate>
Page Containing Treelistview :
public MainPage()
{
InitializeComponent();
#region Datatemplate
GridViewDataColumn column = new GridViewDataColumn();
column.Header = "Name";
if (radTreeListView.Columns.Count == 0)
{
EntityViewDataTemplate dt;
dt = new EntityViewDataTemplate(EntityViewDataTemplate.TemplateType.TreelistViewColumn);
dt.Convert_Parameter = "Name";
dt.TreeListViewIconDataTemplate.Loaded += new RoutedEventHandler(TreeListViewIconDataTemplate_Loaded);
column.CellTemplate = dt.TreeListViewDataTemplateIcon;
column.FilterMemberPath = "Name";
column.IsFilterable = true;
}
else
{
column.DataMemberBinding = new Binding("Name");
}
this.radTreeListView.Columns.Add(column);
#endregion Datatemplate
this.radTreeListView.ItemsSource = WarehouseService.GetWarehouseData();
}
void TreeListViewIconDataTemplate_Loaded(object sender, RoutedEventArgs e)
{
List<object> lstobj = ((List<object>)sender);
StackPanel stk = ((StackPanel)lstobj[0]);
var k = stk.DataContext;
if (k != null)
{
TextBlock TxtFirstColumn = stk.FindName("TxtFirstColumn") as TextBlock;
Image IconImage = stk.FindName("ImgIcon") as Image;
PropertyInfo[] props = k.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
if (lstobj[1] != null)
{
try
{
string data = props.Where(pi => pi.Name.ToLower() == lstobj[1].ToString().ToLower()).FirstOrDefault().GetValue(k, null) as string;
TxtFirstColumn.Text = data;
string source = props.Where(pi => pi.Name.ToLower() == "treelist_iconimage").FirstOrDefault().GetValue(k, null) as string;
Byte[] imgsource = Convert.FromBase64String(source);
if (imgsource is byte[])
{
MemoryStream memStream = new MemoryStream((Byte[])imgsource);
memStream.Seek(0, SeekOrigin.Begin);
BitmapImage empImage = new BitmapImage();
if (memStream.Length > 0)
empImage.SetSource(memStream);
IconImage.Source = empImage;
}
else
IconImage.Source = null;
}
catch (Exception)
{
}
}
}
}
This code leads loading data incorrectly.
How do i attach sample project here ? i tried changing extension but its not working :(
0
Hi Ishita,
Actually, you need to open a support ticket if you want to attach your project.
As for the problem - I would suggest you to create a custom column and override the CreateCellElement method. You can check the Create Custom DateTimePicker Column help article for an example.
Regards,
Yoan
Telerik
Actually, you need to open a support ticket if you want to attach your project.
As for the problem - I would suggest you to create a custom column and override the CreateCellElement method. You can check the Create Custom DateTimePicker Column help article for an example.
Regards,
Yoan
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.