Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
154 views

Greetings, 

        I am trying to implement the RadDock functionality in example similar to the "MyPortal" Demo . The language used is C#. I follow the same way as shown in the demo except for the part that instead of populating the usercontrols in the dropdown and clicking the 'Add Dock' button to add the dock to the dockzone , I use seperate buttons and  on clicking each button it loads respective user control to  RadDock control and displays it. Each control has a Radgrid inside that displays different data. 

While opening/closing the raddocks after a point it throws an error such as 'Failed to load viewstate' error . Is there a way to rectify it ?? Since there are controls such as dropdown, radgird which also initiates a postback , I cant set the EnableViewState=false for each page as well. 

Also , in the demo Session is used to save/load the raddockstates . How to save and reload these states using database. Can you provide me with an example ? I did search on other forum posts regarding the raddock state persistance , where I see that the states are being only updated or loaded but not inserted so I am not sure how to insert , update and select the rad dock states from the database without having the above mentioned error. Kindly help me asap as its very urgent.

Below attached image shows how my page look like and the c# code is pasted as well. 

        private List<DockState> CurrentDockStates
        {
            get
            {
                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;
            }
        }

        public ArrayList GetZones()
        {
            ArrayList zones = new ArrayList();
            zones.Add(RadDockZone1);
            //zones.Add(RadDockZone2);

            return zones;
        }

   
        private void Page_Init(object sender, EventArgs e)
        {
                  for (int i = 0; i < CurrentDockStates.Count; i++)
            {
                // clears the closed docks from the dock state, this line is 
                // optional and its purpose is to keep the dock state as small 
                // as possible
                if (CurrentDockStates[i].Closed == true) continue;

                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);
                //Load the selected widget
                LoadWidget(dock);

                // prevents the rendering of closed docks, used for improving 
                // performance
                if (CurrentDockStates[i].Closed == true)
                {
                    dock.Visible = false;
                }
            }

            //UpdatePanel2.Triggers.Add(new PostBackTrigger() { ControlID = rdbAddEqpgSettings.UniqueID });
            //UpdatePanel2.Triggers.Add(new PostBackTrigger() { ControlID = rdbAddEqpgConstraints.UniqueID });
            //UpdatePanel2.Triggers.Add(new PostBackTrigger() { ControlID = rdbViewInputDetails.UniqueID });

            UpdatePanel2.Triggers.Add(new PostBackTrigger() { ControlID = rdbViewResults.UniqueID });
            UpdatePanel2.Triggers.Add(new PostBackTrigger() { ControlID = rdbResultHistory.UniqueID });
            Updat
        }

