Is there an option that can be set to persist the expanded nodes during postback? My tree is set to load-on-demand with only the 1st level nodes being initially loaded. If the user expands several nodes and a postback occurs I want to be able to keep the grid in the same state after postback.
Hello Bob,
I have created and attached a sample that sets up the WebDataTree like you described and the expanded state of the tree is persisted. The main things you will want to look at are the Page_Load and Page_LoadComplete. In Page_Load I set up a list of expanded nodes then in Page_LoadComplete I re-expand the node by using that list.
Please let me know if I may be of further assistance with this issue.
here's my webdatatree from .aspx:
<ig:WebDataTree ID="webDataTree" runat="server" Height="100%" Width="200px" EnableConnectorLines="True" EnableAjaxViewState="true" EnableViewState="true" InitialExpandDepth="0" StyleSetName="Granite" InitialDataBindDepth="0" EnableAjax="true" SelectionType="Single" EnableExpandOnClick="true" > <ClientEvents NodeClick="NodeClickedHandler" /> <DataBindings> <ig:DataTreeNodeBinding DataMember="WORK_ORDERS" TextField="WONodeLabel" ValueField="WF_WorkOrder_ID" KeyField="WF_WorkOrder_ID" /> <ig:DataTreeNodeBinding DataMember="SAMPLES" TextField="SampleNodeLabel" ValueField="WF_Sample_ID" KeyField="WF_Sample_ID" /> <ig:DataTreeNodeBinding DataMember="SAMPLE_TESTS" TextField="TestNodeLabel" ValueField="WF_Test_ID" KeyField="WF_Test_ID" /> </DataBindings> </ig:WebDataTree>
I added EnableViewState and EnableAjaxViewState = true and it still doesn't work. On my page I have a button that posts back and gets a dataset (3 tables) , saves it to session variable and sets the datasource of the tree to the session variable and does a databind.. In Page_Load I set the datasource of the tree back to the session variable.
If I don't have the datasource set on page_load then none of the nodes ever get data when they try to expand.
I have created a small sample with the behavior you are describing. I have a WebDataTree that binds to a XmlDataSource and a WebImageButton. The WebImageButton does a post back on click. When I run it I expand a few nodes and the click the WebImageButton to do a post back, the page refreshes and the WebDataTree remains in the state it was before the post back. If this is not the case in the project you are working on please check to see that EnableViewState and EnableAjaxViewState are set to true.
Sincerely,
Mike P.
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com