Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
74 views
Hi,

I want to use raddocks in sharepoint 2010 using ajax to create them and to reload their content.

My problem is happening when I add the first dock dinamically. The ajax request is made and my javascript is evaluated after the request is done but the i'm unable to get the RadDock client instance.

I already tried the hidden updatePanel approach and  the RadAjaxManager approach but I did not succeed.

Here is the code I'm using:

  • WebPart code (RadDockSpike.cs):

[ToolboxItemAttribute(false)]
public class RadDockSpike : WebPart
{
    // Visual Studio might automatically update this path when you change the Visual Web Part project item.
    private const string _ascxPath = @"~/_CONTROLTEMPLATES/Buv.Backoffice.WebAdmin/RadDockSpike/RadDockSpikeUserControl.ascx";
 
    private RadAjaxManager _ajaxManager;
 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
 
        // Init the ajax manager
        _ajaxManager = new RadAjaxManager();
        _ajaxManager.EnableEmbeddedScripts = true;           
        Page.Items.Add(typeof(RadAjaxManager), _ajaxManager);
        Page.Form.Controls.AddAt(0, _ajaxManager);
    }
 
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
         
        Control control = Page.LoadControl(_ascxPath);
        RadDockSpikeUserControl controlAux = control as RadDockSpikeUserControl;
        controlAux.AjaxManager = _ajaxManager;
        Controls.Add(control);
 
 
    }
}

  • Usercontrol loaded by the WebPart  (RadDockSpikeUserControl.cs):

public partial class RadDockSpikeUserControl : UserControl
{
    public RadAjaxManager AjaxManager;
 
    private List<DockState> _currentDockStates
    {
        get
        {
            //Store the info about the added docks in the session. For real life 
            // applications we recommend using database or other storage medium  
            // for persisting this information. 
            List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesMyPortal"];
            if (Object.Equals(_currentDockStates, null))
            {
                _currentDockStates = new List<DockState>();
                Session["CurrentDockStatesMyPortal"] = _currentDockStates;
            }
            return _currentDockStates;
        }
        set
        {
            Session["CurrentDockStatesMyPortal"] = value;
        }
    }
 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
 
        // Initialize toolbar
        RadToolBarButton button = new RadToolBarButton();
        button.Text = "Open new dock";
        ToolBar.Items.Add(button);
 
        ToolBar.ButtonClick += new RadToolBarEventHandler(ToolBar_ButtonClick);
 
        //Recreate the docks in order to ensure their proper operation 
        for (int i = 0; i < _currentDockStates.Count; i++)
        {
            if (_currentDockStates[i].Closed == false)
            {
                AddDockFromState(_currentDockStates[i]);
                //We want to save the dock state every time a dock is moved. 
            }
        }
    }
 
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
         
    }
 
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        AjaxManager.AjaxSettings.AddAjaxSetting(ToolBar, Panel1, AjaxLoadingPanel);
         
    }
 
    protected void HandleLoadDockLayout(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 HandleSaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        //Save the dock state in the session. This will enable us  
        // to recreate the dock in the next Page_Init.  
        _currentDockStates = DockLayout.GetRegisteredDocksState();
    }
 
    void ToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
    {
        AddDock("Untitled...");
    }
 
    private void AddDockFromState(DockState state)
    {
        RadDock dock = new RadDock();
        dock.ID = string.Format("Dock{0}", state.UniqueName);
        dock.ApplyState(state);
 
        Panel1.Controls.Add(dock);
 
        CreateSaveStateTrigger(dock);
    }
 
    protected void AddDock(string title)
    {
        RadDock dock = new RadDock();
        dock.UniqueName = Guid.NewGuid().ToString();
        dock.ID = string.Format("Dock{0}", dock.UniqueName);
        dock.Title = title;
        dock.Text = "Dock content";
        //dock.Resizable = true;
        //dock.EnableRoundedCorners = true;
 
        Panel1.Controls.Add(dock);
 
        CreateSaveStateTrigger(dock);
 
    // Here is the problem: The dock client instance is null???!!!
        string script = string.Format(@"                           
                        var dock = $find('{0}');
            alert('Dock: ' + dock);
                        //$find('{1}').dock($find('{0}'));
                        $find('{2}').ajaxRequest();",
                dock.ClientID, PageDockZone.ClientID, AjaxManager.ClientID);
 
        AjaxManager.ResponseScripts.Add(script);
 
 
    }
 
    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;
 
        AjaxSetting trigger = new AjaxSetting();
        trigger.AjaxControlID = dock.ID;
        trigger.EventName = "DockPositionChanged";
 
        AjaxUpdatedControl updatedControl = new AjaxUpdatedControl();
        updatedControl.ControlID = Panel1.ID;
 
        trigger.UpdatedControls.Add(updatedControl);
        AjaxManager.AjaxSettings.Add(trigger);
 
 
        trigger = new AjaxSetting();
        trigger.AjaxControlID = dock.ID;
        trigger.EventName = "Command";
 
        updatedControl = new AjaxUpdatedControl();
        updatedControl.ControlID = Panel1.ID;
 
        trigger.UpdatedControls.Add(updatedControl);
        AjaxManager.AjaxSettings.Add(trigger);
    }
}
   

  • Usercontrol loaded by the WebPart  (RadDockSpikeUserControl.ascx):
