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

I am creating Radmenu and Radwindow dynamically in the page_load, i want to open the radwindow(dynamically created) on Rad Menu "OnClientItemClicked". When i do this i am getting "Microsoft JScript runtime error: Sys.InvalidOperationException: Two components with the same id 'RadWindow2' can't be added to the application." exception.
I am using Telerik Version=2010.2.929.20. In the view source of the page i dont see 2 Radwindows. I have only one Radwindow with ID'RadWindow2".

thanks,
srikanth

Shinu
Top achievements
Rank 2
 answered on 18 Nov 2010
1 answer
78 views
Hi all,

We are using Telerik Scheduler trial in one of our projects to test its abilities. Since the specification prompts to have a resources on the horizontal axis and time on the vertical axis we came across a problem. The number of resources is dynamic and we cannot predict how many resources (employees) the user will have. The scheduler could grow horizontally and look bad, have horizontal scroll and low usability. Our designers come with an idea to have a functionality like expand and shrink of a scheduler column. So, I was wondering if such functionality can be accomplished using your scheduler so we can interpret resources (columns) shrink and then allow users to expand them on demand.

I would appreciate your answer.

Thank you.
Nikolay Tsenkov
Telerik team
 answered on 18 Nov 2010
7 answers
227 views
Hi!

I have a self-referencing grid with custom CRUD operations (NeedDataSource and custom OnItemCommand events). It is made after this demo http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/selfreferencing/defaultcs.aspx and this article http://www.telerik.com/help/aspnet-ajax/grdselfreferencinghierarchy.html.

When i set the HierarchyDefaultExpanded to true, everything works fine, but I have a lot of data in my grid so I would like to collapse everything at the start. So, when I set the HierarchyDefaultExpanded to false, the grid is initially collapsed, but the edit form doesn't show on child items. The edit work only on the top level of the hierarchy.

