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

Updating only one Raddock by Event Command by a RadWindow

1 Answer 53 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Juan
Top achievements
Rank 1
Juan asked on 29 Jul 2016, 08:01 PM

Good afternoon following is for support'm working with a dashboard using Raddock
in the aspx I have the RadDockLayout and within the I have 4 Raddock zone and the dock are created in programming I can now create them but the problem I have is to create a command event to edit that Raddock which by clicking call a radwindow and edit the information but when saving the edited information is not as it should do so that the dock is displayed again with editing changes

currently the dock have a user control
I have no problems to eliminate them or close them I need to edit and I've tried so ask for your help

 

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="css/common.css" rel="stylesheet" />
    <link href="css/dashboard.css" rel="stylesheet" />
    <%--    <link href="../../Styles/kendo.common.min.css" rel="stylesheet" />
    <%--<link href="../../Styles/kendo.default.min.css" rel="stylesheet" />--%>
    <%-- <link href="../../Styles/kendo.mobile.all.min.css" rel="stylesheet" />
    <link href="../../Styles/kendo.bootstrap.min.css" rel="stylesheet" />--%>
    <%--  <style type="text/css">
        #ctl00_CPH1_verticalMenu div {
            padding: 0 !important;
        }
 
        #ctl00_CPH1_verticalMenu ul {
            border: 30px !important;
            background: rgba(218, 39, 39, 0) !important;
            margin: 0;
            padding: 0;
            width: 200px;
        }
 
        .RadMenu_sfs .rmVertical a.rmLink {
            padding-top: 0px !important;
            padding-bottom: 0px !important;
            padding-left: 0px !important;
        }
 
        .RadMenu_sfs .rmVertical > div {
            border-left: none !important;
        }
 
        .RadMenu_sfs, .RadMenu_sfs a.rmLink {
            color: white !important;
            font-family: "Segoe UI",Arial,Helvetica,sans-serif !important;
            font-weight: 100 !important;
        }
 
        #ctl00_CPH1_verticalMenu .mail:after {
            background: #C0C4C5;
        }
 
        .slider .mail .rmRootLink:before {
            background: #3C4142 !important;
        }
    </style>--%>
 
    <script type="text/javascript" src="Js/dashboard4.js"></script>
    <%-- <script type="text/javascript" src="js.min/dashboard4.js"></script>--%>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            serverIDs({
                ajaxID: "<%= RadAjaxPanel1.ClientID%>",
                ajaxServerID: "<%= RadAjaxPanel1.UniqueID %>",
                windowsId: "<%= newSensorWindows.ClientID%>",
                rcbSensorInventory: "<%= rcbSensorInventory.ClientID%>",
                rcSensorTYpe: "<%= rcSensorType.ClientID %>",
                rcWidgetType: "<%= rcWidgetType.ClientID %>",
                rcRadDockSensor: "<%= rcRadDockSensor.ClientID %>",
                rtbsensorName: "<%= rtbsensorName.ClientID %>",
                RadDockZone2: "<%= RadDockZone2.ClientID %>",
                regKey: "<%= dashregKey.ClientID%>",
                cliKey: "<%= dashcliKey.ClientID%>",
                entitykey: "<%= dashentitykey.ClientID%>",
                cboEntities: "<%=cboEntities.ClientID%>",
                rcRadDockSensor: "<%=rcRadDockSensor.ClientID%>",
                rcTemperatureType: "<%=rcTemperatureType.ClientID%>"
            });
        </script>
    </telerik:RadCodeBlock>
    <%-- <script type="text/javascript" src="../Scripts/kendo.all.min.js"></script>--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH1" runat="Server">
 
    <input type="hidden" clientidmode="Static" id="dashregKey" name="regKey" runat="server" value="" />
    <input type="hidden" clientidmode="Static" id="dashcliKey" name="cliKey" runat="server" value="" />
    <input type="hidden" clientidmode="Static" id="dashentitykey" name="entitykey" runat="server" value="" />
    <input type="hidden" clientidmode="Static" id="dashdockid" name="dashdockid" runat="server" value="" />
    <telerik:RadAjaxLoadingPanel ID="panel1" runat="server" Transparency="30" BackColor="#E0E0E0">
        <asp:Image ID="image2" runat="server" AlternateText="Actualizando Datos..." BorderWidth="0px"
            ImageUrl="images/loading1.gif" />
    </telerik:RadAjaxLoadingPanel>
    <div class="prueba">
        <div class="page">
            <div class="container clear">
                <div class="section bottom">
 
                    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="panel1"
                        OnAjaxRequest="RadAjaxPanel1_AjaxRequest" Width="100%">
 
                        <div class="scroller">
                            <div class="Panel" style="margin: 0 auto; width: 96.7%;">
                                <div class="home-btn">
                                    <span id="entityList" class="icon icon-Home" onclick="entityList()">
                                        <asp:Label ID="entTitle" runat="server" Text="<%$ Resources:Dashboard4,iotEntitiesList%> " /></span>
 
                                    <telerik:RadComboBox runat="server" DropDownWidth="300px" Text="" OnItemDataBound="cboEntities_ItemDataBound" ID="cboEntities" ClientIDMode="Static" Width="260px" AutoPostBack="false" Filter="Contains" Style="padding: 5px 27%;"
                                        OnSelectedIndexChanged="cboEntities_SelectedIndexChanged" OnClientSelectedIndexChanged="OnClientSelectedIndexChangedEntity" Sort="Ascending" SortCaseSensitive="true" Height="100%" MarkFirstMatch="true" />
 
                                    <span id="addSensor" class="icon icon-Add-Circle spanTag" onclick="addSensorWindow()" style="float: right; padding-right: 30px;">
                                        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Dashboard4,AddSensor%> " /></span>
 
                                </div>
 
 
 
                            </div>
                            <telerik:RadDockLayout ID="RadDockLayout1" runat="server" OnSaveDockLayout="RadDockLayout1_SaveDockLayout" OnLoadDockLayout="RadDockLayout1_LoadDockLayout">
 
                                <ul id="ctl00_MainContent_rlvContacts_itemPlaceholder" class="contacts-listNew">
 
                                    <li>
                                        <div class="itemTemplateNew">
                                            <div class="content">
                                                <telerik:RadDockZone ID="RadDockZone1" runat="server" CssClass="contacts-list" BorderColor="#F7F7F7" Orientation="Horizontal">
                                                </telerik:RadDockZone>
                                            </div>
 
                                        </div>
                                    </li>
                                </ul>
                                <ul id="Ul1" class="contacts-list">
                                    <li>
                                        <div class="itemTemplate">
                                            <div class="content">
                                                <telerik:RadDockZone ID="RadDockZone2" runat="server" CssClass="contacts-list" BorderColor="white" Orientation="Vertical">
                                                </telerik:RadDockZone>
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <div class="itemTemplate">
                                            <div class="content">
                                                <telerik:RadDockZone ID="RadDockZone3" runat="server" CssClass="contacts-list" BorderColor="white" Orientation="Vertical">
                                                </telerik:RadDockZone>
                                            </div>
                                        </div>
 
                                    </li>
                                    <li>
                                        <div class="itemTemplate">
                                            <div class="content">
                                                <telerik:RadDockZone ID="RadDockZone4" runat="server" CssClass="contacts-list" BorderColor="white" Orientation="Vertical">
                                                </telerik:RadDockZone>
 
                                            </div>
                                        </div>
                                    </li>
 
 
                                </ul>
                            </telerik:RadDockLayout>
                        </div>
                        <telerik:RadWindow runat="server" ID="newSensorWindows" Width="600px" Title="New Sensor " Heigth="380px" MinHeight="370px" VisibleStatusbar="false" ReloadOnShow="true" Behaviors="Close" Style="z-index: 2345" Modal="true">
                            <ContentTemplate>
                                <div style="width: 90%; margin: 0 auto; height: 320px">
                                    <div class="Panel">
                                        <div style="float: left">
                                            <asp:Label ID="sensorTitle" runat="server" Text="<%$ Resources:Dashboard4,AddSensor%>" />
                                        </div>
                                    </div>
 
                                    <div class="PanelContent" style="height: 80%; overflow: auto; padding-top: 10px; padding-left: 100px">
                                        <div class="row" style="margin: 10px;">
                                            <%-- <label><%$ Resources:Dashboard4,sensorName%></label>--%>
                                            <asp:Label ID="lbsensorname" runat="server" Text="<%$ Resources:Dashboard4,sensorName%>" Width="160"></asp:Label>
                                            <telerik:RadTextBox runat="server" ID="rtbsensorName" AutoPostBack="false"></telerik:RadTextBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="rtbsensorName"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <div class="row" style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorStock%></label>--%>
                                            <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Dashboard4,sensorStock%>" Width="160"></asp:Label>
                                            <telerik:RadComboBox ID="rcbSensorInventory" Height="200" runat="server" Width="176px" ClientIDMode="Static" AutoPostBack="true" Filter="Contains" MaxHeight="200px"
                                                EmptyMessage="- Select a Sensor -" ZIndex="1000000" OnDataBound="rcbSensorInventory_DataBound" DropDownAutoWidth="Enabled" HighlightTemplatedItems="true" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
                                                <HeaderTemplate>
                                                    <table style="width: 300px" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td style="width: 75px;">
                                                                <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Dashboard4,imei%>"></asp:Label>
                                                            </td>
                                                            <td style="width: 100px;">
                                                                <asp:Label ID="Label6" runat="server" Text="<%$ Resources:Dashboard4,brand%>"></asp:Label>
                                                            </td>
                                                            <td style="width: 125px;">
                                                                <asp:Label ID="Label7" runat="server" Text="<%$ Resources:Dashboard4,model%>"></asp:Label>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <table style="width: 300px" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td style="width: 75px;">
                                                                <%# DataBinder.Eval(Container, "Text")%>
                                                            </td>
                                                            <td style="width: 100px;">
                                                                <%# DataBinder.Eval(Container, "Attributes['Marca']")%>
                                                            </td>
                                                            <td style="width: 125px;">
                                                                <%# DataBinder.Eval(Container, "Attributes['Modelo']")%>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </ItemTemplate>
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="rcbSensorInventory"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <div class="row" style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorType%></label>--%>
                                            <asp:Label ID="Label3" runat="server" Text="<%$ Resources:Dashboard4,sensorType%>" Width="160"></asp:Label>
                                            <telerik:RadComboBox ID="rcSensorType" runat="server" Width="176px" ClientIDMode="Static" AutoPostBack="false" OnClientSelectedIndexChanged="checkifisTemperature"
                                                EmptyMessage="- Select a Sensor Type -" ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="rcSensorType"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <div id="tempDiv" class="row" style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorType%></label>--%>
                                            <asp:Label ID="Label8" runat="server" Text="<%$ Resources:Dashboard4,temperatureUnit%>" Width="160"></asp:Label>
                                            <telerik:RadComboBox ID="rcTemperatureType" runat="server" Width="176px" ClientIDMode="Static" AutoPostBack="false"
                                                EmptyMessage="- Select a Temperature Type -" ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <%--<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator6" ControlToValidate="rcTemperatureType"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>--%>
                                        </div>
                                        <div class="row" style="margin: 10px;">
                                            <%--<label style="margin-right: 37px;"><%$ Resources:Dashboard4,widgetType%></label>--%>
                                            <asp:Label ID="Label4" runat="server" Text="<%$ Resources:Dashboard4,widgetType%>" Width="160"></asp:Label>
                                            <telerik:RadComboBox ID="rcWidgetType" runat="server" Width="176px" ClientIDMode="Static" AutoPostBack="false"
                                                EmptyMessage="- Select a Widget Type -" ZIndex="10001">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="rcWidgetType"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <div id="locationID" class="row" style="margin: 10px;">
                                            <%--<label style="margin-right: 20px;"><%$ Resources:Dashboard4,widgetLocation%></label>--%>
                                            <asp:Label ID="Label5" runat="server" Text="<%$ Resources:Dashboard4,widgetLocation%>" Width="160"></asp:Label>
                                            <telerik:RadComboBox ID="rcRadDockSensor" runat="server" Width="176px" ClientIDMode="Static" AutoPostBack="false"
                                                EmptyMessage="- Select Dock Location -" ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="rcRadDockSensor"
                                                Display="Dynamic" ErrorMessage="!" CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
 
                                        <div id="saveDiv" style="text-align: center; padding-top: 7px">
 
                                            <telerik:RadButton ID="SaveData" runat="server" AutoPostBack="false" Text="<%$ Resources:language,save %>" OnClientClicked="addDock">
                                                <Icon PrimaryIconCssClass="rbEdit" PrimaryIconLeft="4px" PrimaryIconTop="4px" />
                                            </telerik:RadButton>
                                        </div>
                                        <div id="editDiv" style="text-align: center; padding-top: 7px">
 
                                            <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="false" Text="<%$ Resources:language,Edit %>" OnClientClicked="editDock">
                                                <Icon PrimaryIconCssClass="rbEdit" PrimaryIconLeft="4px" PrimaryIconTop="4px" />
                                            </telerik:RadButton>
                                        </div>
                                        <telerik:RadNotification ID="RadNotification1" runat="server" Position="Center"
                                            Width="250px" EnableRoundedCorners="true" VisibleTitlebar="True" TitleIcon="none" ContentIcon="none" CssClass="boxcontainer" Title="Mensaje" AnimationDuration="0" AutoCloseDelay="0">
                                        </telerik:RadNotification>
                            </ContentTemplate>
                        </telerik:RadWindow>
                    </telerik:RadAjaxPanel>
                </div>
            </div>
        </div>
    </div>
    <div class="tm-click-overlay"></div>
 
    <asp:HiddenField runat="server" ID="nav" />
 