<telerik:RadToolBar ID="ToolBar" runat="server">
     
</telerik:RadToolBar>
  
<asp:Panel ID="DocksContainer" runat="server">
    <telerik:RadDockLayout ID="DockLayout" runat="server" OnLoadDockLayout="HandleLoadDockLayout" OnSaveDockLayout="HandleSaveDockLayout" >   
                  
        <telerik:RadDockZone ID="PageDockZone" runat="server">
  
        </telerik:RadDockZone>
  
       <div style="display: block">
            Hidden Ajaxified asp:Panel, which is used to receive the new dock controls. We will move
            them with script to the desired initial dock zone.
            <asp:Panel ID="Panel1" runat="server">
            </asp:Panel>
        </div>
  
  
    </telerik:RadDockLayout>
</asp:Panel>
  
<telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel" runat="server" Skin="Default" MinDisplayTime="500">
</telerik:RadAjaxLoadingPanel>



Can someone help me?

Michael Pinheiro
Pero
Telerik team
 answered on 23 Mar 2011
1 answer
89 views
Below is my code. my query is if i use Button type as LinkButton, i got the result. But the type is Image/push button then the back-end code doesn't work. whats the problem in this? can any one help?


    <telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" GridLines="None"
            AutoGenerateColumns="False" PageSize="13" AllowSorting="True" AllowPaging="True"
            ShowStatusBar="True" >
            <MasterTableView DataKeyNames="Cid" AllowMultiColumnSorting="True" Width="100%"
                CommandItemDisplay="None">
                <Columns>
                    <telerik:GridBoundColumn UniqueName="Cid" SortExpression="Cid" HeaderText="Cid"
                        DataField="Cid" Visible="false" />
                    <telerik:GridDateTimeColumn UniqueName="HolidayDate" SortExpression="HolidayDate" HeaderText="Date"
                        DataField="HolidayDate" DataFormatString="{0:d}" />
                    <telerik:GridBoundColumn UniqueName="HolidayFor" SortExpression="HolidayFor" HeaderText="Holiday name"
                        DataField="HolidayFor" />
                    <telerik:GridButtonColumn UniqueName="EditColumn" CommandName="Edit" ButtonType="ImageButton" 
                        HeaderText ="Action" Text="Edit" HeaderStyle-Width="20px" />
                    <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="LinkButton" 
                        Text="Delete"  HeaderStyle-Width="20px"/>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents />
            </ClientSettings>
        </telerik:RadGrid>

    Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("Cid").ToString
        If e.CommandName = "Delete" Then
            Response.Write(ID)
end if
    End Sub

Pavlina
Telerik team
 answered on 23 Mar 2011
1 answer
81 views
Hello,

I want to refresh/reload a individual raddoc on the layout on Custom Command click. If I make autopostback=true then it refresh complete page and all raddocs get refreshed.

Can you suggest me refresh individual raddoc keeping rest intact on page ?

Thanks,
Prayag
Pero
Telerik team
 answered on 23 Mar 2011
22 answers
1.0K+ views
Hi all.

I am rewriting a rather large web application with just about 100 lists in it. We have to access control the lists, and the actions performed on them so we are trying to make the creation of the lists (RadGrids) dynamic.