This is my grid
<telerik:RadGrid ID="RG_MENU_MenuItem" runat="server"
                     DataSourceID="ods_MENU_MenuItem"
                     AutoGenerateColumns="false"
                     AllowSorting="false"
                     OnNeedDataSource="RG_MENU_MenuItem_NeedDataSource"
                     OnColumnCreated="RG_MENU_MenuItem_ColumnCreated"
                     OnItemDataBound="RG_MENU_MenuItem_ItemDataBound"
                     OnItemCreated="RG_MENU_MenuItem_ItemCreated"
                     OnItemCommand="RG_MENU_MenuItem_ItemCommand"
                     OnInsertCommand="RG_MENU_MenuItem_InsertCommand"
                     OnUpdateCommand="RG_MENU_MenuItem_UpdateCommand"
                     OnDeleteCommand="RG_MENU_MenuItem_DeleteCommand">
        <MasterTableView HierarchyDefaultExpanded="true"
                         HierarchyLoadMode="Client"
                         AllowSorting="false"
                         EditMode="PopUp"
                         DataKeyNames="MenuItemID, ParentItemID"
                         Width="100%">
            <SelfHierarchySettings ParentKeyName="ParentItemID" KeyName="MenuItemID" />
            <Columns>      
                <telerik:GridBoundColumn DataField="MenuItemID"
                                         HeaderText="ID"
                                         SortExpression="MenuItemID"
                                         UniqueName="MenuItemID"
                                         DataType="System.Int64"
                                         AllowFiltering="false"
                                         ReadOnly="true">
                    <HeaderStyle CssClass="rgHeader column0"/>
                    <ItemStyle CssClass="column0" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AppDescription"
                                         HeaderText="App Description"
                                         SortExpression="AppDescription"
                                         UniqueName="AppDescription"
                                         CurrentFilterFunction="Contains"
                                         AutoPostBackOnFilter="true">
                    <HeaderStyle CssClass="rgHeader column1"/>
                    <ItemStyle CssClass="column1" />
                </telerik:GridBoundColumn>              
                <telerik:GridTemplateColumn DataField="MenuInstanceID"
                                            HeaderText="Menu Instance"
                                            SortExpression="MenuInstanceID"
                                            UniqueName="MenuInstanceID">
                                            <FilterTemplate>
                                                <telerik:RadComboBox ID="rcbMenuInstanceFilter" runat="server"
                                                                     DataSourceID="ods_MenuInstance"
                                                                     DataTextField="AppDescription"
                                                                     DataValueField="MenuInstanceID"
                                                                     AllowCustomText="true"
                                                                     AppendDataBoundItems="true"
                                                                     Width="100"
                                                                     SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("MenuInstanceID").CurrentFilterValue %>'
                                                                     OnClientSelectedIndexChanged="rcbMenuInstanceFilter_SelectedIndexChanged">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="" Value="" />
                                                    </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="rsbMenuInstanceFilter" runat="server">
                                                    <script type="text/javascript">
                                                        function rcbMenuInstanceFilter_SelectedIndexChanged(sender, args) {
                                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            tableView.filter("MenuInstanceID", args.get_item().get_value(), "EqualTo");
                                                        }
                                                    </script>
                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
                                            <ItemTemplate>
                                                <%# Eval("MenuInstance.AppDescription")%>
                                            </ItemTemplate>
                    <HeaderStyle CssClass="rgHeader column2"/>
                    <ItemStyle CssClass="column2" />
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn DataField="PageID"
                                            HeaderText="Page"
                                            SortExpression="PageID"
                                            UniqueName="PageID">
                                            <FilterTemplate>
                                                <telerik:RadComboBox ID="rcbPageFilter" runat="server"
                                                                     DataSourceID="ods_Page"
                                                                     DataTextField="AppDescription"
                                                                     DataValueField="PageID"
                                                                     AllowCustomText="true"
                                                                     AppendDataBoundItems="true"
                                                                     Width="100"
                                                                     SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("PageID").CurrentFilterValue %>'
                                                                     OnClientSelectedIndexChanged="rcbPageFilter_SelectedIndexChanged">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="" Value="" />
                                                    </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="rsbPageFilter" runat="server">
                                                    <script type="text/javascript">
                                                        function rcbPageFilter_SelectedIndexChanged(sender, args) {
                                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            tableView.filter("PageID", args.get_item().get_value(), "EqualTo");
                                                        }
                                                    </script>
                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
                                            <ItemTemplate>
                                                <%# Eval("Page.AppDescription")%>
                                            </ItemTemplate>
                    <HeaderStyle CssClass="rgHeader column3"/>
                    <ItemStyle CssClass="column3" />
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="WebOrder"
                                         HeaderText="Web Order"
                                         SortExpression="WebOrder"
                                         UniqueName="WebOrder"
                                         DataType="System.Int32"
                                         FilterControlWidth="25px">
                    <HeaderStyle CssClass="rgHeader column5"/>
                    <ItemStyle CssClass="column5" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="IsActive"
                                         HeaderText="Is Active"
                                         SortExpression="IsActive"
                                         UniqueName="IsActive"
                                         DataType="System.Boolean">
                    <HeaderStyle CssClass="rgHeader column6"/>
                    <ItemStyle CssClass="column6" />
                </telerik:GridBoundColumn>         
                <telerik:GridBoundColumn DataField="TimeStamp"
                                         DataType="System.DateTime"
                                         HeaderText="Time Stamp"
                                         SortExpression="TimeStamp"
                                         UniqueName="TimeStamp"
                                         AllowFiltering="false">
                    <HeaderStyle CssClass="rgHeader column10"/>
                    <ItemStyle CssClass="column10" />
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn CommandName="CustomEdit"
                                          ButtonType="ImageButton"
                                          UniqueName="EditColumn"
                                          ImageUrl="~/_Med_App/images/edit.gif">
                    <HeaderStyle CssClass="rgHeader column11"/>
                    <ItemStyle CssClass="column11" />
                </telerik:GridButtonColumn>
                <telerik:GridButtonColumn ConfirmText="Jeste li sigurni da želite obrisati odabranu stavku?"
                                          CommandName="Delete"
                                          ButtonType="ImageButton"
                                          UniqueName="DeleteColumn">
                    <HeaderStyle CssClass="rgHeader column12"/>
                    <ItemStyle CssClass="column12" />
                </telerik:GridButtonColumn>
                <telerik:GridTemplateColumn UniqueName="SelectColumn"
                                            AllowFiltering="true"
                                            Display="false">
                                            <FilterTemplate>
                                                <asp:CheckBox ID="cbxSelectAllForSync" runat="server" AutoPostBack="true"
                                                              OnCheckedChanged="SelectAll_CheckedChanged" />                                               
                                            </FilterTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="cbxSelectForSync" runat="server" />
                                            </ItemTemplate>
                    <HeaderStyle CssClass="rgHeader column13"/>
                    <ItemStyle CssClass="column13" />
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings EditFormType="Template">
                <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
                <FormTemplate>
                    <table class="edit-table-rad" cellspacing="2" cellpadding="1" width="100%" border="0">
                        <tr>
                            <td align="left" width="200px">
                                <b>MenuItemID:</b>
                            </td>
                            <td>
                                <%# Eval("MenuItemID").ToString()%>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>ParentItem:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadComboBox ID="rcbParentItemID" runat="server"
                                                     DataSourceID="ods_MENU_ParentMenuItem"
                                                     DataTextField="AppDescription"
                                                     DataValueField="MenuItemID"
                                                     AppendDataBoundItems="true"
                                                     AllowCustomText="true"
                                                     Filter="StartsWith"
                                                     Width="350px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Menu Instance:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadComboBox ID="rcbMenuInstanceID" runat="server"
                                                     DataSourceID="ods_MenuInstance"
                                                     DataTextField="AppDescription"
                                                     DataValueField="MenuInstanceID"
                                                     AllowCustomText="true"
                                                     Width="350px">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="rfvMenuInstanceID" runat="server"
                                                            ControlToValidate="rcbMenuInstanceID"
                                                            ErrorMessage="Obavezan unos!"
                                                            ForeColor="Red">
                                </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Page:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadComboBox ID="rcbPageID" runat="server"
                                                     DataSourceID="ods_Page"
                                                     DataTextField="AppDescription"
                                                     DataValueField="PageID"
                                                     AppendDataBoundItems="True"
                                                     AllowCustomText="true"
                                                     Width="350px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Menu Item Url:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadTextBox ID="txtMenuItemUrl" runat="server" Width="350px"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>App Description:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadTextBox ID="txtAppDescription" runat="server" Width="350px"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Web Order:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadNumericTextBox ID="rnbWebOrder" runat="server" NumberFormat-DecimalDigits="0" Width="350px"/>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="rfvWebOrder" runat="server"
                                                            ControlToValidate="rnbWebOrder"
                                                            ErrorMessage="Obavezan unos!"
                                                            ForeColor="Red">
                                </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Is Active:</b>
                            </td>
                            <td width="350px">
                                <asp:CheckBox ID="chbIsActive" runat="server" Checked="false"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" width="200px">
                                <b>Priority Factor:</b>
                            </td>
                            <td width="350px">
                                <telerik:RadNumericTextBox ID="rnbPriorityFactor" runat="server" NumberFormat-DecimalDigits="0" Width="350px"/>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="rfvPriorityFactor" runat="server"
                                                            ControlToValidate="rnbPriorityFactor"
                                                            ErrorMessage="Obavezan unos!"
                                                            ForeColor="Red">
                                </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="InsertUpdateButton" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
                                <asp:Button ID="CancelButton" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings AllowExpandCollapse="true" />
    </telerik:RadGrid>

