Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
149 views
Hi,

I have nested Rad Splitters,
RadSplitter1 is divided horizontally to RadPane1 and RadPane2 with a height of 130px.
    RadPane1  is once again divided horizontally by  RadSplitter2 into RadPane11 and RadPane12.
             RadPane11  wraps a Grid  and RadPane12 contains collection of Buttons. RadPane12 is set a height of 120px  and top RadPane11 is expected to fill remaining area.


RadPane 2 (height=130px)  initially is in collapsed state and RadPane12 is also in collapsed state. With this setting, RadPane11 should cover 100% browser height. However, it renders by covering (Browser Height - RadPane2's Height)

But when RadPane2 is in expanded mode everything renders appropriately.Please see attachment to have a better idea on my issue. Is there any solution to my issue ?

Thanks,
Prava
Dobromir
Telerik team
 answered on 01 Sep 2010
1 answer
101 views
Hi,

I am creating a grid programmatically, because I don't know the columns ahead of time. The grid is Index Funds vs. As Of Date. So there is a row for each As Of Date and a column for each Index Fund. The cell intersection is the monthly return for the Index Fund for the As Of Date. I have created Template columns to represent the returns in display and edit mode. If I edit a row, the edit controls appear. However when I save them by clicking the update button in the row, I am unable to obtain the newly edited values. GridEditableItem returns the item in the UpdateCommand event handler, however ExtractValuesFromItem returns an empty array and the SavedOldValues in the item is similarly empty. Is there any example of how to do this? I can post code if necessary.

Steve
Martin
Telerik team
 answered on 01 Sep 2010
2 answers
88 views
Hi, i'm working with the sample that persists grid setting to an xml file. I have a tree view loaded with form names that loads a dynamic grid. Saves and loads settings ok. I changed

SettingsDDL.DataSource =

GridPersisterUtility.GetSettingIds(name + "GridSettings.xml");

 


where "name" is the name of the form seleted from treeview so i have an xml file for each form
I load all the saved settings into the combo based on the tree sellection, however this only works for the first node selected
clearing the combo and databind to different xml file does nothing even though the xml is loaded correctly

// in node click event
  
string selectedValue = SettingsDDL.SelectedValue;
            SettingsDDL.Items.Clear(); // doesnt clear
            SettingsDDL.Items.Add(new RadComboBoxItem("", ""));
            SettingsDDL.DataSource = GridPersisterUtility.GetSettingIds(Session["nodeText"].ToString() + "GridSettings.xml"); // loads data from selected xml file ok
            SettingsDDL.DataBind(); // still contains original data
            SettingsDDL.Items.FindItemByValue(selectedValue).Selected = true;
Radoslav
Telerik team
 answered on 01 Sep 2010
1 answer
71 views
Hello,

I have two pages. In one page I have the RadComboBox and based on the value of RadComboBox the grid populates.

Now I have the other page which has the grid with GridHyperlinkColumn which points to that page. When I click on the hyperlink I want the value of the RadComboBox from the other page to the current page.

How can I get that ?

Thanks,
Parth
Princy
Top achievements
Rank 2
 answered on 01 Sep 2010
6 answers
147 views
This one is a little bizarre, so forgive me if I don't describe this perfectly.

I'm in the process of updating custom web parts from our 2007 to 2010 deployment. For 2007, I had a Smartpart-style web part (ascx control wrapped in a web part class). For 2010, I'm taking advantage of the VS2010 Web Part projects (Visual Web Part in this case) and the native SP debugging.

The control for the webpart is designed around the following structure:

RadAjaxPanel
    RadTabStrip (2 tabs)
        RadMultiPage
            Pageview1
                 Formview (bound to ObjectDataSource)
            Pageview2
                 RadEditor

Due to databinding and speed concerns, the original web part was designed to use the RenderSelectedPageOnly option on the multipage. So with this setup, I'm experiencing the following behaviors:

1. When RenderSelectedPageOnly=false and the formview is in the display view, everything works great - editor loads content properly, allows editing correctly, etc.
2. RenderSelectedPage= false, Formview in Edit view - when you click on the tab to bring up the Editor, there is an outline around where the editor should be, but there is no content nor any controls.
3. When RenderSelectedPageOnly = true, the Editor does not display correctly, regardless of what mode the Formview is in.

Occasionally, with #2 and 3, the following javascript error displays momentarily:

Sys.ArgumentUndefinedException: Value cannot be undefined. Parameter name: type from ScriptResource.axd.

Any thoughts on what could be causing this strange series of behaviors?


ETA - I spent more time playing with this, and the problem seems to be with the Ajax controls (or at least how the editor is working with them). When I remove the AjaxPanel and just let the webpart go pure postback, everything works great. I then tried it with a RadAjaxManager instead of the panel, and the same behavior was displayed as with the panel. Wanted to include that info if that helps track this issue down.
Iana Tsolova
Telerik team
 answered on 01 Sep 2010
16 answers
418 views
Hi,

I have a aspx form with a Master Page.  The Master Page has a RadScriptManager.  The form has an UpdatePanel with a RadDockLayout and RadDockZone control.  The logic will dynamically load RadDock controls.  The RadDock controls each have an embedded usercontrol.  The user control has navigation buttons.  I cannot get the click events of the buttons in user control to fire. 

I figured the solution was to register an AsyncPostBackTrigger event for each button.  I tried to do this in three different ways with no success:

1)Pass the update panel to the user control.  The user control registers the trigger and adds it to the update panel.  I tried setting the controlid parameter to ID, CLientId and UniqueId.  I get an error stating the the Update panel cannot find the "Control Name" .
2) Get a reference to the radscriptmanager and use RegisterAsyncPostBackControl to register each button control.  I get no errors, but no click events either.
3) Provide properties for the client id in the user control.  Register the user control in the form using method #1.  I get the same error as #1 as well.

