Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
170 views
This is probably a classic issue regarding update of dock content, but I can't get the docks to update or move the docks without the entire page is reloaded.

My code is base on an example I found here in the forum written by Telerik, and I have only made a few modifications.

I have moved public List<DockState> GetCurrentDockStates(string userkey, string frmName) to a widget class.

On page_init the docks are initiated from state. On page_load docks that are not in state are initiated and ascx controls are then loaded for all docks. 

I have 2 main problems.

1. I can't move or minimize a dock without the entire page reloads. If it isn't possible to move one dock without having to recreate all docks registered in the given RadDockLayout when I want to save the state (which is what I'm doing now), that is fine if just the RadDock components and their content is reloaded but the top menu and the rest of the page isn't. How can I change my code to achieve that?

2. I can't update the content of one dock without the entire page reloads. How can I update the content of one dock without the other docks or other page content is reloaded?

Hope someone here can help me out.

Thanks.

/Thomas


Widget class .aspx

        public List<DockState> GetCurrentDockStates(string userkey, string frmName)
        {
            //Get saved state string from the database - set it to dockState variable for example
            string dockStatesFromDB = "";
            dockStatesFromDB = DbUtils.GetUserSettings(userkey, frmName, settingsKey);
            List<DockState> _currentDockStates = new List<DockState>();
            if ((dockStatesFromDB != null) && (dockStatesFromDB != ""))
            {
                string[] stringStates = dockStatesFromDB.Split(';');
                foreach (string stringState in stringStates)
                {
                    if (stringState.Trim() != string.Empty)
                    {
                        _currentDockStates.Add(DockState.Deserialize(stringState));
                    }
                }
            }
            return _currentDockStates;
        }


Default.aspx.cs

 

    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
            Widget _widget = new Widget();
            List<DockState> _currentDockStates = _widget.GetCurrentDockStates((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).KeyID, DebugFormName);
            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)
    {

        List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();

        StringBuilder serializedList = new StringBuilder();

        Widget _widget = new Widget();
        List<DockState> _currentDockStates = _widget.GetCurrentDockStates((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).KeyID, DebugFormName);
        bool state_closed;
        foreach (DockState _dockState in stateList)
        {
            state_closed = false;
            foreach (DockState _dockState2 in _currentDockStates)
            {
                if (_dockState2.UniqueName == _dockState.UniqueName)
                {
                    if (_dockState2.Closed)
                    {
                        state_closed = true;
                        serializedList.Append(_dockState2.ToString());
                        serializedList.Append(";");
                    }
                }
            }
            if (!state_closed)
            {
                serializedList.Append(_dockState.ToString());
                serializedList.Append(";");
            }
        }

        string dockState = serializedList.ToString();
        if (dockState.Trim() != String.Empty)
        {
            DbUtils.SetUserSetting((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).KeyID, "Default", "WidgetState", dockState);
        }

    }

    private RadDock CreateRadDockFromState(DockState state)
    {
        Widget widget = new Widget();
        XPOWidgetSettings xpoWidgetSettings = widget.getWidgetSettingsObjectById(state.UniqueName);

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

    private RadDock CreateRadDock(string oid, string displayName, string widgetSettings)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.UniqueName = oid;
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);

        DockCloseCommand closeCmd = new DockCloseCommand();
        dock.Commands.Add(closeCmd);
        DockExpandCollapseCommand cmd = new DockExpandCollapseCommand();
        dock.Commands.Add(cmd);

        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;

        AjaxUpdatedControl updatedControl = new AjaxUpdatedControl();
        updatedControl.ControlID = "Panel1";

        AjaxSetting setting1 = new AjaxSetting(dock.ID);
        setting1.EventName = "DockPositionChanged";
        setting1.UpdatedControls.Add(updatedControl);

        AjaxSetting setting2 = new AjaxSetting(dock.ID);
        setting2.EventName = "Command";
        setting2.UpdatedControls.Add(updatedControl);

        RadAjaxManager1.AjaxSettings.Add(setting1);
        RadAjaxManager1.AjaxSettings.Add(setting2);
    }

    private void LoadUserWidgets()
    {
        Widget widget = new Widget();
        string radDockID;
        string displayName;
        string settingString;

        List<DockState> _currentDockStates = widget.GetCurrentDockStates((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).KeyID, DebugFormName);
        XPCollection widgetSettingsObjectsByUserLevel = widget.getWidgetSettingsObjectsByUserLevel((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).Userrole);

        Boolean _doContinue;
        foreach (XPOWidgetSettings _widgetSetting in widgetSettingsObjectsByUserLevel)
        {
            _doContinue = false;
            radDockID = _widgetSetting.Oid.ToString();
            displayName = _widgetSetting.DisplayName;
            settingString = _widgetSetting.Settings;

            foreach (DockState _ds in _currentDockStates)
            {
                if (_ds.UniqueName == radDockID)
                    _doContinue = true;
            }
            if (_doContinue) continue;
            RadDock dock = CreateRadDock(radDockID, displayName, settingString);
            //find the target zone and add the new dock there

            //adding the dock to the docklayout and then docking it to the zone to avoid ViewState issues on subsequent postback
            RadDockLayout1.Controls.Add(dock);

            dock.Dock(DZCenter);

 

            CreateSaveStateTrigger(dock);

            //Load the selected widget in the RadDock control
            dock.Tag = _widgetSetting.AscxFile;
            LoadWidget(dock);
        }
    }

    private void LoadWidget(RadDock dock)
    {
        string siteUrl = TCFramework.TCConfigSettings.HostUrlGroups + Session[TCSessionConst.SessionFrmDefault_SelGroup];
        string userName = (Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).Username;
        string password = (Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).GetPassword();
        string ascxFile = "";
        string settings = "";

        string oId = dock.UniqueName;

        Widget widget = new Widget();
        XPOWidgetSettings xpoWidgetSettings = widget.getWidgetSettingsObjectById(oId);

        ascxFile = xpoWidgetSettings.AscxFile;
 settings = xpoWidgetSettings.Settings;

        Control widgetControl = LoadControl(ascxFile);
        if (widgetControl != null)
         dock.ContentContainer.Controls.Add(widgetControl);
    }

    private void CreateDocksFromStateDB()
    {
        Widget _widget = new Widget();
        List<DockState> _currentDockStates = _widget.GetCurrentDockStates((Session[TCSessionConst.SessionFrmDefault_XpoUser] as XpoUser).KeyID, DebugFormName);
        for (int i = 0; i < _currentDockStates.Count; i++)
        {
            RadDock dock = CreateRadDockFromState(_currentDockStates[i]);
            dock.Visible = !_currentDockStates[i].Closed;
            RadDockLayout1.Controls.Add(dock);

            //We want to save the dock state every time a dock is moved.

            if (dock.Visible) CreateSaveStateTrigger(dock);
        }
    }

 

    protected void Page_Init(object sender, EventArgs e)
    {
        CreateDocksFromStateDB();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (RadDock _rd in RadDockLayout1.RegisteredDocks)
            try
            {
                LoadWidget(_rd);
            }
            catch
            {
                //error in loading widget _rd.
            }

        if (!IsPostBack)
        {
            LoadUserWidgets();
        }
    }