The code behind is: (omitted some code that is not relevant)
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using admin_bl;
using admin_bo;
using Telerik.Web.UI;
 
namespace admin
{
    public partial class MENU_MenuItem_Hierarchy : bl_BasePage
    {
        #region "Properties"
 
        private string _strAppMode = string.Empty;
        private Hashtable _htOdsValues;
 
        private bool _isRowFound = false;
        private long _lMenuInstanceIDFilter;
 
        #endregion
 
        #region "Page Load Methods"
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
                return;
 
            SetGridDisplay();
 
            SetInitialFilter();
        }
 
        public void Page_PreRenderComplete(object sender, EventArgs e)
        {
            HideExpandColumnRecursive(this.RG_MENU_MenuItem.MasterTableView);
        }
 
        /// <summary>
        /// Changes the grid display based on the ApplicationMode
        /// </summary>
        private void SetGridDisplay()
        {
            this._strAppMode = (Convert.ToInt32(bl_ApplicationData.AppMode)).ToString();
            this.txtAppMode.Text = this._strAppMode;
 
            if (bl_ApplicationData.AppMode == bl_ApplicationData.ApplicationMode.SYNCRONIZATION)
            {
                //disable insert, update & delete
                this.RG_MENU_MenuItem.AllowAutomaticInserts = false;
                this.RG_MENU_MenuItem.AllowAutomaticUpdates = false;
                this.RG_MENU_MenuItem.AllowAutomaticDeletes = false;
                //hide edit & delete columns and show select column
                this.RG_MENU_MenuItem.MasterTableView.GetColumn("EditColumn").Display = false;
                this.RG_MENU_MenuItem.MasterTableView.GetColumn("DeleteColumn").Display = false;
                this.RG_MENU_MenuItem.MasterTableView.GetColumn("SelectColumn").Display = true;
                //show buttons
                this.bDoSyncUP.Visible = true;
                this.bDoSyncDOWN.Visible = true;
                // confirm message
                this.bDoSyncUP.Attributes.Add("OnClick", "return confirm('Jeste li sigurni da želite pokrenuti sinkronizaciju? ');");
                this.bDoSyncDOWN.Attributes.Add("OnClick", "return confirm('Jeste li sigurni da želite pokrenuti sinkronizaciju? ');");
                //set sync legend colors and show it
                this.WUC_sync_legend1.bckColorInsert = bl_ApplicationData.BckColorInsert;
                this.WUC_sync_legend1.bckColorUpdate = bl_ApplicationData.BckColorUpdate;
                this.WUC_sync_legend1.bckColorDelete = bl_ApplicationData.BckColorDelete;
                this.WUC_sync_legend1.isSyncMode = true;
            }
            else if (bl_ApplicationData.AppMode == bl_ApplicationData.ApplicationMode.ADMINISTRATION)
            {
                this.RG_MENU_MenuItem.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
            }
        }
 
        private void SetInitialFilter()
        {
            this.RG_MENU_MenuItem.MasterTableView.FilterExpression = "(it.ParentItemID == 0)";
            //glavni menu initial filter
            this.rcbMenuInstanceFilter.SelectedValue = "8";
            SetMenuInstanceFilter("8");
        }
 
        #endregion
 
        #region "RadGrid Events"
 
