Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
98 views
Hello,

I have been working with a Hierarchal RadGrid (Latest version), which has a parent and child level (only). I have AJAX enabled, and have an rebind() occurring on an interval defined by an <asp:Timer>. I have wrapped the Grid in a RadAjaxPanel, and the refreshes occur only to the panel when triggered by the Timer.

I believe I have this all setup properly, except that the Child's that are expanded do not persist between AJAX Refreshes triggered by the Timer Rebind(). Any suggestion would be appreciated. General code below:
protected void Timer1_Tick(object sender, EventArgs e)
{
    RadGrid1.Rebind();
}
 
private Hashtable _ordersExpandedState;
private Hashtable _selectedState;
 
 
public void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //reset states
        this._ordersExpandedState = null;
        this.Session["_ordersExpandedState"] = null;
        this._selectedState = null;
        this.Session["_selectedState"] = null;
    }
}
 
//Save/load expanded states Hash from the session
//this can also be implemented in the ViewState
private Hashtable ExpandedStates
{
    get
    {
        if (this._ordersExpandedState == null)
        {
            _ordersExpandedState = this.Session["_ordersExpandedState"] as Hashtable;
            if (_ordersExpandedState == null)
            {
                _ordersExpandedState = new Hashtable();
                this.Session["_ordersExpandedState"] = _ordersExpandedState;
            }
        }
 
        return this._ordersExpandedState;
    }
}
 
//Clear the state for all expanded children if a parent item is collapsed
private void ClearExpandedChildren(string parentHierarchicalIndex)
{
    string[] indexes = new string[this.ExpandedStates.Keys.Count];
    this.ExpandedStates.Keys.CopyTo(indexes, 0);
    foreach (string index in indexes)
    {
        //all indexes of child items
        if (index.StartsWith(parentHierarchicalIndex + "_") ||
            index.StartsWith(parentHierarchicalIndex + ":"))
        {
            this.ExpandedStates.Remove(index);
        }
    }
}
 
private void ClearSelectedChildren(string parentHierarchicalIndex)
{
    string[] indexes = new string[this.SelectedStates.Keys.Count];
    this.SelectedStates.Keys.CopyTo(indexes, 0);
    foreach (string index in indexes)
    {
        //all indexes of child items
        if (index.StartsWith(parentHierarchicalIndex + "_") ||
            index.StartsWith(parentHierarchicalIndex + ":"))
        {
            this.SelectedStates.Remove(index);
        }
    }
}
 
//Save/load selected states Hash from the session
//this can also be implemented in the ViewState
private Hashtable SelectedStates
{
    get
    {
        if (this._selectedState == null)
        {
            _selectedState = this.Session["_selectedState"] as Hashtable;
            if (_selectedState == null)
            {
                _selectedState = new Hashtable();
                this.Session["_selectedState"] = _selectedState;
            }
        }
 
        return this._selectedState;
    }
}
 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    //save the expanded/selected state in the session
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        //Is the item about to be expanded or collapsed
        if (!e.Item.Expanded)
        {
            //Save its unique index among all the items in the hierarchy
            this.ExpandedStates[e.Item.ItemIndexHierarchical] = true;
        }
        else //collapsed
        {
            this.ExpandedStates.Remove(e.Item.ItemIndexHierarchical);
            this.ClearSelectedChildren(e.Item.ItemIndexHierarchical);
            this.ClearExpandedChildren(e.Item.ItemIndexHierarchical);
        }
    }
    //Is the item about to be selected
    else if (e.CommandName == RadGrid.SelectCommandName)
    {
        //Save its unique index among all the items in the hierarchy
        this.SelectedStates[e.Item.ItemIndexHierarchical] = true;
    }
    //Is the item about to be deselected
    else if (e.CommandName == RadGrid.DeselectCommandName)
    {
        this.SelectedStates.Remove(e.Item.ItemIndexHierarchical);
    }
}
protected void RadGrid1_DataBound(object sender, EventArgs e)
{
    //Expand all items using our custom storage
    string[] indexes = new string[this.ExpandedStates.Keys.Count];
    this.ExpandedStates.Keys.CopyTo(indexes, 0);
 
    ArrayList arr = new ArrayList(indexes);
    //Sort so we can guarantee that a parent item is expanded before any of
    //its children
    arr.Sort();
 
    foreach (string key in arr)
    {
        bool value = (bool)this.ExpandedStates[key];
        if (value)
        {
            RadGrid1.Items[key].Expanded = true;
        }
    }
 
    //Select all items using our custom storage
    indexes = new string[this.SelectedStates.Keys.Count];
    this.SelectedStates.Keys.CopyTo(indexes, 0);
 
    arr = new ArrayList(indexes);
    //Sort to ensure that a parent item is selected before any of its children
    arr.Sort();
 
    foreach (string key in arr)
    {
        bool value = (bool)this.SelectedStates[key];
        if (value)
        {
            RadGrid1.Items[key].Selected = true;
        }
    }
}

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="scomx.PersistentTest.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register assembly="Telerik.Web.UI" Namespace="Telerik.Charting" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Timer ID="Timer1" runat="server" Interval="15000" OnTick="Timer1_Tick">
    </asp:Timer>
 
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            DefaultLoadingPanelID="RadAjaxLoadingPanel1"
            UpdateInitiatorPanelsOnly="True"
            UpdatePanelsRenderMode="Inline">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Timer1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"  />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
 
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" HorizontalAlign="NotSet" LoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"  Width="100%"
        OnNeedDataSource="List_DataSource"
        OnDetailTableDataBind="Details_DataSource"
        OnDataBound="RadGrid1_DataBound"
        OnItemDataBound="RadGrid1_ItemDataBound">
        <MasterTableView DataKeyNames="Name" Name="Parent">
            <Columns>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name">
                </telerik:GridBoundColumn>
            </Columns>
            <DetailTables>
                <telerik:GridTableView runat="server" HierarchyLoadMode="ServerOnDemand" AutoGenerateColumns="false" Name="DetailGrid">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Alert" DataField="Alert" UniqueName="Detail_Alert" ItemStyle-Width="375px"></telerik:GridBoundColumn>
                        <telerik:GridHyperLinkColumn HeaderText="View Details" DataNavigateUrlFields="Data" UniqueName="Detail_Data" NavigateUrl="http://{0}" Text="Click Here" Target="_blank"></telerik:GridHyperLinkColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
    </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    </div>
    </form>
