i am trying to create dynamic grid listing setting page. User will configre their report and grid options. and u ser can set grid column order and header text using dock.
1- but i have problem about that because i am creating docking dynamicly, and creating TitlebarTempalte dynamicly and creating ContentTempalte dynamicly, but when user fill the content , i cant reach docks content over the server button.
2- In demos, they show us keep dock state infos Using Session. But i need use ViewState. Not Session.When I change Session to ViewState .net error serialaziton problem.
Thats my code :
private RadDock CreateRadDock(String columnName)
{
RadDock dock = new RadDock();
dock.DockMode =
DockMode.Docked;
dock.EnableViewState =
true;
dock.EnableAnimation =
true;
dock.UniqueName =
Guid.NewGuid().ToString().Replace("-", "a");
dock.ID =
string.Format("RadDock{0}", dock.UniqueName);
dock.Title = columnName;
dock.Text = columnName;
dock.Width = System.Web.UI.WebControls.
Unit.Percentage(100);
dock.EnableRoundedCorners =
true;
dock.ExpandText =
"Settings";
dock.Commands.Add(
new DockCloseCommand());
System.Web.UI.WebControls.
Image mg = new System.Web.UI.WebControls.Image();
mg.Style.Add(
"float", "left");
mg.ImageUrl =
"~/Image/information.png";
mg.ID =
"mg" + dock.ID;
dock.TitlebarTemplate = new TitleBarTemplate(dock.Text);
dock.TitlebarContainer.Controls[0].FindControl(
"PanelForTitle").Controls.Add(mg);
dock.ContentTemplate =
new ContentTemplate(dock.Text);
return
dock;
}
public
class ContentTemplate : ITemplate
{
Panel pContainer = new Panel();
Panel pControls = new Panel();
CheckBox chkIsHidden = new CheckBox();
String columnName = String.Empty;
public ContentTemplate(String columnName)
{
this.columnName = columnName;
}
public void InstantiateIn(Control container)
{
Table tbl = new Table();
TableRow row = null;
TableCell cell = null;
// NEW ROW FOR HEADER TEXT
// ROW 1 (HEADER TEXT)
//LABEL
row =
new TableRow();
cell =
new TableCell();
Label lblText = new Label();
lblText.ID =
"lblTitle";
lblText.CssClass =
"rdcontent";
lblText.Text =
"Kolon Bal : ";
cell.Controls.Add(lblText);
row.Controls.Add(cell);
// TEXTBOX
cell =
new TableCell();
TextBox tb = new TextBox();
tb.Text =
this.columnName;
tb.ID =
"txtHeader";
tb.AutoPostBack =
true;
tb.MaxLength = 100;
tb.Width =
new System.Web.UI.WebControls.Unit(200);
cell.Controls.Add(tb);
row.Controls.Add(cell);
tbl.Controls.Add(row);
// ROW 2 (HIDDEN STATUS)
row =
new TableRow();
//LABEL
cell =
new TableCell();
lblText =
new Label();
lblText.ID =
"lblHidden";
lblText.CssClass =
"rdcontent";
lblText.Text =
"Gizli Kolon ";
cell.Controls.Add(lblText);
row.Controls.Add(cell);
//CHECKBOX
cell =
new TableCell();
CheckBox chkIsHidden = new CheckBox();
chkIsHidden.ID =
"cbIsHidden";
chkIsHidden.Checked =
false;
cell.Controls.Add(chkIsHidden);
row.Controls.Add(cell);
tbl.Controls.Add(row);
// ROW 3 (FILTER)
row =
new TableRow();
//LABEL
cell =
new TableCell();
lblText =
new Label();
lblText.ID =
"lblFilter";
lblText.CssClass =
"rdcontent";
lblText.Text =
"Filtreye Dahil Et ";
cell.Controls.Add(lblText);
row.Controls.Add(cell);
//CHECKBOX
cell =
new TableCell();
CheckBox chkIsFilter = new CheckBox();
chkIsFilter.ID =
"cbIsFilter";
chkIsFilter.Checked =
false;
cell.Controls.Add(chkIsFilter);
row.Controls.Add(cell);
tbl.Controls.Add(row);
pControls.ID =
"PanelForContent";
pControls.Controls.Add(tbl);
container.Controls.Add(pControls);
}
}
public class TitleBarTemplate : ITemplate
{
Label lblText = new Label();
Panel pContainer = new Panel();
Panel pControls = new Panel();
String columnName = String.Empty;
public TitleBarTemplate(String columnName)
{
this.columnName = columnName;
}
public void InstantiateIn(Control container)
{
Literal l;
lblText.ID =
"lblTitleText";
lblText.Text =
this.columnName;
pControls.ID =
"PanelForTitle";
l =
new Literal();
l.Text =
"<table style='float: left;'><tr><td class='rdcontent'>";
pContainer.Controls.Add(l);
pContainer.Controls.Add(lblText);
l =
new Literal();
l.Text =
"</td><td>";
pContainer.Controls.Add(l);
pContainer.Controls.Add(pControls);
l =
new Literal();
l.Text =
"</td></tr></table>";
pContainer.Controls.Add(l);
container.Controls.Add(pContainer);
}
}
after that i raise on page_int to keep dock states :
protected void Page_Init(object sender, EventArgs e)
{
//// check source is changing
////Recreate the docks in order to ensure their proper operation
for (int i = 0; i < CurrentDockStates.Count; i++)
{
RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
//We will just add the RadDock control to the RadDockLayout.
// You could use any other control for that purpose, just ensure
// that it is inside the RadDockLayout control.
// The RadDockLayout control will automatically move the RadDock
// controls to their corresponding zone in the LoadDockLayout
// event (see below).
RadDockLayout1.Controls.Add(dock);
//We want to save the dock state every time a dock is moved.
CreateSaveStateTrigger(dock);
}
}
private void CreateSaveStateTrigger(RadDock dock)
{
//Ensure that the RadDock control will initiate postback
// when its position changes on the client or any of the commands is clicked.
//Using the trigger we will "ajaxify" that postback. by mr@h
//dock.AutoPostBack = true;
//dock.CommandsAutoPostBack = true;
AsyncPostBackTrigger saveStateTrigger = new AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"DockPositionChanged";
UpdatePanel1.Triggers.Add(saveStateTrigger);
saveStateTrigger =
new AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"Command";
UpdatePanel1.Triggers.Add(saveStateTrigger);
}
private RadDock CreateRadDockFromState(DockState state)
{
RadDock dock = new RadDock();
dock.DockMode =
DockMode.Docked;
dock.ID =
string.Format("RadDock{0}", state.UniqueName);
dock.ApplyState(state);
System.Web.UI.WebControls.
Image mg = new System.Web.UI.WebControls.Image();
mg.Style.Add(
"float", "left");
mg.ImageUrl =
"~/Image/information.png";
mg.ID =
"mg" + dock.ID;
//dock.Commands.Add(new DockExpandCollapseCommand());
return dock;
}
..
well, you can see textboxes and check boxes in the dock content template. there is a button in the page,and i need all text box and check values inside docks for create xml setting file by using c#
and i dont need the keep state infos into session. i want ViewState.
private List<DockState> CurrentDockStates
{
get
{
//Store the info about the added docks in the session. For real life
// applications we recommend using database or other storage medium
// for persisting this information.
List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"];
if (Object.Equals(_currentDockStates, null))
{
_currentDockStates =
new List<DockState>();
Session[
"CurrentDockStatesDynamicDocks"] = _currentDockStates;
}
return _currentDockStates;
}
set
{
Session[
"CurrentDockStatesDynamicDocks"] = value;
}
}
pls help me. thanks