        protected void RG_MENU_MenuItem_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            GetDataSource();
        }
 
        protected void RG_MENU_MenuItem_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column is GridExpandColumn)
            {
                e.Column.Visible = false;
            }
            else if (e.Column is GridBoundColumn)
            {
                e.Column.HeaderStyle.Width = Unit.Pixel(100);
            }
        }
 
        protected void RG_MENU_MenuItem_ItemDataBound(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "MenuItemID");
        }
 
        protected void RG_MENU_MenuItem_ItemCreated(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "MenuItemID");
 
            //e.Item.Expanded = false;
 
            if (e.Item is GridHeaderItem && e.Item.OwnerTableView != this.RG_MENU_MenuItem.MasterTableView)
            {
                e.Item.Style["display"] = "none";               
            }
 
            if (e.Item is GridNestedViewItem)
            {
                e.Item.Cells[0].Visible = false;               
            }           
 
            if (bl_ApplicationData.AppMode == bl_ApplicationData.ApplicationMode.ADMINISTRATION)
            {
                this.ItemCreatedAdmin(e);
            }
            else if (bl_ApplicationData.AppMode == bl_ApplicationData.ApplicationMode.SYNCRONIZATION)
            {
                this.ItemCreatedSync(e);
            }
        }
 
        protected void RG_MENU_MenuItem_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "CustomEdit")
            {
                EditRow(e);
            }
        }
 
        protected void RG_MENU_MenuItem_InsertCommand(object sender, GridCommandEventArgs e)
        {
            GetValues(e);
 
            Insert();
        }
 
        protected void RG_MENU_MenuItem_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GetValues(e);
 
            Update(e);
        }
 
        protected void RG_MENU_MenuItem_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            Delete(e);
        }
 
        public void SelectAll_CheckedChanged(object sender, EventArgs e)
        {
            this.RG_MENU_MenuItem.Rebind();
 
            foreach (GridDataItem item in this.RG_MENU_MenuItem.MasterTableView.Items)
            {
                (item.FindControl("cbxSelectForSync") as CheckBox).Checked = (sender as CheckBox).Checked;
            }
        }
 
        #endregion
 
        #region "Insert - Update - Delete"
 
        private void Insert()
        {
            string strMessage = String.Empty;
            bool isInserted = false;
 
            new bl_MENU_MenuItem().Insert(Convert.ToInt64(this._htOdsValues["ParentItemID"])
                                        , Convert.ToInt64(this._htOdsValues["MenuInstanceID"])
                                        , Convert.ToInt64(this._htOdsValues["PageID"])
                                        , this._htOdsValues["MenuItemUrl"].ToString()
                                        , this._htOdsValues["AppDescription"].ToString()
                                        , Convert.ToInt32(this._htOdsValues["WebOrder"])
                                        , Convert.ToBoolean(this._htOdsValues["IsActive"])
                                        , base.LoggedUser.UserID
                                        , Convert.ToInt32(this._htOdsValues["PriorityFactor"])
                                        , out isInserted
                                        , out strMessage);
 
            DisplayMessage(!isInserted, strMessage);
        }
 
        private void Update(GridCommandEventArgs e)
        {
            string strMessage = String.Empty;
            bool isUpdated = false;
 
            long lMenuItemID = Convert.ToInt64((e.Item as GridEditableItem).GetDataKeyValue("MenuItemID"));
 
            new bl_MENU_MenuItem().Update(lMenuItemID
                                        , Convert.ToInt64(this._htOdsValues["ParentItemID"])
                                        , Convert.ToInt64(this._htOdsValues["MenuInstanceID"])
                                        , Convert.ToInt64(this._htOdsValues["PageID"])
                                        , this._htOdsValues["MenuItemUrl"].ToString()
                                        , this._htOdsValues["AppDescription"].ToString()
                                        , Convert.ToInt32(this._htOdsValues["WebOrder"])
                                        , Convert.ToBoolean(this._htOdsValues["IsActive"])
                                        , base.LoggedUser.UserID
                                        , Convert.ToInt32(this._htOdsValues["PriorityFactor"])
                                        , out isUpdated
                                        , out strMessage);
 
            DisplayMessage(!isUpdated, strMessage);
        }
 
        private void Delete(GridCommandEventArgs e)
        {
            string strMessage = String.Empty;
            bool isDeleted = false;
 
            long lMenuItemID = Convert.ToInt64((e.Item as GridEditableItem).GetDataKeyValue("MenuItemID"));
 
            new bl_MENU_MenuItem().Delete(lMenuItemID
                                        , out isDeleted
                                        , out strMessage);
 
            DisplayMessage(!isDeleted, strMessage);
        }
 
        #endregion
 
        #region "ObjectDataSource Events"
 
        protected void ods_MENU_MenuItem_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {
            SetOdsValues(e);
        }
 
        protected void ods_MENU_MenuItem_Updating(object sender, ObjectDataSourceMethodEventArgs e)
        {
            SetOdsValues(e);
        }
 
        protected void ods_MENU_MenuItem_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
        {
 
        }
 
        protected void ods_MENU_MenuItem_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            DisplayMessage(!Convert.ToBoolean(e.OutputParameters["pIsInserted"]), Convert.ToString(e.OutputParameters["pMessage"]));
        }
 
        protected void ods_MENU_MenuItem_Updated(object sender, ObjectDataSourceStatusEventArgs e)
        {
            DisplayMessage(!Convert.ToBoolean(e.OutputParameters["pIsUpdated"]), Convert.ToString(e.OutputParameters["pMessage"]));
        }
 
        protected void ods_MENU_MenuItem_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            DisplayMessage(!Convert.ToBoolean(e.OutputParameters["pIsDeleted"]), Convert.ToString(e.OutputParameters["pMessage"]));
        }
 
        #endregion
 
        #region "Other Events"
 
        protected void button_Click(object sender, EventArgs e)
        {
            ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand";
        }
 
        protected void rcbMenuInstanceFilter_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            SetMenuInstanceFilter(e.Value);
        }
 
        #endregion
 
        #region "Utility Methods"
 
        public void GetDataSource()
        {
            RG_MENU_MenuItem.DataSource = new bl_MENU_MenuItem().GetAll( this.txtSortExpression.Text
                                                                       , Convert.ToBoolean(this.txtSortDirection.Text)
                                                                       , this.txtAppMode.Text);
        }
 
        public void HideExpandColumnRecursive(GridTableView pTableView)
        {
            GridItem[] nestedViewItems = pTableView.GetItems(GridItemType.NestedView);
            foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
            {
                foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                {
                    nestedView.Style["border"] = "0";
 
                    Button btnExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("btnExpandCollapseButton");
                    if (nestedView.Items.Count == 0)
                    {
                        if (btnExpandCollapseButton != null)
                        {
                            btnExpandCollapseButton.Style["visibility"] = "hidden";
                        }
                        nestedViewItem.Visible = false;
                    }
                    else
                    {
                        if (btnExpandCollapseButton != null)
                        {
                            btnExpandCollapseButton.Style.Remove("visibility");
                        }
                    }
 
                    if (nestedView.HasDetailTables)
                    {
                        HideExpandColumnRecursive(nestedView);
                    }
                }
            }
        }
 
        public void CreateExpandCollapseButton(GridItem pItem, string pColumnUniqueName)
        {
            if (pItem is GridDataItem)
            {
                if (pItem.FindControl("btnExpandCollapseButton") == null)
                {
                    Button button = new Button();
                    button.Click += new EventHandler(button_Click);
                    button.CommandName = "ExpandCollapse";
                    button.CssClass = (pItem.Expanded) ? "rgCollapse" : "rgExpand";
                    button.ID = "btnExpandCollapseButton";
 
                    if (pItem.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
                    {
                        string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", pItem.Parent.Parent.ClientID);
 
                        button.OnClientClick = script;
                    }
 
                    int level = pItem.ItemIndexHierarchical.Split(':').Length - 1;
 
                    button.Style["margin-left"] = level * 15 + "px";
 
                    TableCell cell = ((GridDataItem)pItem)[pColumnUniqueName];
                    cell.Controls.Add(button);
                    cell.Controls.Add(new LiteralControl(" "));
                    cell.Controls.Add(new LiteralControl(((GridDataItem)pItem).GetDataKeyValue(pColumnUniqueName).ToString()));
                }
            }
        }
 
        private void DisplayMessage(bool pIsError, string pText)
        {
            if (pIsError == true)
            {
                this.lblActionNotOk.Visible = true;
                this.lblActionNotOk.Text = pText;
                this.lblActionOk.Visible = false;
            }
            else
            {
                this.lblActionOk.Visible = true;
                this.lblActionOk.Text = pText;
                this.lblActionNotOk.Visible = false;
            }
        }
 
        private void ItemCreatedAdmin(GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditFormItem geiEditedItem = e.Item as GridEditFormItem;
                geiEditedItem.Visible = true;
 
                if (e.Item.DataItem is bo_MENU_MenuItem)
                {
                    bo_MENU_MenuItem boCurrent = (bo_MENU_MenuItem)e.Item.DataItem;
 
                    RadComboBox rcbParentItemID = geiEditedItem.FindControl("rcbParentItemID") as RadComboBox;
                    rcbParentItemID.SelectedValue = boCurrent.ParentItemID != 0 ? boCurrent.ParentItemID.ToString() : "";
 
                    RadComboBox rcbMenuInstanceID = geiEditedItem.FindControl("rcbMenuInstanceID") as RadComboBox;
                    rcbMenuInstanceID.SelectedValue = boCurrent.MenuInstance.MenuInstanceID.ToString();
 
                    RadComboBox rcbPageID = geiEditedItem.FindControl("rcbPageID") as RadComboBox;
                    rcbPageID.SelectedValue = boCurrent.Page.PageID != 0 ? boCurrent.Page.PageID.ToString() : String.Empty;
 
                    RadTextBox txtMenuItemUrl = geiEditedItem.FindControl("txtMenuItemUrl") as RadTextBox;
                    txtMenuItemUrl.Text = boCurrent.MenuItemUrl.ToString();
 
                    RadTextBox txtAppDescription = geiEditedItem.FindControl("txtAppDescription") as RadTextBox;
                    txtAppDescription.Text = boCurrent.AppDescription.ToString();
 
                    RadNumericTextBox rnbWebOrder = geiEditedItem.FindControl("rnbWebOrder") as RadNumericTextBox;
                    rnbWebOrder.Text = boCurrent.WebOrder.ToString();
 
                    CheckBox chbIsActive = geiEditedItem.FindControl("chbIsActive") as CheckBox;
                    chbIsActive.Checked = boCurrent.IsActive;
 
                    RadNumericTextBox rnbPriorityFactor = geiEditedItem.FindControl("rnbPriorityFactor") as RadNumericTextBox;
                    rnbPriorityFactor.Text = boCurrent.PriorityFactor.ToString();
                }
            }
        }
 
        private void ItemCreatedSync(GridItemEventArgs e)
        {
             
        }
 
        private void GetValues(GridCommandEventArgs e)
        {
            this._htOdsValues = new Hashtable();
            this._htOdsValues.Add("ParentItemID", Convert.ToInt64(((e.Item as GridEditableItem).FindControl("rcbParentItemID") as RadComboBox).SelectedValue != String.Empty ? ((e.Item as GridEditableItem).FindControl("rcbParentItemID") as RadComboBox).SelectedValue : "0"));
            this._htOdsValues.Add("MenuInstanceID", Convert.ToInt64(((e.Item as GridEditableItem).FindControl("rcbMenuInstanceID") as RadComboBox).SelectedValue));
            this._htOdsValues.Add("PageID", Convert.ToInt64(((e.Item as GridEditableItem).FindControl("rcbPageID") as RadComboBox).SelectedValue != String.Empty ? ((e.Item as GridEditableItem).FindControl("rcbPageID") as RadComboBox).SelectedValue : "0"));
            this._htOdsValues.Add("MenuItemUrl", ((e.Item as GridEditableItem).FindControl("txtMenuItemUrl") as RadTextBox).Text);
            this._htOdsValues.Add("AppDescription", ((e.Item as GridEditableItem).FindControl("txtAppDescription") as RadTextBox).Text);
            this._htOdsValues.Add("WebOrder", Convert.ToInt32(((e.Item as GridEditableItem).FindControl("rnbWebOrder") as RadNumericTextBox).Text));
            this._htOdsValues.Add("IsActive", ((e.Item as GridEditableItem).FindControl("chbIsActive") as CheckBox).Checked);
            this._htOdsValues.Add("PriorityFactor", Convert.ToInt32(((e.Item as GridEditableItem).FindControl("rnbPriorityFactor") as RadNumericTextBox).Text));
        }
 
        private void SetOdsValues(ObjectDataSourceMethodEventArgs e)
        {
            e.InputParameters["ParentItemID"] = this._htOdsValues["ParentItemID"];
            e.InputParameters["MenuInstanceID"] = this._htOdsValues["MenuInstanceID"];
            e.InputParameters["PageID"] = this._htOdsValues["PageID"];
            e.InputParameters["MenuItemUrl"] = this._htOdsValues["MenuItemUrl"];
            e.InputParameters["AppDescription"] = this._htOdsValues["AppDescription"];
            e.InputParameters["WebOrder"] = this._htOdsValues["WebOrder"];
            e.InputParameters["IsActive"] = this._htOdsValues["IsActive"];
            e.InputParameters["UserID"] = base.LoggedUser.UserID;
            e.InputParameters["PriorityFactor"] = this._htOdsValues["PriorityFactor"];
        }
 
        private void EditRow(GridCommandEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem gdiItem = (GridDataItem)e.Item;
                long lMenuItemID = Convert.ToInt64(gdiItem.GetDataKeyValue("MenuItemID"));
                this._isRowFound = false;
 
                if (this.RG_MENU_MenuItem.MasterTableView.FindItemByKeyValue("MenuItemID", lMenuItemID) != null)
                    this.RG_MENU_MenuItem.MasterTableView.FindItemByKeyValue("MenuItemID", lMenuItemID).Edit = true;
                else
                    EditRowRecursive(this.RG_MENU_MenuItem.MasterTableView, lMenuItemID);
 
                this.RG_MENU_MenuItem.Rebind();
            }
        }
 
        private void EditRowRecursive(GridTableView pTableView, long pMenuItemID)
        {
            GridItem[] nestedViewItems = pTableView.GetItems(GridItemType.NestedView);
            foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
            {
                if (this._isRowFound)
                    return;
 
                foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                {
                    if (nestedView.FindItemByKeyValue("MenuItemID", pMenuItemID) != null)
                    {
                        nestedView.FindItemByKeyValue("MenuItemID", pMenuItemID).Edit = true;
                        this._isRowFound = true;
                        return;
                    }
 
                    if (nestedView.HasDetailTables)
                    {
                        EditRowRecursive(nestedView, pMenuItemID);
                    }
                }               
            }
        }
 
        private void SetMenuInstanceFilter(string pMenuInstanceID)
        {
            this._lMenuInstanceIDFilter = Convert.ToInt64(pMenuInstanceID.Equals(String.Empty) ? "0" : pMenuInstanceID);
 
            this.locTitle.Text = "UreÄ‘ivanje Stavki Menua";
            this.RG_MENU_MenuItem.MasterTableView.FilterExpression = "(it.ParentItemID == 0)";
 
            this.txtMenuInstanceID.Text = this._lMenuInstanceIDFilter.ToString();
 
            GridColumn gdcMenuInstanceID = this.RG_MENU_MenuItem.MasterTableView.GetColumnSafe("MenuInstanceID");
 
            if (this._lMenuInstanceIDFilter == 0)
            {
                gdcMenuInstanceID.CurrentFilterFunction = GridKnownFunction.NoFilter;
                gdcMenuInstanceID.CurrentFilterValue = String.Empty;
            }
            else
            {
                this.locTitle.Text += " za MenuInstanceID = " + this.txtMenuInstanceID.Text;
                this.RG_MENU_MenuItem.MasterTableView.FilterExpression += " AND (it.MenuInstanceID == " + this.txtMenuInstanceID.Text + ")";
 
                gdcMenuInstanceID.CurrentFilterFunction = GridKnownFunction.EqualTo;
                gdcMenuInstanceID.CurrentFilterValue = this.txtMenuInstanceID.Text;
            }
 
            this.RG_MENU_MenuItem.MasterTableView.Rebind();
        }
 
        #endregion
 
        #endregion
    }
}

