This is a migrated thread and some comments may be shown as answers.

DockPanelLayout Load_Layout event issue

11 Answers 123 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Bhagyesh
Top achievements
Rank 1
Bhagyesh asked on 26 Apr 2013, 12:07 PM

Hi,
I have usercontrol in which 'RadDockLayout','RadDockZone' and 'RadDock' is defined. Now this usercontrol is binded with in datalist. So for each row these three controls will loaded dynamically.


Now, My question is, how to maintain RadDock state (Collapse/Expand) at each postback?

Please respond ASAP... Thanks

11 Answers, 1 is accepted

Sort by
0
Bhagyesh
Top achievements
Rank 1
answered on 30 Apr 2013, 04:42 AM
Hi,

Please reply on this question ASAP.
0
Slav
Telerik team
answered on 30 Apr 2013, 08:04 AM
Hello Bhagyesh,

I have some suggestions for configuring the docks scenario correctly. The RadDockLayout control is designed to persist the state of all RadDocks on the page so you need only one layout control on the page and it should wrap all docks.

If the user control that contains the docks is loaded from the code-behind, please add it on Page_Init to ensure that all controls are initialized correctly and their state is persisted.

As for the Collapse/Expand state, it is automatically persisted through postbacks in the client state of the dock control. If you want to keep it when the page is reloaded or closed and opened again, you can use the events SaveDockLayout and LoadDockLayout of RadDockLayout. You can check an example in this online demo.

Regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bhagyesh
Top achievements
Rank 1
answered on 30 Apr 2013, 12:54 PM

Thanks for Reply.

 

My scenario is different than you have stated. I have usercontrol in which 'RadDockLayout', 'RadDockZone' and 'RadDock' are loaded. Following is the code for the same

 

UControl1.ascx

 

<telerik:RadDockLayout ID="RadDockLayout1" runat="server" EnableViewState="true"

                StoreLayoutInViewState="true" OnLoadDockLayout="RadDock_LoadDockLayout"

                OnSaveDockLayout="RadDock_SaveDockLayout">

                <telerik:RadDockZone BorderStyle="None" ID="RadDockZone1" runat="server">

                    <telerik:RadDock ID="RadDock1" runat="server" OnCommand="RadDock_Command">

                        <TitlebarTemplate>

                            <table>

                                <tr>

                                    <td>

                                        <asp:Label ID="Label1" runat="server" Text='<%#Eval("Text")%>'/>

                                    </td>

                                </tr>

                            </table>

                        </TitlebarTemplate>

                        <ContentTemplate>

                            <table width="100%">

                                <tr>

                                    <td>

                                        <asp:DataList runat="server" ID="DataList1" RepeatColumns="3" RepeatDirection="Horizontal" CellPadding="5">

                                            <ItemTemplate>

                                                <contenttemplate>

                            <table width="100%">

                                <tr>

                                    <td>

                                        <asp:LinkButton ID="LinkButton1"

                                                        Text='<%# Bind("Name") %>' runat="server" Enabled="true" OnClick="LinkButton1_Click" />

                                    </td>

                                    </tr>

                                </table>

                            </contenttemplate>

                                            </ItemTemplate>

                                        </asp:DataList>

                                    </td>

                                </tr>

                            </table>

                        </ContentTemplate>

                        <Commands>

                            <telerik:DockExpandCollapseCommand />

                            <telerik:DockCommand Text="Save Position" AutoPostBack="true" />

                        </Commands>

                    </telerik:RadDock>

                </telerik:RadDockZone>

            </telerik:RadDockLayout>

 

This usercontrol will load from following aspx page.

 

Default.aspx

 

<telerik:RadPane ID="RadPane1" runat="server">

<asp:DataList id="DataList2" runat="server" OnItemDataBound="DataList2_ItemDataBound" DataKeyField="Text">

<ccg:UControl1 ID="Uctrl1" runat="server" />

                            </td>

                          </tr>

                       </ItemTemplate>

                   <FooterTemplate>

                    </table>

                   </FooterTemplate>

            </asp:DataList>

        </telerik:RadPane>

 

Default.aspx.cs

 

protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)

    {

        DataListItem item = e.Item;

        if ((item.ItemType == ListItemType.Item) ||

            (item.ItemType == ListItemType.AlternatingItem))

        {

            DataSet Dataset1 = new DataSet();

            DataTable DataTable1;

            DataTable DataTable2;

            int rowCount = 0;

           

            Dataset1.ReadXml("abc.xml");

           

            System.Data.DataRow[] result = Dataset1.Tables[0].Select("Type='Type1' OR Type='Type2'");

            DataTable1 = Dataset1.Tables[0].Clone();

            DataTable2 = Dataset1.Tables[0].Clone();

            foreach (System.Data.DataRow row in result)

            {

                DataTable1.Rows.Add(row.ItemArray);

            }

            while (rowCount <= DataTable1.Rows.Count - 1)

            {

                if (DataTable1.Rows[rowCount]["Type"].ToString() == "Type1")

                {

                    if (((DataRowView)(item.DataItem)).Row.ItemArray[1].ToString() == DataTable1.Rows[rowCount]["Text"].ToString())

                    {

                        while (DataTable1.Rows[rowCount + 1]["Type"].ToString() == "Type3")

                        {

                            DataTable2.Rows.Add(DataTable1.Rows[rowCount + 1].ItemArray);

                            rowCount = rowCount + 1;

                            if (rowCount == DataTable1.Rows.Count - 1)

                                break;

                        }

                   UControl1 reportDetails = item.FindControl("Uctrl1") as UControl1;

                       

                        reportDetails.reportDataTable = DataTable2;

                        reportDetails.reportDomain = DataTable1.Rows[rowCount]["Text"].ToString();

                        return;

                    }

                    DataTable2.Clear();

                }

                rowCount = rowCount + 1;

            }

        }

    }

 

The scenario is, usercontrol is loaded in datalist_itemdatabound event. So for each item new 'RadDockLayout', 'RadDockZone' and 'RadDock' is loaded.

 

The problem is when page is loaded, ' RadDock_LoadDockLayout' is not called for dock. So when user collapse any dock and try to save settings, the dock is expanded again and not able to save its state.

0
Slav
Telerik team
answered on 30 Apr 2013, 05:07 PM
Hi Bhagyesh,

RadDockLayout should be added on the page before the event ItemDataBound of the DataList is fired. The dock layout control depends on events  that are raised early on the page lifecycle (Init event). In your case the dock layout is included in the user control which is loaded too late and the event LoadDockLayout is not fired.

The suggested approach in this case is remove the RadDockLayout from the user control and place it on the page Default.aspx so that it wraps all user controls that contain docks. The purpose is to use a single dock layout control for persisting the state of all docks on a page.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bhagyesh
Top achievements
Rank 1
answered on 01 May 2013, 04:51 AM
Thanks for reply..

I have tried to remove the RadDockLayout from the user control and place it on the page Default.aspx, and place RadDockZone and RadDock in usercontrol, but it gives me error "RadDockLayout should contain raddockzone"
If I place RadDockLayout and RadDockZone in Default.aspx, and RadDock in usercontrol so it give me error "RaddockZone should contain RadDock".

If you have some samples for above scenario, then please share with us.

Thanks...
0
Dobromir
Telerik team
answered on 01 May 2013, 01:21 PM
Hi Bhagyesh,

Please find attached the required example.

Greetings,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bhagyesh
Top achievements
Rank 1
answered on 02 May 2013, 06:43 AM
Thanks for Replay and example...

In example there is only one dock loaded at a time so there is no any problem with that. In my case no of docks are decided at runtime so I need to bind usercontrol in datalist.

If I follow this approach, I received error "The ID of RadDock with ID='XXX' is not unique to RadDockLayout with ID='YYY'. Please, set the UniqueName property of RadDock with ID='XXX' with a value, which is unique to RadDockLayout with ID='YYY'".

Can you please provide example with using of datalist or any list in which usercontrol is binding?

Thanks...
0
Bhagyesh
Top achievements
Rank 1
answered on 07 May 2013, 04:48 AM
Please reply ASAP... It will really helful to me... :)
0
Christophe
Top achievements
Rank 1
answered on 07 May 2013, 05:49 AM
Hi Bhagyesh,

May be you should post your code here, that would make it easier for everyone willing to help you. And please, MF please, use the CodeBlock format when  you do.
As Slav said, 1 dock layout per page is definitely the best approach and the most efficient. 

Post your code and I'll have a look see if I can be of any help here.

Thanks,

Chris
0
Bhagyesh
Top achievements
Rank 1
answered on 08 May 2013, 04:39 AM
Thanks Chris for helping me...

I have already attached code in my earlier post. See if it helps you else I will again upload code.

Thanks...
0
Christophe
Top achievements
Rank 1
answered on 08 May 2013, 04:49 AM
Yes could you please update / upload your code here so I can have a look ? As Slav suggested, you're supposed to use only one instance of the DockLayout. The code you posted shows that your layout object is embedded within your usercontrol, which is the wrong approach.

Please use the code block format, it makes it way easier to read for us.

Cheers
Tags
Dock
Asked by
Bhagyesh
Top achievements
Rank 1
Answers by
Bhagyesh
Top achievements
Rank 1
Slav
Telerik team
Dobromir
Telerik team
Christophe
Top achievements
Rank 1
Share this question
or