Thanks,

Al Rosner



Source for ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" 
    MasterPageFile="~/loggedIn.master" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<%@ Register Src="~/UserControls/Gadget.ascx" TagName="Gadgets" TagPrefix="uc" %> 
<asp:Content ID="ContentArea" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">  
    <asp:UpdatePanel runat="server" ID="UpdatePanel1">  
        <ContentTemplate> 
            <telerik:RadDockLayout runat="server" ID="rdlGadgets" OnSaveDockLayout="rdlGadgets_SaveDockLayout" 
                OnLoadDockLayout="rdlGadgets_LoadDockLayout">  
                <telerik:RadDockZone runat="server" ID="rdzGadgets" Orientation="Horizontal" Width="100%" 
                    MinHeight="200" Style="float: left; margin-right: 20px;">  
                </telerik:RadDockZone> 
            </telerik:RadDockLayout> 
        </ContentTemplate> 
    </asp:UpdatePanel> 
    <br /> 
    <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" /> 
</asp:Content> 

Code Behind for ASPX

using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using Telerik.Web.UI;  
using System.Collections.Generic;  
 
public partial class Home : System.Web.UI.Page  
{  
    private const string _createPage = "CreateGadget.aspx?Id=";  
 
    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.  
            //get data  
            DataLayer.toReadGadgetsDataTable gadgets = DataAccess.GetGadgets(Users.GetUserInfo.UserId);  
 
            List<DockState> currentDockStates = new List<DockState>();  
 
            foreach (DataRow dr in gadgets.Rows)  
            {  
                DataLayer.toReadGadgetsRow row = dr as DataLayer.toReadGadgetsRow;  
 
                currentDockStates.Add(CreateDockState(row));  
            }  
 