Please help me to have my self-referencing grid initially collapsed and with working edit forms.
Tsvetina
Telerik team
 answered on 18 Nov 2010
2 answers
123 views
Hi,
  Personally, I love radScheduler and I love how it performs in FF, but my clients like IE and radScheduler just don't have good performance in IE.
  I already checked the suggestion in http://www.telerik.com/products/aspnet-ajax/resources/top-performance.aspx, but it's not helping much.  We don't use web or WCF web service binding.  Is there anything else we can do to improve the performance in IE? 
T. Tsonev
Telerik team
 answered on 18 Nov 2010
1 answer
111 views
Hello guys. I'm attempting to tackle a situation where, in the database, there are three columns in a table called JobDate, StartTime, and EndTime. StartTime and EndTime are also stored as a smalldatetime like JobDate. Also, the date portion of StartTime and EndTime is equal to JobDate.

Now, upon clicking the Edit Icon, I see the results as shown in "step-01". Although the values are correct, it still shows up as incorrect. Upon clicking either of the two field while in edit mode, the results achieved are shown in "step-02".

I don't want to show the date portion while editing StartTime and EndTime. This because the date portion will be same as JobDate and a JobDate cannot be changed. Not even by an accident.

Kindly help.

<telerik:RadGrid ID="RadGridJobs" runat="server" AutoGenerateColumns="False" AllowPaging="True" PageSize="25" AllowSorting="false" GridLines="None" Width="885px" Skin="Office2007" SkinID="RadGrid_UnPageable" OnNeedDataSource="RadGridJobs_NeedDataSource" OnUpdateCommand="RadGridJobs_UpdateCommand" OnDeleteCommand="RadGridJobs_DeleteCommand" OnItemCreated="RadGridJobs_ItemCreated">
<MasterTableView ClientDataKeyNames="OID" DataKeyNames="OID" CommandItemDisplay="Top">
  <Columns>
    <telerik:GridBoundColumn DataField="PharmacyName" HeaderText="Pharmacy" ReadOnly="True" SortExpression="PharmacyName"
      UniqueName="columnPharmacy" />
    <telerik:GridBoundColumn DataField="CoordinatorName" HeaderText="Coordinator" ReadOnly="true" SortExpression="CoordinatorName"
      UniqueName="columnCoordinator" />
    <telerik:GridBoundColumn DataField="JobDate" HeaderText="Date" ReadOnly="true" SortExpression="JobDate"
      UniqueName="columnDate" DataType="System.DateTime" DataFormatString="{0:dd-MMM-yyyy}" />
    <telerik:GridBoundColumn DataField="StartTime" HeaderText="Start" UniqueName="columnStart" DataType="System.DateTime"
      DataFormatString="{0:hh:mm tt}" />
    <telerik:GridBoundColumn DataField="EndTime" HeaderText="End" UniqueName="columnEnd" DataType="System.DateTime"
      DataFormatString="{0:hh:mm tt}" />
    <telerik:GridBoundColumn DataField="Rate" HeaderText="Rate" UniqueName="columnRate" DataType="System.Decimal"
      DataFormatString="{0:c}" />
    <telerik:GridBoundColumn DataField="RatePlus" HeaderText="Rate +" UniqueName="columnRatePlus" DataType="System.Decimal"
      DataFormatString="{0:c}" />
    <telerik:GridEditCommandColumn ButtonType="ImageButton" />
    <telerik:GridButtonColumn ConfirmText="Delete this Job?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete"
      ButtonType="ImageButton" CommandName="Delete" />
    <telerik:GridTemplateColumn HeaderText="" UniqueName="NoteColumn" HeaderStyle-Width="10px" ItemStyle-Width="10px">
      <ItemTemplate>
    <a href="../Notes/NotesManager.aspx?RecordID=<%# Eval("OID") %>&NoteTypeID=3">
      <asp:Image ID="ImageEditNote" runat="server" ImageUrl="~/Images/notes-icon.gif" AlternateText="Add notes"
        Width="15px" ToolTip="Add notes" />
    </a>
      </ItemTemplate>
      <HeaderStyle Width="10px"></HeaderStyle>
      <ItemStyle Width="10px"></ItemStyle>
    </telerik:GridTemplateColumn>
  </Columns>
  <EditFormSettings>
    <EditColumn ButtonType="ImageButton" />
  </EditFormSettings>
  <CommandItemSettings ShowRefreshButton="true" ShowAddNewRecordButton="false" ShowExportToWordButton="false"
    ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToCsvButton="true" />
  <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="TopAndBottom" />
