Hello,
I was hoping to have the ability to Update my RadGrid from a GidViewDetailElement that was implemented as a User Control. When a user clicks on a row in the RadGrid, a separate UserControl is displayed to show the Details of that Row. I want to have the ability for the User to change a value in one of the fields shown in the Details vVew which will ujpdate the row in the base RadGrid. The code was implemented just like your example of "Custom Views" only that i wrapped the Details view as a User Control in a RadHostItem. I'm able to view the data just fine in the User Control, its just not apparent to me how to now pass updates from this UserControl now back to my RadGrid with this GridViewDetailElement implementation or if its even possible. Appreciate anyone who can help on this. Thanks - Doug
i Have included the main pieces of code in how this was implemented.
Here is the code in my MainForm.c file that defines the detailView GridViewDetailElement for my RadGrid rgDetails.
Here is the Class that Defines the GridViewDetailElement (just the relevant code).
And Here is my UserControl Code (relevant code only)
Thanks Doug
I was hoping to have the ability to Update my RadGrid from a GidViewDetailElement that was implemented as a User Control. When a user clicks on a row in the RadGrid, a separate UserControl is displayed to show the Details of that Row. I want to have the ability for the User to change a value in one of the fields shown in the Details vVew which will ujpdate the row in the base RadGrid. The code was implemented just like your example of "Custom Views" only that i wrapped the Details view as a User Control in a RadHostItem. I'm able to view the data just fine in the User Control, its just not apparent to me how to now pass updates from this UserControl now back to my RadGrid with this GridViewDetailElement implementation or if its even possible. Appreciate anyone who can help on this. Thanks - Doug
i Have included the main pieces of code in how this was implemented.
Here is the code in my MainForm.c file that defines the detailView GridViewDetailElement for my RadGrid rgDetails.
private
void
InitializeGridControl()
{
this
.rgDetails.TableElement.SetValue(DockLayoutPanel.DockProperty, Telerik.WinControls.Layouts.Dock.Top);
this
.rgDetails.TableElement.Margin =
new
Padding(10, 0, 10, 10);
this
.detailView =
new
GridViewDetailElement();
this
.rgDetails.GridViewElement.Panel.Children.Insert(1,
this
.detailView);
this
.detailView.SetValue(DockLayoutPanel.DockProperty, Telerik.WinControls.Layouts.Dock.Bottom);
this
.detailView.Margin =
new
Padding(10, 0, 10, 2);
}
Here is the Class that Defines the GridViewDetailElement (just the relevant code).
public
class
GridViewDetailElement : GridVisualElement, IGridView
{
private
RadGridViewElement gridElement;
private
GridViewInfo viewInfo;
public
DetailElement detailPanel;
#region Fields
private
RadHostItem hostDetailView;
#endregion
#region Initialization
protected
override
void
InitializeFields()
{
base
.InitializeFields();
this
.UseNewLayoutSystem =
true
;
this
.Padding =
new
System.Windows.Forms.Padding(10);
this
.StretchHorizontally =
true
;
this
.MinSize =
new
Size(0, 250);
this
.MaxSize =
new
Size(0, 250);
this
.DrawFill =
true
;
this
.Class =
"RowFill"
;
this
.detailPanel =
new
DetailElement();
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
hostDetailView =
new
RadHostItem(detailPanel);
this
.Children.Add(hostDetailView);
}
public
void
Initialize(RadGridViewElement gridElement, GridViewInfo viewInfo)
{
this
.gridElement = gridElement;
this
.viewInfo = viewInfo;
this
.gridElement.GridControl.CurrentRowChanged +=
new
CurrentRowChangedEventHandler(GridControl_CurrentRowChanged);
}
public
void
Detach()
{
this
.gridElement.GridControl.CurrentRowChanged -=
new
CurrentRowChangedEventHandler(GridControl_CurrentRowChanged);
this
.gridElement =
null
;
this
.viewInfo =
null
;
}
public
void
UpdateView()
{
GridViewDataRowInfo dataRow =
this
.GridViewElement.GridControl.CurrentRow
as
GridViewDataRowInfo;
if
(dataRow !=
null
)
{
detailPanel.UpdateUCView(dataRow);
}
}
public
RadGridViewElement GridViewElement
{
get
{
return
this
.gridElement; }
}
public
GridViewInfo ViewInfo
{
get
{
return
this
.viewInfo; }
}
#endregion
#region Event Handlers
private
void
GridControl_CurrentRowChanged(
object
sender, CurrentRowChangedEventArgs e)
{
this
.UpdateView();
}
#endregion
...
}
And Here is my UserControl Code (relevant code only)
public
partial
class
DetailElement : UserControl
{
public
DetailElement()
{
InitializeComponent();
}
public
void
UpdateUCView(GridViewDataRowInfo dataRow)
{
string
statusView;
if
(dataRow !=
null
)
{
statusView = GetSafeString(dataRow.Cells[
"State"
].Value.ToString());
switch
(statusView)
{
case
"Running"
:
picBoxStatus.Image = Properties.Resources.start24;
break
;
case
"Paused"
:
picBoxStatus.Image = Properties.Resources.pause24;
break
;
case
"Stopped"
:
picBoxStatus.Image = Properties.Resources.stop_red24;
break
;
default
:
picBoxStatus.Image = Properties.Resources.warning16;
break
;
}
this
.rTxtServiceOwner.Text = GetSafeString(dataRow.Cells[
"StartName"
].Value.ToString());
this
.rTxtServiceType.Text = GetSafeString(dataRow.Cells[
"ServiceType"
].Value.ToString());
....
}
private
void
rChkTrackService_Click(
object
sender, EventArgs e)
{
// How Do I pass an update from this CheckBox back to my main Grid ???????????????
}
}
Thanks Doug