Default.aspx

    <div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server"
            onloaddocklayout="RadDockLayout1_LoadDockLayout"
            onsavedocklayout="RadDockLayout1_SaveDockLayout">
            <table width="100%" cellpadding="12px">
                <tr>
                    <td width="25%" valign="top">
                        <telerik:RadDockZone ID="DZLeft" runat="server" BackColor="#BFDBFF"
                            ForeColor="#BFDBFF">
                        </telerik:RadDockZone>
                    </td>
                    <td width="50%" valign="top">
                        <telerik:RadDockZone ID="DZCenter" runat="server" BackColor="#BFDBFF"
                            Visible="True" ForeColor="#BFDBFF">
                        </telerik:RadDockZone>
                    </td>
                    <td width="25%" valign="top">
                        <telerik:RadDockZone ID="DZRight" runat="server" BackColor="#BFDBFF"
                            ForeColor="#BFDBFF">
                        </telerik:RadDockZone>
                    </td>
                </tr>
            </table>
        </telerik:RadDockLayout>
    </div>
    <div style="width: 0px; height: 0px; overflow: hidden; position: absolute; left: -10000px;">
        Hidden UpdatePanel, which is used to help with saving state when minimizing, moving
        and closing docks. This way the docks state is saved faster (no need to update the
        docking zones).
        <asp:UpdatePanel runat="server" ID="UpdatePanel1">
        </asp:UpdatePanel>
    </div>

Shirlee
Top achievements
Rank 1
 answered on 15 Dec 2016
12 answers
235 views
Hi,

    I have one question, is that RadEditor supports including of image as a content, when user enter text as well as image, right now it looks like it is not allowing to paste image under the RadEditor control.   Please let me know, if there are any suggestions.

Regards,
Satya
Rumen
Telerik team
 answered on 15 Dec 2016
1 answer
74 views

Occurs in IE11, IE10, or IE9 (Works in IE8).

  1. Copy a table from MS word/excel into editor.
  2. Right-click right most column.
  3. Select Column > Delete Column.

Unable to select other rows in copied table or edit table cells.

Rumen
Telerik team
 answered on 15 Dec 2016