</MasterTableView>
<ExportSettings HideStructureColumns="false" />
<ClientSettings>
  <Selecting AllowRowSelect="True" />
  <ClientEvents OnRowDblClick="RadGridJobs_OnRowDblClick" />
  <Scrolling UseStaticHeaders="True" />
</ClientSettings>
</telerik:RadGrid>
 
<telerik:RadInputManager runat="server" ID="RadInputManagerJobs" Enabled="true">
  <telerik:DateInputSetting BehaviorID="DateInputSettingStartEnd" DateFormat="hh:mm:ss tt"  DisplayDateFormat="hh:mm tt" EmptyMessage="Cannot be empty" ErrorMessage="Enter valid time" />
  <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSettingRate" Type="Currency" AllowRounding="true" DecimalDigits="2" MinValue="0" EmptyMessage="Cannot be empty" ErrorMessage="Enter valid currency" />
</telerik:RadInputManager>
Veli
Telerik team
 answered on 18 Nov 2010
6 answers
1.2K+ views
Hello,

I am in the process of building a control that registers some javascript after each postback (regular or ajax).  This is done in the PreRender event of the control and looks something like this:

ScriptManager.RegisterStartupScript(thisthis.GetType(), this.ClientID + "_SplitterBarStartupScript", sb.ToString(), true);  
 