            return currentDockStates;  
        }  
        set 
        {  
            List<DockState> currentDockStates = value;  
 
            foreach (DockState dockState in currentDockStates)  
            {  
                DockStateTag tag = new DockStateTag(dockState.Tag);  
                //update gadget in db  
                DataAccess.UpdateGadget(  
                    int.Parse(dockState.UniqueName),  
                    tag.SearchCriteria,  
                    dockState.Title,  
                    dockState.Index,  
                    tag.DisplayRows  
                    );  
            }  
        }  
    }  
 
    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 RadDock CreateRadDockFromState(DockState state)  
    {  
        RadDock dock = new RadDock();  
        dock.DockMode = DockMode.Docked;  
        dock.ID = state.UniqueName;  
        dock.ApplyState(state);  
        dock.Commands.Add(new DockCloseCommand());  
        dock.Commands.Add(new DockExpandCollapseCommand());  
 
        DockCommand dc = new DockCommand();  
        dc.AutoPostBack = true;  
        dc.Name = "Edit";  
        dock.Commands.Add(dc);  
 
        dock.Command += new DockCommandEventHandler(dock_Command);  
        return dock;  
    }  
 
    private DockState CreateDockState(DataLayer.toReadGadgetsRow row)  
    {  
        DockState dockState = new DockState();  
        dockState.UniqueName = row.GadgetId.ToString();  
        dockState.Title = row.Title;  
        dockState.Width = Unit.Pixel(300);  
        DockStateTag tag = new DockStateTag(row.SearchCriteria, row.DisplayRows);  
        dockState.Tag = tag.Tag;  
        dockState.Index = row.Rank;  
        return dockState;  
    }  
 
    private void Initialize()  
    {  
        List<DockState> dockStates = CurrentDockStates;  
        int count = dockStates.Count;  
        for (int i = 0; i < count; i++)  
        {  
            RadDock dock = CreateRadDockFromState(dockStates[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).  
 
            //load gadget control into dock  
            UserControls_Gadget c = (UserControls_Gadget)LoadControl("~/UserControls/Gadget.ascx");  
            c.ID = "Gadget" + i.ToString();  
            DockStateTag tag = new DockStateTag(dock.Tag);  
            c.DisplayRows = tag.DisplayRows;  
            c.SearchCriteria = tag.SearchCriteria;  
 
            dock.ContentContainer.Controls.Add(c);  
 
            rdzGadgets.Controls.Add(dock);  
 
            c.SetTriggers(this.UpdatePanel1);  
 
            //We want to save the dock state every time a dock is moved.  
            CreateSaveStateTrigger(dock);  
 
 
        }  
    }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        //on init, load all docks in this event so display will occur in sequence  
        if (!IsPostBack)  
        {  
            Initialize();  
        }  
    }  
 
    protected void Page_Init(object sender, EventArgs e)  
    {  
        //on postback, initialize dock controls so they will display  
        if (IsPostBack)  
        {  
            Initialize();  
        }  
    }  
 
    void dock_Command(object sender, DockCommandEventArgs e)  
    {  
        if (sender is RadDock)  
        {  
            RadDock radDock = sender as RadDock;  
            switch (e.Command.Name)  
            {  
                case "Edit":  
                    Response.Redirect(_createPage + radDock.UniqueName);  
                    break;  
                case "Close":  
                    DataAccess.DeleteGadget(int.Parse(radDock.UniqueName));  
                    break;  
            }  
        }  
    }  
 
    protected void rdlGadgets_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 rdlGadgets_SaveDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        //Save the dock state. This will enable us  
        // to recreate the dock in the next Page_Init.  
        CurrentDockStates = rdlGadgets.GetRegisteredDocksState();  
    }  
 
    protected void btnAdd_Click(object sender, EventArgs e)  
    {  
        Response.Redirect(_createPage + "0");  
    }  
}  
 


Source for control
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Gadget.ascx.cs" Inherits="UserControls_Gadget" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<telerik:RadGrid ID="rgGadget" runat="server" Skin="Telerik" ShowHeader="true" AllowPaging="true" 
    ShowStatusBar="false" ShowFooter="False" AllowMultiRowSelection="False" GridLines="none" 
    AutoGenerateColumns="false">  
    <MasterTableView NoMasterRecordsText="No Records Found.">  
        <Columns> 
            <telerik:GridBoundColumn HeaderText="Date Created" DataField="DateCreated" UniqueName="DateCreated" 
                DataType="System.DateTime" /> 
            <telerik:GridBoundColumn HeaderText="Doc Title" DataField="DocTitle" UniqueName="DocTitle" 
                DataType="System.String" /> 
            <telerik:GridBoundColumn HeaderText="Doc Name" DataField="DocNme" UniqueName="DocNme" 
                DataType="System.String" /> 
        </Columns> 
    </MasterTableView> 
    <HeaderStyle Width="250px" /> 
    <ItemStyle Wrap="true" Width="100px" /> 
    <AlternatingItemStyle BackColor="#F0F4F7" /> 
    <ItemStyle BackColor="white" /> 