6 answers
231 views
Hi,

I have 3 questions:

1. I have set the AutoCompleteBox to allow only single mode selection; however, after the user has picked the data I noticed that the control still displays like a linefeed / space as if the user is still allowed to enter more [but it doesn't allow him to enter more than one; I mean it's only adding this space] and I'm not ok with this behaviour. Suggestions? [Pictures attached].

2. Let's say the page I have saves and displays the details of a certain item; and I use an AutoCompleteBox for the country of origin field. In saving, I won't have a problem since the AutoCompleteBox will display proper data for the user to choose from. But in displaying the saved database records, sometimes the country database field might not have a proper value and still be valid; like "USA" instead of "United States", I want to still be able to view that kind of data in the AutoCompleteBox regardless. Is this possible? How can I do it?

3. After the user has entered the letters to search for in the AutoCompleteBox, you know there's like a one second delay before displaying the data for him. How can I add like a "loading..." text in the AutoCompleteBox until the data is retrieved for him?

Many thanks!
chetna
Top achievements
Rank 1
 answered on 15 Dec 2016
3 answers
278 views

I have run into a whole bunch of problems with the editor control on iPhone/Safari devices in the latest release. The .focus() client-side method doesn't appear to work when inside a timeout. In this case, the editor can never receive focus either. Touching inside the editor does not bring up the keyboard.

 

Without a timeout, the editor receives focus and the keyboard comes up, however, when users type, no letters are displayed. THe cursor moves along as if typing is occurring, but nothing is shown in the editor. I tried the Lightweight RenderMode, which didn't look very good in iOS. I tried the Mobile Rendermode, which displayed better, but didn't function properly. Typing in the editor would display a white screen which covered the rest of the site and could never be recovered.

I have reverted back to a previous version of the controls (Q1). Needing to do this is becoming an all-too frequent occurrence.

Ianko
Telerik team
 answered on 15 Dec 2016
1 answer
136 views

Hi:

I copy those code from local demo on my empty and practice site.

         <telerik:RadMediaPlayer RenderMode="Lightweight" ID="RadMediaPlayer1" runat="server" AutoPlay="true"
            Height="360px" Width="640px">
            <PlaylistSettings YouTubePlaylist="PLvmaC-XMqeBb991YNEWAHYL9ZJAeURr-r" Mode="Buttons" ButtonsTrigger="MouseDown" />
        </telerik:RadMediaPlayer>

but when I run, only media player and other nothig. 

The same code on local demo can run very well, What's happen on my site ?

Eyup
Telerik team
 answered on 15 Dec 2016
12 answers
971 views
Hello,

I have a grid and the Insert/Update/Delete events are handled in the 'ItemCommand' event.
I'm now trying to get the dataItem row that was updated/inserted so that I can select it and then change it's BackColor.

Here is what I have now in the ItemCommand  Event:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
   if ((e.CommandName == RadGrid.PerformInsertCommandName) || (e.CommandName == RadGrid.UpdateCommandName))
   {
      GridEditableItem saveableItem = (GridEditableItem)e.Item;
      SaveItems(saveableItem, e.Item.OwnerTableView.IsItemInserted);
   }
}

I trying to do something like:  saveableItem.Selected = true;
but this way won't work because it's the editableItem vs the dataItem.

So my questions:
- Is this the right event to handle this?  If not, what event should I call to handle this (from ItemCommand if possible)?
- How do I 'get' the inserted/updated item, so that I can 'do something' (Select, change BackColor, add Border, etc. after the action)?

Thank you in advance,
Ronnie
Eyup
Telerik team
 answered on 15 Dec 2016
9 answers
1.1K+ views
Hi Telerik Team - I have a grid that has gridTemplateColumn checkbox column. so If the user checks some rows and in the second screen if he checks some rows then return backs to previous rows needs to show correct records. I searched in this forum, found code and created with northwind database. But sometimes when I check some items in 4 pages and then returns back not preserving the checkboxes as expected. Can anyone please guide me on this?
aspx:
  
<telerik:GridTemplateColumn UniqueName="TemplateColumn" SortExpression="LastName">
                                        <ItemTemplate>
                              
                                <asp:checkbox ID="checkColumn" runat="server" />
                              
          </ItemTemplate>
         </telerik:GridTemplateColumn>
                                          
                                           
                                             
                                           <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" 
                                               HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" 
                                               UniqueName="OrderID">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" 
                                               HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" 
                                               UniqueName="ProductID">
                                           </telerik:GridBoundColumn>
                                           <telerik:GridBoundColumn DataField="UnitPrice" DataType="System.Decimal" 
                                               HeaderText="UnitPrice" SortExpression="UnitPrice" UniqueName="UnitPrice">
                                           </telerik:GridBoundColumn>
                                      
  
                                          
                                           
                                             
                                        </Columns> 
  
  
  