This works fine both when using no Ajax panel at all and also when using the ASP.NET UpdatePanel.  After each postback the script is injected correctly and runs.  This doesn't work with the RadAjaxPanel though.

I did some testing and found that RegisterClientScriptBlock does fire with the RadAjaxPanel after each postback.  I do not want to use this however because the script is injected before the elements have been loaded (too early).

I have also seen suggestions on the forum to use the RadAjaxPanel's ClientScripts collection.  This will also not work for me because this is a custom control and doesn't know what other controls are included on the page.

I would like this to work in all 3 scenarios: regular postback, ASP.NET UpdatePanel and RadAjaxPanel.

Please advise as to how I should proceed.

Thanks,
Kevin
sahil
Top achievements
Rank 1
 answered on 18 Nov 2010
1 answer
54 views
Hi - I have a rotator with some text in it. The text needs to be bold. It looks fine in other browsers but after the first scroll, IE renders the text really badly - almost unreadable.

Any ideas why and how to fix it?
Fiko
Telerik team
 answered on 18 Nov 2010
4 answers
120 views
I'm looking for Grid-Like behaviour and functionality on the client side. I want an easy way to extract data values from a tree list data item, similar to the way you do it in a grid:

var treeList = $find("<%= treeList.ClientID %>");
var item = treeList.get_selectedItems()[0];
var selectedID = item.getDataKeyValues("someDatabaseID");