</body>
</html>
Darryl
Top achievements
Rank 1
 answered on 08 May 2013
3 answers
244 views
Hi Telerik Guys !

I have been using the RAD MENU for a quite some while in my project.

Iam using the RADMENU in one of my project & this RADMENU is being populated dynamically .

Now what I need to do is to display the IMAGE(LOGO) along with the RAD MENU.

I dont know how to do it as I have not written any code in my ASPX page nor i have used any TEMPLATE.

Below is the code that I have used in order to dynammically bind the RADMENU:-

   <telerik:RadMenu ID="RadMenu1" Width="220px" runat="server" DataSourceID="ModulesSqlDataSource" 
                            DataTextField="MOD_DET_Name" DataValueField="MOD_DET_ID" Flow="Vertical" Font-Names="Trebuchet MS" 
                            Font-Size="15px" OnItemClick="RadMenu1_ItemClick" Skin="Web20">  
                        </telerik:RadMenu> 
                        <asp:SqlDataSource ID="ModulesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:demoDMSConnectionString %>" 
                            SelectCommand="Usp_Dms_GetModulesForDMSApplication" SelectCommandType="StoredProcedure">  
                        </asp:SqlDataSource> 
While , below is the Item Click event of the RADMENU:-

 protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)  
    {  
 
        if (e.Item.Text == "Document Management")  
        {  
            Response.Redirect("~/DocumentManagementSystem.aspx");  
        }  
 
        else if (e.Item.Text == "Folder Permissions")  
        {  
            Response.Redirect("~/FolderPermissions.aspx");  
        }  
 
        else if (e.Item.Text == "FTP Management")  
        {  
            Response.Redirect("~/FTPManagement.aspx");  
        }  
 
        else  
        {  
            Response.Redirect("~/RestoreDocuments.aspx");  
        }  
    }  
 
    
 While , my basic requirement is to display the RADMENU just like the image that I have attached.

Please help !!!

Ajay Jamwal
Kate
Telerik team
 answered on 08 May 2013
2 answers
387 views

I am new in using telerik rad Grid,I have requirement like this

Column1 | Column2

java | check Box

.Net | check Box

Python | check Box

Like this ,The above one is existing "Rad Grid" having two columns , I want to know In Column2 which check box is checked.,using the allowMultipleRowSelection="true"..,how to find that a particular Check box is checked or Not. Eg:- .Net Row checked Box is checked just assume

how to find that particular check-box of that .net Row,In

Insert And Update ,But it's inside of  other grid not an Independent grid. Parent Grid Insert Or Update I need to Find out that particular one.

please give reply...if any one Knows.