</asp:Content>

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using sFleet.General;
using sfleet.Api;
using sfleet.General;
using sfleet.dashboardModels;
 
public partial class app_DashBoard : app_Page
{
    enum WidgetType { ImageDock, BarWidget, GaugeChart, RadarChart, Weather, Gauge, AreaChart, KendoAreaChart };
    string[] PrimaryDockZone = new string[] { "RadDockZone1" };
    string[] SensorDockZone = new string[] { "RadDockZone2", "RadDockZone3", "RadDockZone4" };
    private int regkey = 0, clikey = 0, entkey = 0;
 
 
 
    private void LoadWidget(RadDock dock)
    {
        if (string.IsNullOrEmpty(dock.Tag))
            return;
        Control widget = LoadControl(dock.Tag);
        dock.ContentContainer.Controls.Add(widget);
    }
 
    public void loadVariable()
    {
        //if (regkey != 0)
        regkey = Convert.ToInt32(Session["RegionKey"]);
        // if (clikey != 0)
        clikey = Convert.ToInt32(Session["ClientKey"]);
        entkey = Convert.ToInt32(Session["EntityKey"]);
 
        //Session["EntityKey"] = entkey;
        this.dashregKey.Value = regkey.ToString();
        this.dashcliKey.Value = clikey.ToString();
        this.dashentitykey.Value = entkey.ToString();
    }
 
   
    protected void Page_Init(object sender, EventArgs e)
    {
        //loadEntitiesList();
         
          loadVariable();
 
        if (entkey == 0)
        {
            Response.Redirect("iotEntities.Aspx");
        }
        //Recreate the docks in order to ensure their proper operation
        for (int i = 0; i < CurrentDockStates.Count; i++)
        {
            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);
            LoadWidget(dock);
 
            // prevents the rendering of closed docks, used for improving
            // performance
            if (CurrentDockStates[i].Closed == true)
            {
                dock.Visible = false;
            }
        }
 
 
    }
 
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        //string title = this.Page.Title;
        this.Page.Title = "";
        nav.Value = "desktop";
        if (!Page.IsPostBack && !Page.IsCallback)
        {
            //if (this.RadDockZone1.Docks.Count < 2)
            //{
            //    CreateDockforGatewayZone();
            //}
            loadSensorInventory();
            loadEntitiesList();
            loadWidgetType();
            loadRadDockZoneSensor();
            loadTemperatureType();
        }
 
 
 
    }
 
    private RadDock CreateRadDockFromState(DockState state)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.ID = string.Format("RadDock{0}", state.UniqueName);
        dock.Title = state.Title;
        dock.CssClass = "higherZIndex new";
        dock.EnableRoundedCorners = true;
        dock.BackColor = System.Drawing.Color.White;
        dock.BorderColor = System.Drawing.Color.LightGray;
        dock.ForbiddenZones = getZone(state);
        dock.RenderMode = RenderMode.Lightweight;//RenderMode.Lightweight;
        dock.CommandsAutoPostBack = true;
        dock.ApplyState(state);
        var close = new DockCloseCommand();
        close.CssClass = "CloseCustom";
        close.AutoPostBack = true;
        dock.Commands.Add(close);
        dock.Command += new DockCommandEventHandler(dock_Command);
        //dock.Commands.Add(new DockCloseCommand());
        //dock.Commands.Add(new DockExpandCollapseCommand());
        var editCommand = new DockCommand();
        
        editCommand.Name = "Edit";
        editCommand.CssClass = "EditCustom";
        editCommand.OnClientCommand = "EditWidget";
        editCommand.AutoPostBack = false;
        dock.Commands.Add(editCommand);
        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 = false;
         
    }
 
    void dock_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name == "Close")
        {
            //Delete Sensor
            var dockid = ((Telerik.Web.UI.RadDock)(sender)).UniqueName;
            var iot = new sfDataAccess();
            iot.DeleteRadDockSensor(regkey, clikey, entkey, dockid);
            //Delete Dock
            sender.ToString();
            //var current = CurrentDockStates;
            rcbSensorInventory.Items.Clear();
            loadSensorInventory();
        }
         
         
 
    }
 
    //private void LoadMobile(DeviceScreenDimensions screenDimensions)
    //{
 
    //}
 
    private void CreateDockforGatewayZone()
    {
 
        WidgetType[] values = (WidgetType[])Enum.GetValues(typeof(WidgetType));
 
        int PrimaryDock = 3 - this.RadDockZone1.Docks.Count;
 
        for (int i = 0; i < PrimaryDock; i++)
        {
            //WidgetType widget = ParseEnum<WidgetType>(widType[i]);
            //RadDock dock = CreateRadDock(widget, ForbZone);
 
            RadDock dock = CreateRadDock(values[i], SensorDockZone, "Widget "+i, 32, 350);
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(RadDockZone1);
            CreateSaveStateTrigger(dock);
        }
 
    }
 
    private RadDock CreateRadDock(WidgetType widget, string[] zone, string Title, int dockWidth, int dockHeight)
    {
        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 = Title;
        dock.Text = string.Format("Add to {0}", DateTime.Now);
        dock.RenderMode = RenderMode.Native;//RenderMode.Lightweight;
        dock.ForbiddenZones = zone;
        //dock.Style = "margin-left: 100px;";
        dock.BorderColor = System.Drawing.Color.LightGray;
        dock.BackColor = System.Drawing.Color.White;
        dock.CommandsAutoPostBack = false;
        dock.CssClass = "higherZIndex new";
        //if (dockHeight == 300)
        //{
        dock.Width = Unit.Percentage(dockWidth);
        //dock.Height = Unit.Percentage(dockHeight);
        //}
        //else
        //{
        //    dock.Width = Unit.Pixel(dockWidth);
            dock.Height = Unit.Pixel(dockHeight);
        //}
         
        dock.DockHandle = DockHandle.TitleBar;
        dock.Tag = getTag(widget);
        dock.EnableRoundedCorners = true;
         
        LoadWidget(dock);
        var close = new DockCloseCommand();
        close.AutoPostBack = true;
        close.CssClass = "CloseCustom";
        dock.Commands.Add(close);
        dock.Command += new DockCommandEventHandler(dock_Command);
         
        var editCommand = new DockCommand();
        editCommand.Name = "Edit";
        editCommand.CssClass = "EditCustom";
        editCommand.OnClientCommand = "EditWidget";
        editCommand.AutoPostBack = false;
        dock.Commands.Add(editCommand);
 
        return dock;
    }
 
    protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "AddDock")
        {
            
 
            try
            {
                //RadAjaxPanel1.ResponseScripts.Add("../Scripts/kendo.all.min.js");
                var sensor = new sfsSensor();
                sensor.SensorName = this.rtbsensorName.Text;
                sensor.regionKey = regkey;
                sensor.clientKey = clikey;
                sensor.entityKey = entkey;
                sensor.sensorTypeKey = Convert.ToInt32(this.rcSensorType.SelectedValue);
                sensor.sensorInv_Key = Convert.ToInt32(this.rcbSensorInventory.SelectedValue);
                int width, heigth;
                width = 40;
                heigth = 345;
                if (sensor.sensorTypeKey == 7)
                {
                    sensor.temperatureType = Convert.ToChar(rcTemperatureType.SelectedValue);
                }
 
                RadDock dock = CreateRadDock(WidgetType.BarWidget, PrimaryDockZone, sensor.SensorName, width, heigth);
 
                sensor.sensorDockId = dock.UniqueName;
 
                var iot = new sfDataAccess();
                iot.saveIotSensor(sensor);
                RadDockLayout1.Controls.Add(dock);
                var radzone = Page.Master.FindControl("CPH1").FindControl(this.rcRadDockSensor.SelectedValue) as RadDockZone;
                dock.Dock(radzone);
                CreateSaveStateTrigger(dock);
                dock.Closed = false;
 
                //RadAjaxPanel1.ResponseScripts.Add("../Scripts/kendo.all.min.js");
 
                rcbSensorInventory.Items.Clear();
                loadSensorInventory();
 
                RadNotification1.Text = "Sensor Agregado Correctamente";
                RadNotification1.Show();
 
                //ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('Hello World');", true);setTimeout(updateSensor, sfs.timer, sfs.sensorKey);
                //RadAjaxPanel1.ResponseScripts.Add("setTimeout(updateSensor, "+60000+", "+sensor.sensorKey+");");
            }
            catch (Exception ex)
            {
                var iot = new sfGenerall();
                iot.InsertErrorLog(ex);
                RadNotification1.Text = ex.ToString();
                RadNotification1.Show();
                 
            }
           
             
        }
 
        if (e.Argument == "EditDock")
        {
            try
            {
                var sensor = new sfsSensor();
                sensor.SensorName = this.rtbsensorName.Text;
                sensor.regionKey = regkey;
                sensor.clientKey = clikey;
                sensor.entityKey = entkey;
                sensor.sensorTypeKey = Convert.ToInt32(this.rcSensorType.SelectedValue);
                sensor.sensorInv_Key = Convert.ToInt32(this.rcbSensorInventory.SelectedValue);
 
                if (sensor.sensorTypeKey == 7)
                {
                    sensor.temperatureType = Convert.ToChar(rcTemperatureType.SelectedValue);
                }
                else
                {
                    sensor.temperatureType = 'C';
                }
 
                var iot = new sfDataAccess();
                iot.updateIotSensor(sensor);
                string dockid = dashdockid.Value;
                //var raddock = iot.LoadRadDockState(sensor.regionKey, sensor.clientKey, sensor.entityKey);
 
                //foreach (var oneDock in CurrentDockStates)
                //{
                //    RadDock dock = CreateRadDockFromState(oneDock);
                //    if (oneDock.UniqueName == dockid)
                //    {
                //        dock.Title = sensor.SensorName;
                //        dock.Tag = getTag(WidgetType.BarWidget);
                         
                //    }
                //    RadDockLayout1.Controls.Add(dock);
                //    //We want to save the dock state every time a dock is moved.
                //    CreateSaveStateTrigger(dock);
                //    LoadWidget(dock);
                //}
 
                foreach (var item in RadDockLayout1.Controls)
                {
                    var x = item;
                }
                 
                for (int i = 0; i < CurrentDockStates.Count; i++)
                {
                    if (CurrentDockStates[i].Closed == true) continue;
                    RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
                    var resp1 = RadDockZone1.Docks.Contains(dock);
                    var resp2 = RadDockZone2.Docks.Contains(dock);
                    var resp3 = RadDockZone3.Docks.Contains(dock);
                    if (dock.UniqueName == dockid)
                    {
                        RadDockLayout1.Controls.RemoveAt(i);
                        dock.Title = sensor.SensorName;
                        dock.Tag = getTag(WidgetType.BarWidget);
                    }
                    //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);
                    //LoadWidget(dock);
 
                    // prevents the rendering of closed docks, used for improving
                    // performance
                    if (CurrentDockStates[i].Closed == true)
                    {
                        dock.Visible = false;
                    }
                }
                CurrentDockStates =RadDockLayout1.GetRegisteredDocksState();
                 
 
            }
            catch (Exception ex)
            {
                var iot = new sfGenerall();
                iot.InsertErrorLog(ex);
                RadNotification1.Text = ex.ToString();
                RadNotification1.Show();
 
            }
 
        }
 
        
 
    }
 
    protected void RadDock1_Command(object sender, Telerik.Web.UI.DockCommandEventArgs e)
    {
        if (e.Command.Name == "Close")
        {
 
        }
 
    }
 
    #region raddockState
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
 
        //Populate the event args with the state information. The RadDockLayout control
        // will automatically move the docks according that information.
        foreach (DockState state in CurrentDockStates)
        {
 
            e.Positions[state.UniqueName] = state.DockZoneID;
            e.Indices[state.UniqueName] = state.Index;
        }
 
 
    }
 
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        //Save the dock state in the page Session. This will enable us
        // to recreate the dock in the next Page_Init.
 
        CurrentDockStates = RadDockLayout1.GetRegisteredDocksState();
 
    }
 
 
 
    #endregion
 
    #region raddockState
 
    private List<DockState> CurrentDockStates
    {
        get
        {
            var iot = new sfDataAccess();
            List<DockState> _currentDockSates = iot.LoadRadDockState(regkey, clikey, entkey);
            //List<DockState> _currentDockSates = (List<DockState>)Session["CurrentDockStatesDynamicDock"];
            if (Object.Equals(_currentDockSates, null))
            {
                _currentDockSates = new List<DockState>();
            }
            return _currentDockSates;
        }
        set
        {
            var iot = new sfDataAccess();
            iot.SaveRadDockState(value, regkey, clikey, entkey);
            //Session["CurrentDockStatesDynamicDock"] = value;
        }
    }
 
    #endregion
 
    public void loadSensorInventory()
    {
        List<sfsSensorInventary> inventorySensor = new List<sfsSensorInventary>();
        var iot = new sfDataAccess();
        var sensor = new sfsSensorInventary();
        sensor.regkey = regkey;
        sensor.clientKey = clikey;
        sensor.entityKey = entkey;
        inventorySensor = iot.getSensorInventoryforDashboard(sensor);
 
 
        foreach (var x in inventorySensor)
        {
            //rcbSensorInventory.Items.Add(new RadComboBoxItem(x.sensorkey.ToString(), x.sensorsenrie));
            RadComboBoxItem item = new RadComboBoxItem();
 
            item.Text = x.sensorserie;
            item.Value = x.sensorkey.ToString();
 
            item.Attributes.Add("Marca", x.brandName.ToString());
            item.Attributes.Add("Modelo", x.modelName.ToString());
 
            if (x.checheck == x.sensorCount)
            {
                item.ForeColor = System.Drawing.Color.Red;
            }
            //else
            //{
            //    item.BackColor = ;
            //}
            //item.Value += ":" + unitPrice;
 
            rcbSensorInventory.Items.Add(item);
 
            item.DataBind();
        }
 
    }
 
    public void loadEntitiesList()
    {
        //if(regkey==0)
        //regkey =  Convert.ToInt32((object)Session["RegionKey"]);
 
        //if(clikey==0)
        //clikey = Convert.ToInt32((object)Session["ClientKey"]);
 
        var iot = new sfDataAccess();
        var entitiesList = iot.getEntityDataByUser(regkey, clikey);
 
        foreach (var entities in entitiesList)
        {
            if (entities.SensorCount > 0)
            {
                RadComboBoxItem item = new RadComboBoxItem();
                item.Value = entities.IdEntity.ToString();
                item.Text = entities.Name;
                //+ "("+entities.IdEntity.ToString()+") "
                cboEntities.Items.Add(item);
                if (item.Value == entkey.ToString())
                    item.Selected = true;
 
                item.DataBind();
            }
        }
 
        cboEntities.SelectedIndex = entkey - 1;
 
        //entTitle.Text = cboEntities.SelectedItem.Text;
    }
 
 
    public void loadSensorType()
    {
        List<sfsSensorType> sensorType = new List<sfsSensorType>();
        sfsDashController sfs = new sfsDashController();
        sensorType = sfs.loadddpSensorType();
        //DropDownListItem item = new DropDownListItem();
        foreach (var x in sensorType)
        {
            rcSensorType.Items.Add(new RadComboBoxItem(x.sensorName, x.sensorTypeId.ToString()));
 
        }
        //RadDropDownSensorType.DataSource = sensorType;
        //RadDropDownSensorType.DataBind();
 
    }
 
    public void loadTemperatureType()
    {
        rcTemperatureType.Items.Add(new RadComboBoxItem("Celsius","C"));
        rcTemperatureType.Items.Add(new RadComboBoxItem("Fahrenheit", "F"));
    }
 
    public void loadWidgetType()
    {
        rcWidgetType.Items.Add(new RadComboBoxItem(WidgetType.BarWidget.ToString(), WidgetType.BarWidget.GetType().ToString()));
        //rcWidgetType.Items.Add(new RadComboBoxItem(WidgetType.KendoAreaChart.ToString(), WidgetType.KendoAreaChart.GetType().ToString()));
    }
 
    public void loadRadDockZoneSensor()
    {
            //culture = new System.Globalization.CultureInfo(Session["USER_LANGUAGE"].ToString());
        int langNumber = 0;
        var lang = Session["USER_LANGUAGE"].ToString();
        if (lang.Substring(0, 2) == "en")
        {
            langNumber = 1;
        }
        //var  radDockName = new String[3]  {"Izquierda","Centro","Derecha"};
        var radDockName = new String[2, 3] { { "Izquierda", "Centro", "Derecha" }, { "Left", "Center", "Right" } };
         
        int zoneCount = 0;
        foreach (string x in SensorDockZone)
        {
            rcRadDockSensor.Items.Add(new RadComboBoxItem(radDockName[langNumber,zoneCount], x.ToString()));
            zoneCount++;
        }
    }
 
    private string getTag(WidgetType value)
    {
        string widgetName;
        switch (value)
        {
            case WidgetType.GaugeChart:
                widgetName = "~/app/Widget/GaugeChart.ascx";
                break;
            case WidgetType.Gauge:
                widgetName = "~/app/Widget/WeatherControl.ascx";
                break;
            case WidgetType.RadarChart:
                widgetName = "~/app/Widget/RadarChart.ascx";
                break;
            case WidgetType.AreaChart:
                widgetName = "~/app/Widget/AreaChart.ascx";
                break;
            case WidgetType.ImageDock:
                widgetName = "~/app/Widget/ImgWidget.ascx";
                break;
            case WidgetType.BarWidget:
                widgetName = "~/app/Widget/BarWidget.ascx";
                break;
            case WidgetType.KendoAreaChart:
                widgetName = "~/app/Widget/KendoAreaChart.ascx";
                break;
            default:
                widgetName = "~/app/Widget/WeatherControl.ascx";
                break;
        }
 
        return widgetName;
 
    }
 
    public string[] getZone(DockState state)
    {
        if (!String.IsNullOrEmpty(state.DockZoneID))
        {
            if (state.DockZoneID.Substring(11, 12) == "RadDockZone1")
            {
                return SensorDockZone;
            }
            else
            {
 
                return PrimaryDockZone;
            }
        }
        else
        {
            return null;
        }
    }
 
 
    
   
 
    
}

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 04 Aug 2016, 06:27 AM
Hello Juan,

I am not sure how exactly you update the content of the dock but you can find my comments and suggestions below:
    - If you want to ajaxify a dock and window it would be better to ajaxify only their content and not the control itself. More information on the matter is available in the following articles:
         - http://docs.telerik.com/devtools/aspnet-ajax/controls/dock/troubleshooting/placing-raddock-in-updatepanel
         - http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/how-to-use-radwindow-with-ajax
    - If you want to ajaxify a content by clicking a command button of the dock you can handle the client command of the dock where you can initiate an ajaxRequest to update the desired content - http://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/client-side-programming/overview#ajaxrequestarguments
    - You can examine the following articles that treats how to dynamically add dock controls with ajax:
          - http://demos.telerik.com/aspnet-ajax/dock/examples/dynamicdocks/defaultcs.aspx
          - http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx
    - This article shows how to open RadWindow from the server side - http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/opening-from-the-server

Regards,
Danail Vasilev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Dock
Asked by
Juan
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or