private RadDock CreateRadDockFromState(DockState state)
        {
            RadDock dock = new RadDock();
            dock.DockMode = DockMode.Docked;
            dock.ID = string.Format("RadDock{0}", state.UniqueName);
            dock.ApplyState(state);
            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());

            return dock;
        }
        private RadDock CreateRadDock(string title)
        {
         RadDock dock = new RadDock();
            dock.DockMode = DockMode.Docked;
            dock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a");
            dock.ID = string.Format("RadDock{0}", dock.UniqueName);
            dock.Title = "Dock";
            dock.Text = string.Format("Added at {0}", DateTime.Now);
            dock.Width = Unit.Pixel(300);

            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());

            return 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.
            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 void LoadWidget(RadDock dock)
        {
            if (string.IsNullOrEmpty(dock.Tag) || dock.Closed)
            {
                return;
            }
            switch (dock.Tag)
            {
                case "EquipmentGroupConstraintsForm.ascx":
                    {
                        Control widget = LoadControl("~/Main/UserControls/EquipmentGroupConstraintsForm.ascx");
                        dock.ContentContainer.Controls.Add(widget);
                    }
                    break;
                case "EquipmentGroupSettingsForm.ascx":
                    {
                        Control widget = LoadControl("~/Main/UserControls/EquipmentGroupSettingsForm.ascx");
                        dock.ContentContainer.Controls.Add(widget);
                    }
                    break;
                case "InputDetailsForm.ascx":
                    {
                        Control widget = LoadControl("~/Main/UserControls/InputDetailsForm.ascx");
                        dock.ContentContainer.Controls.Add(widget);
                    }
                    break;
                case "ResultDetails.ascx":
                    {
                         Control widget = LoadControl("~/Main/UserControls/ResultDetails.ascx");
                         dock.Width = Unit.Pixel(1331);
                        dock.ContentContainer.Controls.Add(widget);
                    }
                    break;
                case "ExpResultHistory.ascx":
                    {
                        dock.Width = Unit.Pixel(1320);
                        Control widget = LoadControl("~/Main/UserControls/ExpResultHistory.ascx");
                        dock.ContentContainer.Controls.Add(widget);
                    }
                    break;
            }

        }

        protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
        {
            CurrentDockStates = RadDockLayout1.GetRegisteredDocksState();
        }

        protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
        {
            foreach (DockState state in CurrentDockStates)
            {
                e.Positions[state.UniqueName] = state.DockZoneID;
                e.Indices[state.UniqueName] = state.Index;
            }
        }

        protected void rdbAddEqpgSettings_Click(object sender, EventArgs e)
        {
            RadDock dock = CreateRadDock("Create Equipment Group Settings");
            RadDockZone dz = (RadDockZone)this.Master.FindControl("ContentPlaceholder1").FindControl("RadDockZone1");
            dock.Index = 0;
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(dz);

            CreateSaveStateTrigger(dock);
            dock.Closed = false;

            dock.Tag = "EquipmentGroupSettingsForm.ascx";
            LoadWidget(dock);

        }

        protected void rdbAddEqpgConstraints_Click(object sender, EventArgs e)
        {
            RadDock dock = CreateRadDock("Create Equipment Group Constraints");
            RadDockZone dz = (RadDockZone)this.Master.FindControl("ContentPlaceholder1").FindControl("RadDockZone1");
            dock.Index = 0;
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(dz);

            CreateSaveStateTrigger(dock);
            dock.Closed = false;

            dock.Tag = "EquipmentGroupConstraintsForm.ascx";
            LoadWidget(dock);
          
        }

        protected void rdbViewInputDetails_Click(object sender, EventArgs e)
        {
            //rdbViewInputDetails.Enabled = false;
            //UpdatePanel2.Update();

            RadDock dock = CreateRadDock("View Input Details");
            RadDockZone dz = (RadDockZone)this.Master.FindControl("ContentPlaceholder1").FindControl("RadDockZone1");
            dock.Index = 0;
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(dz);

            CreateSaveStateTrigger(dock);
            dock.Closed = false;

            dock.Tag = "InputDetailsForm.ascx";
            LoadWidget(dock);
        }

        protected void rdbViewResults_Click(object sender, EventArgs e)
        {
            RadDock dock = CreateRadDock("View Result Details");
            RadDockZone dz = (RadDockZone)this.Master.FindControl("ContentPlaceholder1").FindControl("RadDockZone1");
            dock.Index = 0;
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(dz);

            CreateSaveStateTrigger(dock);
            dock.Closed = false;

            dock.Tag = "ResultDetails.ascx";
            LoadWidget(dock);
        }

        protected void rdbResultHistory_Click(object sender, EventArgs e)
        {
            RadDock dock = CreateRadDock("Result History");
            RadDockZone dz = (RadDockZone)this.Master.FindControl("ContentPlaceholder1").FindControl("RadDockZone1");
            dock.Index = 0;
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(dz);

            CreateSaveStateTrigger(dock);
            dock.Closed = false;

            dock.Tag = "ExpResultHistory.ascx";
            LoadWidget(dock);

        }
    }
}

Thanks and Regards, 

Meena

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Meena
Top achievements
Rank 1
 asked on 04 Jun 2018
6 answers
123 views
Hi,

I couldn't achieve of exporting a pdf file with my web service binding scheduler.

Isn't it possible?

I would like to know whether it is possible to do it with a JS code in my aspx page. If it doesn't work, I don't have any binding criteria in my back end code. How could be possible to do that ?

thank you
Marin Bratanov
Telerik team
 answered on 04 Jun 2018
3 answers
144 views

We have a few custom tools added into the editor that we've decided need to be enabled while in preview mode.

Using the steps here, we've had that working for a while now. Recently though we updated to version 2018.2.516.45, and while the buttons still enable they no longer function while in preview mode. They work fine in both other modes, and they're not disabled (at least their state is set to 0).

We're setting a timeout to make the tools available after the page finishes initializing:

function OnClientModeChange(sender, args) {
    setTimeout(function () { MakeToolsAvailable(sender) }, 500);
};

 

And in the timeout we set the state of each of the tools to 0:

function MakeToolsAvailable(sender) {
    var editor = sender;
    editor.getToolByName('example').setState(0);
    // etc
}

 

Both of these are working fine as evidenced by the buttons looking available and the sanity check test I ran by putting console.logs in them. This last bit is the part that breaks.

Telerik.Web.UI.Editor.CommandList["example"] = function (commandName, editor, args) {
     // Everything here runs fine in design mode, but not in preview mode
};

Rumen
Telerik team
 answered on 04 Jun 2018
3 answers
366 views
Together with Telerik components I'm using jQuery 1.6.2

What I'm trying to know is if there is a client event that tells me when does all controls ready, as the page still keeps loading Telerik javascript even after jQuery Document Ready and DOM Ready.

So I can hide the "Loading" div...

Thank you.
Rumen
Telerik team
 answered on 04 Jun 2018
2 answers
158 views

Hi Telerik,

 

I want to know if is it possible to change the cursor when the mouse is over a RadIconTile object ?

I tried to apply a CSS style, but the modification is not considered.

 

Thank you.

Valentin
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 04 Jun 2018
3 answers
327 views

GridCalculatedColumn has a Property called "Expression", what could it contain?

These are valid:

iif(condition, trueResult, falseResult)
{0}*{1}
Convert.ToString({0})

How to format the result of the expression?

e.g. this doesn't work:

iif(condition, String.Format"{0:0.00}%", {0}), "NA")

This Expression doesn't seem to be the same as the .NET Data Column Expression either as I tested it and at least the Len and Convert methods are not supported.

Please help.

Thanks,

Vinh
Top achievements
Rank 1
 answered on 04 Jun 2018
1 answer
120 views

Hi,

I have a Hierarchy Binding raggrid with details table , I would like to change the header text and width from code. I was able to do that on mastertableview but not able to reach the details table.

For Each col As GridBoundColumn In rgTestGrid.MasterTableView.AutoGeneratedColumns
 
col.HeaderStyle.Width = Unit.Pixel(65)
 
Next

Is there any way to change the column header with of details table like this?

Thanks in advance

regards

 

Eyup
Telerik team
 answered on 04 Jun 2018
0 answers
102 views

Telerik UI for ASP.NET AJAX R2 2018.  When I use the AntiXssEncoder as the default encoder...
 web.config 
    <httpRuntime encoderType="Microsoft.Security.Application.AntiXssEncoder, AntiXssLibrary" maxRequestLength="102400"/>

A mistake as a figure

 

gao
Top achievements
Rank 1
 asked on 03 Jun 2018
4 answers
899 views

In the parent page, it had a preview button to prompt a radwindow.

How can I refresh the grid in parent page when user click the Close [X] button of the radwindow.

The radwindow generate in code behind:


Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
    If e.Item.Value = "Preview" Then
        Dim url = "~/TrainingAdmin/SIMPER_view.aspx?SIMPER_ID=0&UserID=" & Request.QueryString("UserID") & "&From=" & RadDatePicker_ValidFrom.SelectedDate & "&To=" & RadDatePicker_ValidTill.SelectedDate
 
        Dim windowManager As New RadWindowManager()
        Dim window1 As New RadWindow()
        ' Set the window properties  
        window1.NavigateUrl = url
        window1.ID = "RadWindow1"
        window1.Height = 750
        window1.Width = 740
        window1.Top = 140
        window1.Left = 250
 
        window1.AutoSize = False
        window1.VisibleTitlebar = True
        window1.VisibleStatusbar = False
        window1.VisibleOnPageLoad = True           
 
        ' Set this property to True for showing window from code  
        windowManager.Windows.Add(window1)
        Me.Form.Controls.Add(window1)
 
    ElseIf e.Item.Value = "Refresh" Then
        Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?userID=" & Request.QueryString("UserID"))
 
    End If
End Sub

Marin Bratanov
Telerik team
 answered on 01 Jun 2018
1 answer
345 views

Dear All,

i need to show a bar graph.

First x-axis - Month like January, February etc. .

Second X axis- every month i need to show two countries  like USA, UK

Y Axis- Total Amount. 

Per country, month expense is Y1 and forecast amount is Y2.

if i can combine Bar chart with bullet charge will achieve my goal. or if Bar chart can show "Target" also will be ok. appreciate your help.

i attached a demo graph for your reference. 

 

Marin Bratanov
Telerik team
 answered on 01 Jun 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?