In the old system, we would have a XML config file for the lists and then do the HTML by hand for each list.

We would like to continue using the XML file, and with regular GridBoundColumn types it works fine. We find ourselves in some problems when we need to display 2 field names in one column, then we have to use GridTemplateColumn.

With more than 100 lists, all with different datasources, things get a bit tricky. We have implemented a simple ITemplate for 1 datasource, but because all the datasources are different, this does not seem to be a viable solution. We would have to create an eventListener for all the special columns in all the datasources, with some very tricky coding ...

Is there any way we can send into the column collection a simple string like just like when we are creating a template column in the ASPX file:

<telerik:GridTemplateColumn>
<ItemTemplate>
<a href="<%#Eval("LinkUrl")%>"><%#Eval("LinkText")%></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
Is it possible for us to use the <a href="<%#Eval("LinkUrl")%>"><%#Eval("LinkText")%></a> model to create these columns in any way ??
Iana Tsolova
Telerik team
 answered on 23 Mar 2011
1 answer
58 views
Hello

I am trying to implement the google like filtering as described in your help topic with my RadGrid (v2010.3.1317.40).
I have done all you describe but I still have an error when I click in combobox :

The target '....' for the callback could not be found or did not implement ICallbackEventHandler.

I do not understand why my ItemsRequested event is never fired.

Can you help me on this?
Read you soon
Pavlina
Telerik team
 answered on 23 Mar 2011
4 answers
71 views
Hello,
I am running into an issue where I need to set document.domain in order to allow communication between rad windows.  an unintended consequence seems to be that radeditors no longer function.  I found an old thread about this from 2009, but there didn't seem to be a solution.  Is there a work around, or fix for this issue? 

Also, it seems to be affecting the RadUpload Progress Bar as well.

Thanks
Lance
Rumen
Telerik team
 answered on 23 Mar 2011
5 answers
145 views
Hi

Am using inline editing ,setting  item to edit mode in grid prerender event it takes long time to rebind.

Is there workaround for it.

Also i use another method , when i load the grid initially  i use editindexes.add to set all the items in edit mode but when i navigate to next page the grid is not rendering in edit mode.

since our company is facing more issues in telerik am facing hard time to convince my manager.

Please help it is urgent.

Regards

Sathya
Sebastian
Telerik team
 answered on 23 Mar 2011
1 answer
41 views
I have a panel and I would like the items in it to not have scroll bars when i expand them. There is plenty of room at the bottom of the page to expand these to fit the items without use of scrollbars. I have tried palying with the height and childheight settings for all the parts but nothing makes any changes at all.
Helen
Telerik team
 answered on 23 Mar 2011
3 answers
67 views
Hi Everyone,

OK I have a page with several lists of companies.  I want the first list to show gas service providers, the next electricity providers etc.  My objectdatasource can filter the type of company that it returns and I'd like to use the single objectdatasource for all combo boxes.  I thought OK I'll determine which combo is requesting the data in the Selecting event and supply the relevant CompanyTypeID as a param there.  Doh, I can't seem to work out which combo is requesting the list.

1) Is there something that I have missed re getting the calling object?
2) Short of having multiple different objectdatasources for each company type is there a work around?

This is inside a Formview to make it a little more complex.

Best Regards,

Jon
Jon
Top achievements
Rank 1
 answered on 23 Mar 2011
1 answer
203 views

Ver 2010.3.1317.35, IE8, Windows 7 Skin, Windows 7 x64 OS

I'm using a simple border and background colour to highlight the focused fields in my application via the skin file:-

 

<telerik:RadTextBox runat="server" >
    <FocusedStyle BackColor="#EEF6FF" BorderColor="Red" /> 
</telerik:RadTextBox>

Unfortunately this option isn't implemented in all controls (which would be the ideal solution) so I have used the StyleBuilder to try and implement a simialr function for the RadComboBox....

Unfortunately No matter what I do I cannot seem to get the Focused RadComnoBox to be the same height as the normal one making the screen jump up and down as I move from Combo Boxes to Text boxes.

I've added a Border of 1 in red to the focused control which works fine but when I add a transparent border of 1 to the normal control it just seems to ignore it? It look correct in Style Builder but when I save and download it then reload from the zip it has removed the border? Any ideas?


Thanks

Kamen Bundev
Telerik team
 answered on 23 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?