</telerik:RadGrid> 
<asp:Panel ID="pnlNavigation" runat="server">  
    <table width="100%">  
        <tr> 
            <td> 
                <asp:Button ID="btnFirst" runat="server" Text="<<" OnClick="btnFirst_Click" /></td>  
            <td> 
                <asp:Button ID="btnPrevious" runat="server" Text="<" OnClick="btnPrevious_Click" /></td>  
            <td> 
                <asp:Button ID="btnNext" runat="server" Text=">" OnClick="btnNext_Click" /></td>  
            <td> 
                <asp:Button ID="btnLast" runat="server" Text=">>" OnClick="btnLast_Click" /></td>  
        </tr> 
    </table> 
</asp:Panel> 

Code behind for control

using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using Telerik.Web.UI;  
 
public partial class UserControls_Gadget : System.Web.UI.UserControl  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
    }  
 
    public int DisplayRows  
    {  
        get { return (int)ViewState["DisplayRows"]; }  
        set { ViewState["DisplayRows"] = value; }  
    }  
 
    public string SearchCriteria  
    {  
        set 
        {  
            ViewState["SearchCriteria"] = value;  
            ViewState["PageNumber"] = 0;  
            Bind();  
        }  
    }  
 
    public void SetTriggers(UpdatePanel updatePanel)  
    {  
        RadScriptManager c = Page.Master.FindControl("ScriptManager1"as RadScriptManager;  
        c.RegisterAsyncPostBackControl(this.btnFirst);  
        c.RegisterAsyncPostBackControl(this.btnPrevious);  
        c.RegisterAsyncPostBackControl(this.btnNext);  
        c.RegisterAsyncPostBackControl(this.btnLast);  
 
        //set triggers for all buttons so they can postback  
        //AddButtonClickEventTrigger(updatePanel, this.btnFirst.UniqueID);  
        //AddButtonClickEventTrigger(updatePanel, this.btnPrevious.UniqueID);  
        //AddButtonClickEventTrigger(updatePanel, this.btnNext.UniqueID);  
        //AddButtonClickEventTrigger(updatePanel, this.btnLast.UniqueID);  
    }  
 
    private void Bind()  
    {  
        SearchEngineOutput searchEngine = SearchEngineFactory.GetSearchEngineData(ViewState["SearchCriteria"].ToString());  
        rgGadget.DataSource = searchEngine.Doc;  
        rgGadget.DataBind();  
 
        if (searchEngine.Summary.Rows.Count > 0)  
        {  
            SearchEngineOutput.SummaryRow row = (SearchEngineOutput.SummaryRow)searchEngine.Summary.Rows[0];  
            ViewState["NumFound"] = row.NumFound;  
            if ((int)ViewState["NumFound"] <= (int)ViewState["DisplayRows"])  //no paging necessary  
            {  
                pnlNavigation.Enabled = false;  
            }  
            else if ((int)ViewState["PageNumber"] == 0) //on first page  
            {  
                this.btnFirst.Enabled = false;  
                this.btnPrevious.Enabled = false;  
                this.btnNext.Enabled = true;  
                this.btnLast.Enabled = true;  
            }  
            else if (((int)ViewState["PageNumber"] + 1) * (int)ViewState["DisplayRows"] >= (int)ViewState["NumFound"]) //last page  
            {  
                this.btnFirst.Enabled = true;  
                this.btnPrevious.Enabled = true;  
                this.btnNext.Enabled = false;  
                this.btnLast.Enabled = false;  
            }  
            else 
            {  
                //in middle  
                this.btnFirst.Enabled = true;  
                this.btnPrevious.Enabled = true;  
                this.btnNext.Enabled = true;  
                this.btnLast.Enabled = true;  
            }  
        }  
        else 
        {  
            pnlNavigation.Enabled = false;  
        }  
    }  
    protected void btnFirst_Click(object sender, EventArgs e)  
    {  
        ViewState["PageNumber"] = 0;  
        Bind();  
    }  
    protected void btnPrevious_Click(object sender, EventArgs e)  
    {  
        ViewState["PageNumber"] = (int)ViewState["PageNumber"] - 1;  
        Bind();  
    }  
    protected void btnNext_Click(object sender, EventArgs e)  
    {  
        ViewState["PageNumber"] = (int)ViewState["PageNumber"] + 1;  
        Bind();  
    }  
    protected void btnLast_Click(object sender, EventArgs e)  
    {  
        if ((int)ViewState["DisplayRows"] > 0)  
        {  
            int lastPageNumber = (int)ViewState["NumFound"] / (int)ViewState["DisplayRows"];  
            int pageNumberRemainder = (int)ViewState["NumFound"] % (int)ViewState["DisplayRows"];  
            if (pageNumberRemainder > 0)  
                lastPageNumber++;  
            ViewState["PageNumber"] = lastPageNumber - 1;  
            Bind();  
        }  
    }  
    //public string FirstClientId  
    //{  
    //    get { return this.btnFirst.ClientID; }  
    //}  
    //public string PreviousClientId  
    //{  
    //    get { return this.btnPrevious.ClientID; }  
    //}  
    //public string NextClientId  
    //{  
    //    get { return this.btnNext.ClientID; }  
    //}  
    //public string LastClientId  
    //{  
    //    get { return this.btnLast.ClientID; }  
    //}  
 
    private void AddButtonClickEventTrigger(UpdatePanel updatePanel, string clientId)  
    {  
        AsyncPostBackTrigger clickTrigger = new AsyncPostBackTrigger();  
        clickTrigger.ControlID = clientId;  
        clickTrigger.EventName = "Click";  
        updatePanel.Triggers.Add(clickTrigger);  
    }  
}  
 