aspx.cs:
  
 ArrayList selectedItems; 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState["Selected"] = null;
        }  
  
    }
  
    private void RememberSelected()
    {
        selectedItems = new ArrayList();
        int index = -1;
  
       // foreach (GridDataItem row in  RadGrid1.MasterTableView.Items)//RadGrid1.Items)
            foreach (GridDataItem row in RadGrid1.Items)
        {
            index = (int)row.GetDataKeyValue("ProductID");
            bool result = ((CheckBox)row.FindControl("CheckColumn")).Checked;
  
            // Check in the Session   
            if (ViewState["Selected"] != null)
                selectedItems = (ArrayList)ViewState["Selected"];
            if (result)
            {
                if (!selectedItems.Contains(index))
                    selectedItems.Add(index);
            }
            else
                selectedItems.Remove(index);
        }
  
        if (selectedItems != null && selectedItems.Count > 0)
            ViewState["Selected"] = selectedItems;
    }
  
  
    protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
    {
        RememberSelected();
    }
  
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (selectedItems != null)
        {
            if (e.Item is GridDataItem)
             
            {
                GridDataItem row = (GridDataItem)e.Item;
  
                int index = (int)row.GetDataKeyValue("ProductID");
  
                if (selectedItems.Contains(index))
                {
                    e.Item.Selected = true;
                     
                     
                }
            }
        }
    }
  
    protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e)
    {
        RememberSelected();
    }  


Eyup
Telerik team
 answered on 15 Dec 2016
3 answers
336 views
hi,
Iam using Radgrid for my ASP.Net project.
I want to design,bound ,bind and create events for my grid by program.
for ex in my design i will have

<telerik:radgrid ID="RadGrid1" runat="server" >

              </telerik:radgrid>


In page init i define all bound columns and design of grid and create a event for the grid for ex.
 protected void Page_Init(object source, System.EventArgs e)
    {
        Loadprogramaticgrid();
        RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    }

  private void Loadprogramaticgrid()
    {
             RadGrid1.MasterTableView.DataKeyNames = new string[] { "username" };
        RadGrid1.Skin = "Default";
        RadGrid1.Width = Unit.Percentage(100);
              RadGrid1.AutoGenerateColumns = false;
        //Add columns
        GridBoundColumn boundColumn;
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "username";
        boundColumn.HeaderText = "username";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "firstname";
        boundColumn.HeaderText = "firstname";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);

        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "lastname";
        boundColumn.HeaderText = "lastname";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
     
    }
 protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = loaddata();
    }
and i have a Button and in button click i rebind the grid as
 protected void Button1_Click(object sender, EventArgs e)
    {
        RadGrid1.Rebind();
    }

now the problem is for first time the grid binds and display the data in grid.
When i click the button the grid is not binding correctly.
i have attached the image for more referance.

Naga
Top achievements
Rank 1
 answered on 14 Dec 2016
2 answers
421 views

Hi,

I'm porting some old code to Telerik and I'm having issues. This application has a grid and two of the columns contains hyperlinks that would execute java code to open a non-modal windows to present more details on the items with hyperliks
In the old code, this solved by a template like this:

<ItemTemplate>
              <asp:HyperLink ID="hplnkCatalogDetails" runat="server" ToolTip='Click To View Details'    Text='<%# Eval("ID") %>' NavigateUrl="<%#String.Format(&quot;javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>" />                                                
</ItemTemplate>

 

However this solution fails to execute if using this solution with Telerik GridTemplateColumn :

<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Catalog" UniqueName="TemplateColumn" DataField="ID">
                                                        <ItemTemplate>
                                                          <asp:HyperLink ID="hplnkCatalogDetails2" runat="server" ToolTip='Click To View Details'
                                                                    Text='<%# Eval("ID") %>' NavigateUrl="<%#String.Format(& quot;javascript:void(window.showModalDialog     ('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>" />
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>

 

and this other approach does not work neither using GridHyperLinkColumn:

                                                   
                                                    <telerik:GridHyperLinkColumn AllowSorting="False" DataTextField="ID" FilterControlAltText="Filter column column" HeaderText="Catalog" UniqueName="colID"
                                                      
                                                        NavigateUrl= "&quot;<%#String.Format(& quot;javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>&quot;"
                                                        DataNavigateUrlFields="ID"
                                                        DataNavigateUrlFormatString="javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'))" >
                                                       
                                                    </telerik:GridHyperLinkColumn>

 

How should I address this?

 

 

 

Miguel
Top achievements
Rank 1
 answered on 14 Dec 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?