It would be great if we could bind client data keys to the tree list without declaring them as columns (just like on a radgrid).
Nikolay Rusev
Telerik team
 answered on 18 Nov 2010
1 answer
83 views
I assume this is something stupid I've missed but I'm missing it.  In my local development machine (Running the VS Dev Web Server) the upload control looks great, see localdev.png.  But when I push the project out to my production server that is IIS7 on Windows 2008, it's like it can't render the CSS.  See prodIIs7.png attached.

There is a script error in the browser (IE7):
URI: http://domain.com/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=scriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3afab31106-1bd6-4491-9a14-59e0fc4a7081%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.1.519.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3afcd44c12-f50d-4937-b05d-1aa46b5c5b3e%3a16e4e7cd%3a86526ba7%3a68f76a79%3af7645509%3a24ee1bba%3aa585d0d4%3a874f8ea2%3a2a2fc429

Message: 'Sys' is undefined

Any ideas?
Yana
Telerik team
 answered on 18 Nov 2010
3 answers
162 views
I have a tabstrip whose name is highlighted below. When I try and get the selected tab I'm on, the value comes back null. I know I am on a tab, because that is where the data entry is taking place. The selectedTab variable is supposed to be coming back with a value.

What am I doing wrong?

html
------------
<telerik:RadTabStrip ID="tsCoding" runat="server" Align="Left" MultiPageID="RadMultiPage1"
                                                                                    OnClientTabSelected="tsCoding_OnClientTabSelected" AutoPostBack="false" CausesValidation="false"
                                                                                    ScrollButtonsPosition="Right" BackColor="Gray">

<Tabs>
                                                                                        <telerik:RadTab Text="<u>C</u>hart" AccessKey="C" PageViewID="pvChart">
                                                                                        </telerik:RadTab>
                                                                                        <telerik:RadTab runat="server" id="tbEMTool" Text="E/M <u>T</u>ool" AccessKey="T"
                                                                                            PageViewID="pvTreatMent" Enabled="false">
                                                                                            <Tabs>
                                                                                                <telerik:RadTab Text="Treatme<u>n</u>t" AccessKey="N" PageViewID="pvTreatMent" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="Comple<u>x</u>ity" AccessKey="X" PageViewID="pvComplexity"
                                                                                                    Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="<u>R</u>esult" AccessKey="R" PageViewID="pvResult" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="<u>H</u>istory" AccessKey="H" PageViewID="pvHistory" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="<u>E</u>xam" AccessKey="E" PageViewID="pvExam" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="<u>S</u>ummary" AccessKey="S" PageViewID="pvSummary" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                            </Tabs>
                                                                                        </telerik:RadTab>
                                                                                        <telerik:RadTab Text="P<u>Q</u>RI" AccessKey="Q" id="tbPQRI" Enabled="false">
                                                                                            <Tabs>
                                                                                                <telerik:RadTab Text="<u>A</u>cute MI" AccessKey="A" PageViewID="pvAcuteMI" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="Chest <u>P</u>ain" AccessKey="P" PageViewID="pvChestPain" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="S<u>y</u>ncope" AccessKey="Y" PageViewID="pvSyncopy" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                                <telerik:RadTab Text="Pne<u>u</u>monia" AccessKey="U" PageViewID="pvPneumonia" Enabled="false">
                                                                                                </telerik:RadTab>
                                                                                            </Tabs>
                                                                                        </telerik:RadTab>
                                                                                    </Tabs>
                                                                                </telerik:RadTabStrip>


js
--

 

var tsCoding = $find("<%= tsCoding.ClientID %>");

 

 

var selectedTab = tsCoding.get_selectedTab();

 

 

if (selectedTab != null) {

 

Yana
Telerik team
 answered on 18 Nov 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?