This Is Code....

           <telerik:RadGrid ID="RgList1" runat="server" AutoGenerateColumns="false" 
                        ShowHeader="false" Width="148px"  >
                        <MasterTableView AutoGenerateColumns="false" >
                        <Columns>
                            <telerik:GridTemplateColumn >
                            <ItemTemplate>
                            <%# Eval("BankTypeName")%>
                            </ItemTemplate>
                             </telerik:GridTemplateColumn>
                             <telerik:GridTemplateColumn UniqueName="chkBankList1">
                             <ItemTemplate>
                             <asp:CheckBox ID="chkBankTypeName" runat="server"  />
                             </ItemTemplate>

                            </Columns>
                        </MasterTableView>
              <ClientSettings  AllowColumnsReorder="true" EnableRowHoverStyle="true"   > 
             <Selecting AllowRowSelect="true"/>
             </ClientSettings>  
</telerik:RadGrid>

I want to find  the  whether check Box is checked or Not  in .aspx.cs file

See The Image You very  clear  idea About asked  the Question

Sairam
Top achievements
Rank 1
 answered on 08 May 2013
1 answer
106 views
We recently updated our Telerik version to the latest after being about a year behind the current version and are experiencing some very odd behavior. 

button events no longer fire from an .ascx page? The break points never get hit but clicking the button does start a post back where the page does reload. It's almost like the page reloads and then forgets why it originally reloaded and never hits the event?

Nothing has changed in our solution other than this telerik update so it's gotta be related to you guys. If it helps, it's wrapped inside of a radsplitter that I use for layout.

What might have changed that is causing this issue?
Thanks, 
Jason
Danail Vasilev
Telerik team
 answered on 08 May 2013
1 answer
144 views
(Hope this is the right forum ....)

How do I get the selected date using jQuery?
Jayesh Goyani
Top achievements
Rank 2
 answered on 08 May 2013
5 answers
124 views
     I have a Scenario using RadSlider with RadHTMLChart(Pie) in the Update Panel, in SharePoint 2010 Application Page. I added the RadSlider in ItemTemplate of RadListView control ,we have more than 50 RadSLider controls in the page. When the changes were made in the Slider, the HTMLChart also changed.

          When modifying the slider, I pass the value to RadHtmlchart on client side.The problem is when the page Refresh, the RadSLider and RadHTMLChart Controls are not displayed initially.
          It takes 15 seconds to show the Slider and RadHTMLChart controls after the page loads. The controls are taking time to load.

      I found that when using the minimum count for RadSLider control(2) , the radHtmlChart loads without delay. When increasing the RadSlider control count to 50, the RadHtml chart displays only after 15 seconds after the page load. It is happens only in IE browser.

         When i open the same page in Chrome and FireFox  the controls are shown within a second.


        Then I have changed  the RadSlider control property as "EnableServerSideRendering="true"". After changing this property, on page refresh the RadSLider controls displays without any delay. RadSlider works perfectly, but the RadHtmlChart produces the same delay to show the control,when referesh the page.

This issue happens only in IE browser.

Please provide any resolve methods to handle  this issue
Slav
Telerik team
 answered on 08 May 2013
3 answers
268 views

We recently upgraded our controls to the Q1 2013 SP2 assembly from 2011 0519. In making this change, we have noticed some significant changes to the way that some of the controls function.
• One of those issues is that the RadGrid control no longer accepts null or DBNull.Value in the DataFields. Changing the underlying data sets to return non-null values is not an immediate option for us since our solution is simply too large to identify all the places where that could be happening. We have been starting the process of re-working some of our pages to do this, but we have several hundred pages/user controls that need to be checked. In the meantime we need to find a work around to make the controls work similarly to the way they used to.
• The other issue is that the Visible=false property on a bound column is no longer maintaining ViewState properly. We know that we can change the Visible to Display and effectively get the old behavior, but there are many places where this was used.
We’ve been seeing other issues, but have not determined if they are due to a change in the Telerik controls or due to a recent upgrade to the latest jQuery library. Can you please at least help us to resolve these two issues?
Kindly let me know if you need any additional information.
Thanks.


Vasil
Telerik team
 answered on 08 May 2013
1 answer
107 views
Hi,

Attached is the code for Hierarchy RadGrid.

I always get error message "No child records to display."  though I have added below code:

protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        e.DetailTableView.DataSource = GetPlans();
    }

Attached is the code for your reference. Please help.
Jayesh Goyani
Top achievements
Rank 2
 answered on 08 May 2013
1 answer
88 views
Hi Telerik,

How can I create my own skin for RadControls? I need a step by step help guide.

Thanks,
Sameer
Shinu
Top achievements
Rank 2
 answered on 08 May 2013
