Hi, everyone.
I am doing Winsform Development based on telerik radcontrol at present.
Specifically, I am building the Hierarchical GridView and setting the template caption for the child template.
However, the Template caption didn't show at all. Do I need set up other properties?
Thank you very much. Appreciate any help!!
I am doing Winsform Development based on telerik radcontrol at present.
Specifically, I am building the Hierarchical GridView and setting the template caption for the child template.
However, the Template caption didn't show at all. Do I need set up other properties?
bagTemplate.Caption = "Bag";
if (bagTemplate.Caption != null)
{
//Popup Bag
MessageBox.Show(bagTemplate.Caption.ToString());
}
Thank you very much. Appreciate any help!!
5 Answers, 1 is accepted
0
Hi Hatsuki,
Thank you for writing.
If your grid contains a single child template, it will not have a corresponding tab and its caption will not be visible. To make its caption appear set the ShowChildViewCaptions of the MasterTemplate to true.
I hope this helps. Let me know if you have further queries.
Kind regards,
Boryana
the Telerik team
Thank you for writing.
If your grid contains a single child template, it will not have a corresponding tab and its caption will not be visible. To make its caption appear set the ShowChildViewCaptions of the MasterTemplate to true.
this
.radGridView1.MasterTemplate.ShowChildViewCaptions =
true
;
this
.radGridView1.Templates[0].Caption =
"Bags"
;
I hope this helps. Let me know if you have further queries.
Kind regards,
Boryana
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
divyesh
Top achievements
Rank 1
answered on 31 Mar 2014, 06:05 AM
Hello,
I have a grid in hierarchical format i.e.,
> Car
>>>> Parts of car
>>>> Services done with car
Now, to save space on screen, i want to hide certain rows that are not useful. For example group column, add new row , caption etc.
I could hide certain rows at Master template level, but not at child templates. See attached image for more clarity.
For master or parent level, i could achieve using ,
_radGridView.MasterTemplate.MasterViewInfo.SystemRows[0].IsVisible = false
And for child templates, i tried with system rows and even with ,
this._radGridView.MasterTemplate.ShowChildViewCaptions = false;
But, that does not seem to be working.
Best Regards,
Divyesh Makwana
I have a grid in hierarchical format i.e.,
> Car
>>>> Parts of car
>>>> Services done with car
Now, to save space on screen, i want to hide certain rows that are not useful. For example group column, add new row , caption etc.
I could hide certain rows at Master template level, but not at child templates. See attached image for more clarity.
For master or parent level, i could achieve using ,
_radGridView.MasterTemplate.MasterViewInfo.SystemRows[0].IsVisible = false
And for child templates, i tried with system rows and even with ,
this._radGridView.MasterTemplate.ShowChildViewCaptions = false;
But, that does not seem to be working.
Best Regards,
Divyesh Makwana
0
Hello Divyesh,
Thank you for writing.
When the MasterTemplate has more than one child templates, the ShowChildViewCaptions property does not affect the pageview, displaying the child levels, because the user should be able to switch between the different tabs for example. However, if you use the PageViewMode.ExplorerBar, it is possible to use the ViewCellFormatting event and hide the RadPageViewExplorerBarItem:
As to the question, related to hiding group area and add new row functionality you can use the following code:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for writing.
When the MasterTemplate has more than one child templates, the ShowChildViewCaptions property does not affect the pageview, displaying the child levels, because the user should be able to switch between the different tabs for example. However, if you use the PageViewMode.ExplorerBar, it is possible to use the ViewCellFormatting event and hide the RadPageViewExplorerBarItem:
public
Form1()
{
InitializeComponent();
List<Car> cars =
new
List<Car>();
List<Part> parts =
new
List<Part>();
List<Service> services =
new
List<Service>();
for
(
int
i = 0; i < 3; i++)
{
cars.Add(
new
Car(i,
"Car"
+ i));
for
(
int
j = 0; j < 5; j++)
{
parts.Add(
new
Part(j,
"Name"
+ j,i));
if
(j % 2 == 0)
{
services.Add(
new
Service(j,
"ServiceName"
+ j,i));
}
}
}
radGridView1.DataSource = cars;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewTemplate firstChildtemplate =
new
GridViewTemplate();
firstChildtemplate.DataSource = parts;
radGridView1.MasterTemplate.Templates.Add(firstChildtemplate);
firstChildtemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewRelation relation =
new
GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = firstChildtemplate;
relation.RelationName =
"CarsParts"
;
relation.ParentColumnNames.Add(
"Id"
);
relation.ChildColumnNames.Add(
"CarId"
);
radGridView1.Relations.Add(relation);
GridViewTemplate secondChildtemplate =
new
GridViewTemplate();
secondChildtemplate.DataSource = services;
radGridView1.MasterTemplate.Templates.Add(secondChildtemplate);
secondChildtemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewRelation relation2 =
new
GridViewRelation(radGridView1.MasterTemplate);
relation2.ChildTemplate = secondChildtemplate;
relation2.RelationName =
"CarsServices"
;
relation2.ParentColumnNames.Add(
"Id"
);
relation2.ChildColumnNames.Add(
"CarId"
);
radGridView1.Relations.Add(relation2);
this
.radGridView1.TableElement.PageViewMode = PageViewMode.ExplorerBar;
}
private
void
radGridView1_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridDetailViewCellElement detailCell = e.CellElement
as
GridDetailViewCellElement;
if
(detailCell !=
null
)
{
detailCell.PageViewElement.Header.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
RadPageViewExplorerBarElement el = detailCell.PageViewElement
as
RadPageViewExplorerBarElement;
if
(el !=
null
)
{
foreach
(RadPageViewExplorerBarItem item
in
el.Items)
{
item.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
}
}
}
}
public
class
Car
{
public
int
Id {
get
;
set
; }
public
string
Title {
get
;
set
; }
public
Car(
int
id,
string
title)
{
this
.Id = id;
this
.Title = title;
}
}
public
class
Part
{
public
int
Id {
get
;
set
; }
public
string
PartName {
get
;
set
; }
public
int
CarId {
get
;
set
; }
public
Part(
int
id,
string
name,
int
carId)
{
this
.Id = id;
this
.PartName = name;
this
.CarId = carId;
}
}
public
class
Service
{
public
int
Id {
get
;
set
; }
public
string
SrviceName {
get
;
set
; }
public
int
CarId {
get
;
set
; }
public
Service(
int
id,
string
srviceName,
int
carId)
{
this
.Id = id;
this
.SrviceName = srviceName;
this
.CarId = carId;
}
}
As to the question, related to hiding group area and add new row functionality you can use the following code:
this
.radGridView1.EnableGrouping =
false
;
this
.radGridView1.AllowAddNewRow =
false
;
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
divyesh
Top achievements
Rank 1
answered on 03 Apr 2014, 05:24 AM
Hi Desilava,
Thanks for your response. Based on your suggestion, could hide captions. However, main idea behind hiding caption was to retain that space for actual data. But with suggestion it is still leaving blank space as it is. Any suggestion around that?
See attached file for more clarity.
Best Regards,
Divyesh Makwana
Thanks for your response. Based on your suggestion, could hide captions. However, main idea behind hiding caption was to retain that space for actual data. But with suggestion it is still leaving blank space as it is. Any suggestion around that?
See attached file for more clarity.
Best Regards,
Divyesh Makwana
0
Hello Divyesh,
Thank you for writing back.
In addition to my previous post, you can set the RadPageViewExplorerBarItem.MaxSize property to new Size(0,5):
Please do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Thank you for writing back.
In addition to my previous post, you can set the RadPageViewExplorerBarItem.MaxSize property to new Size(0,5):
private
void
radGridView1_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridDetailViewCellElement detailCell = e.CellElement
as
GridDetailViewCellElement;
if
(detailCell !=
null
)
{
detailCell.PageViewElement.Header.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
RadPageViewExplorerBarElement el = detailCell.PageViewElement
as
RadPageViewExplorerBarElement;
if
(el !=
null
)
{
foreach
(RadPageViewExplorerBarItem item
in
el.Items)
{
item.MaxSize =
new Size(0,5);
item.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
}
}
}
}
Please do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.