Pero
Telerik team
 answered on 01 Sep 2010
1 answer
400 views
Text area in Radgrid.

I like to put an text area in radrgid as GridBoundColumn.

 

Have multiple rows and a long width.

How I do that?

I found the following code below, but somehow even it nevers shows it in Edit or Insert mode to the code never got triggered. Please help.

 

protected void rgTask_ItemDataBound(object sender, GridItemEventArgs e)

 

{

 

// in insert mode

 

 

 

 

 

 

if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted))

 

{

 

GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;

 

 

TextBox txtbx = (TextBox)insertItem["Task_Detail"].Controls[0];

 

txtbx.MaxLength = 500;

txtbx.Width = 800;

txtbx.TextMode=

TextBoxMode.MultiLine;

 

 

}

 

//in edit mode

 

 

 

 

 

 

if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))

 

{

 

GridEditFormItem editItem = (GridEditFormItem)e.Item;

 

 

TextBox txtbx = (TextBox)editItem["Task_Detail"].Controls[0];

 

txtbx.MaxLength = 500;

txtbx.Width = 800;

txtbx.TextMode =

TextBoxMode.MultiLine;

 

 

}

 

 

}

Thanks!

Princy
Top achievements
Rank 2
 answered on 01 Sep 2010
1 answer
184 views
Hi,

I want to dynamically add/Remove  GridButtonColumn in a RadGrid. In a regular ASP.Net Grid I achieved this by setting  Grid1.AutoGenerateSelectButton = false OR Spreadsheet.AutoGenerateSelectButton = True;

I want to let the users select rows in a Grid only on certain occasions. How can I show / hide Select column in RadGrid? Can someone provide me  clues?

Thanks,
Prava
Princy
Top achievements
Rank 2
 answered on 01 Sep 2010
1 answer
115 views
I have a data bound Hierarchal multi-level TreeView.  Why doesn't it display in the order of the data that it is bound to?

The data comes from a database and I select and order the data as part of the data source.

Any Ideas?
Michael
Top achievements
Rank 1
 answered on 01 Sep 2010
2 answers
307 views
Hi,

I've found several examples of how to bind GridDropDownColumns to SQLDataSources and such, but not how to bind such column to an ordinary List or DataTable.
I know that I can use a GridTemplateColumn containing a dropdown-control and populate the control in the event handler of ItemDataBound, but a more direct approach where the column is bound to something in the grid's datasource would be a lot nicer.
Is this possible?

Thanks!
John Mann
Top achievements
Rank 1
 answered on 01 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?