Hi, is there a way to keep the size of the SplitterPane after a user resized among postbacks?
If a user collapse/expand a pane or moves the splitbar, after a postback these settings are lost and the properties setted at design time/in code behind are applied. Is there a way to preserve them?
Thank You
Claudio Mellina
Hello Claudio,
Thank you for posting in our forums.
By defaullt the SplitterPane keeps its size during the post backs.
You should sets its size only during the initial load for the purpose (!IsPostBack section)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack){
WebSplitter1.Panes[0].Size = new Unit(30, UnitType.Pixel);
WebSplitter1.Panes[1].Size = new Unit(70, UnitType.Pixel);
WebSplitter1.Panes[0].Collapsed = true;
WebSplitter1.Panes[1].ScrollBars = Infragistics.Web.UI.ContentOverflow.Hidden;
WebSplitter1.Panes[1].EnableRelativeLayout = true;
……..
}
Another option is to keep the clientHeight/clientWidth and restore them in onLoad on the client.
The below code snippet shows how to keep the size in % during resize
<script type="text/javascript">
function pageOnLoad()
$addHandler(window, 'resize', onResize);
function onResize()
var splitter = $find('<%=webSplitter.ClientID%>');
var width = splitter.get_element().clientWidth;
var pane1 = splitter.getPaneAt(0);
pane1.set_size(width * 0.7);
var splitterChild = $find('<%=webVerticalSplitter.ClientID%>');
var height = splitter.get_element().clientHeight;
var paneChild1 = splitterChild.getPaneAt(0);
paneChild1.set_size(height * 0.3);
</script>
</head>
<body onload="pageOnLoad()">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ig:WebSplitter ID="webSplitter" runat="server" EnableViewState="true" DynamicResize="true" ResizeWithBrowser="true"
Please let me know if it helps.
Yes, You are right, among postbacks dimensions and collapsed/expanded are preserved.
My scenario is a little different and I asked a wrong question.
If the splitter is on a MasterPage, is there a native way to keep its size etc... during the navigation among pages?
i.e. in the left pane there is the navigation tree, on the right one a page with several links, if a user collapse the left page and clicks on a link is redirected to a new page and loose the collapsed property of the left pane.
Claudio
Hello Giorgio,Please let me know if Tsvetelina's suggestion resolved your issue.
Thank you for the clarification.
You can save the size of the splitter in a session variable and get/set it during the redirections
Please let me know if you have further questions