4 answers
128 views
I have a radgrid in which I am using a custom edit form. When I do anything on the edit form I am getting the error in the screenshot attached to this post. Below is the code for my edit form control and code behind of the custom edit form control.

Custom Edit Form Control UI Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditSCAC.ascx.cs" Inherits="EditSCAC" %>
<telerik:RadAjaxManager ID="radAjaxMgr" runat="server" UpdatePanelsRenderMode="Inline">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="scacGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="scacTypeDDL" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div>
    <table id="scacEditTable">
        <tr>
            <td>
                <table>
                    <tr>
                        <td>
                            <asp:Label runat="server">SCAC:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scacTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC") %>'></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label runat="server">SCAC DESCRIPTION:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scacDescTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC_DESC") %>'></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label runat="server">SCAC PHONE:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="scaPhoneTB" runat="server"  Text='<%# DataBinder.Eval( Container, "DataItem.SCAC_PHONE") %>'></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label runat="server">SCAC TYPE:</asp:Label>
                        </td>
                        <td>
                            <telerik:RadComboBox ID="scacTypeDDL" AutoPostBack="True" runat="server" EmptyMessage="Please choose a type...">
                            </telerik:RadComboBox>
                        </td>
                        <td>
                            <asp:Label runat="server">CONTACT:</asp:Label>
                        </td>
                        <td>
                            <telerik:RadComboBox ID="contactDDL" AutoPostBack="True" runat="server" EmptyMessage="Please choose a contact...">
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is GridInsertionObject) %>'
                                CausesValidation="true" ValidationGroup="FormValidationGroup"></asp:Button>
                            <asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="PerformInsert"
                                Visible='<%# (DataItem is GridInsertionObject) %>' CausesValidation="true" ValidationGroup="FormValidationGroup">
                            </asp:Button>
                              
                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel"></asp:Button>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>


Custom Edit Form Control Code Behind:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using Telerik.Web.UI;
 
namespace IRRIS.Site.DTTS
{
    public partial class EditSCAC : System.Web.UI.UserControl
    {
        public object DataItem { get; set; }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            Populate_SCACDDL();
            Populate_ContactsDDL();
        }
 
        protected void Populate_SCACDDL()
        {
            var ds = new DataSet();
            var factory = new QueryFactory(new Configuration().DataConfigurationFile);
            var query = factory.GetQuery("P_GET_SCAC_TYPES");
            query.Fill(ds);
 
            var list = new List<string>();
            var dt = ds.Tables[0];
            list = (from dr in dt.AsEnumerable()
                    select dr.Field<string>("LUVALUE")).ToList<string>();
 
            scacTypeDDL.DataTextField = ds.Tables[0].Columns["LUDESCRIPTION"].ToString();
            scacTypeDDL.DataValueField = ds.Tables[0].Columns[1].ToString();
            scacTypeDDL.DataSource = ds.Tables[0];
 
            var scacTypeDdlValue = String.Empty;
             
            if (DataItem != null)
            {
                scacTypeDdlValue = DataBinder.Eval(DataItem, "SCAC_TYPE").ToString();
                if (!list.Contains(scacTypeDdlValue))
                {
                    scacTypeDDL.SelectedIndex = -1;
                }
                else
                {
                    scacTypeDDL.SelectedValue = scacTypeDdlValue;
                }
            }
        }
 
        protected void Populate_ContactsDDL()
        {
            var ds = new DataSet();
            var factory = new QueryFactory(new Configuration().DataConfigurationFile);
            var query = factory.GetQuery("P_GET_ALL_CONTACTS");
            query.Fill(ds);
 
            var list = new List<string>();
            var dt = ds.Tables[0];
            list = (from dr in dt.AsEnumerable()
                    select Convert.ToString(dr.Field<decimal>("CONTACT_ID"))).ToList<string>();
 
            contactDDL.DataTextField = ds.Tables[0].Columns["CONTACT_ORG"].ToString();
            contactDDL.DataValueField = ds.Tables[0].Columns[0].ToString();
            contactDDL.DataSource = ds.Tables[0];
 
            var contactDdlValue = String.Empty;
             
            if (DataItem != null)
            {
                contactDdlValue = DataBinder.Eval(DataItem, "SCAC_CONTACT_ID").ToString();
                if (!list.Contains(contactDdlValue))
                {
                    contactDDL.SelectedIndex = -1;
                }
                else
                {
                    contactDDL.SelectedValue = contactDdlValue;
                }
            }
        }
    }
}


Any ideas what could be causing this error?
Eyup
Telerik team
 answered on 08 May 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?