Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
149 views
My situation :
My Web Page has many Tab (dynamic tabs) and 1 RadGrid (grid).  When I changed position tab, grid auto generate dynamic columns.
(I must set property grid.MasterTableView.EnableViewState = false to create dynamic columns). But I can't keep settings of gird when changed to another page and move back

My code :
<code>
private int tabIndex = 0;       // variable to define tab is selected
protected void Page_Init(....)
{
          if(! string.IsNullOrEmpty(Request.QueryString["tabIndex"] )
          {
                    tabIndex = Convert.ToInt32(Request.QueryString["tabIndex"]);
          }
          else
                   tabIndex = 0;
         
          // This method create grid corresponding tab is selected
          CreateGrid(tabIndex);
}

protected void OnUnload(....)
{
       GridPersistSetting gridSetting = new GridPersistSetting (grid);
       Session["grid" + tabIndex] = gridSetting.SaveSettings();
}

protected voi Page_Load(....)
{
        if (!IsPostBack)
        {
                  ....................
                  if(Session["grid" + tablndex] !=null)
                  {
                              GridPersistSetting gridSetting = new GridPersistSetting (grid);
                              gridSetting.LoadSettings(Session["grid" + tabIndex].ToString());
                  }
        }
}

protected void Tab_Click(...)
{
         Response.Redirect("Demo.aspx?tabIndex = " + e.tabIndex)
}
</code>

I do same as your example (gridSetting.LoadSettings() in Page_Init() and and gridSetting.SaveSettings in Render()) but it not success so I must changed as above (on PageLoad and UnLoad)
Can you give me a solution ?
Thanks you.
ysea
Top achievements
Rank 1
 answered on 23 Dec 2009
4 answers
283 views

When a GridDateTimeColumn is bound to a nested object (e.g. DataField="SomeObject.DateField"), column sorting is broken. The sorting appears to be based on the alphanumeric order. Here is the test code below with a workaround and a workaround attempt that causes an exception:

default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <div> 
            <telerik:RadGrid AllowSorting="true" AllowPaging="true" PageSize="25" ID="RadGrid1" runat="server"   
                OnNeedDataSource="RadGrid1_NeedDataSource">  
                <MasterTableView AutoGenerateColumns="false">  
                    <Columns> 
                        <telerik:GridDateTimeColumn   
                            DataFormatString="{0:MM/dd/yyyy}" 
                            DataField="RefDate"   
                            UniqueName="Column0"   
                            HeaderText="ParentObj">  
                        </telerik:GridDateTimeColumn> 
                        <telerik:GridDateTimeColumn   
                            DataFormatString="{0:MM/dd/yyyy}" 
                            DataField="Dobj.RefDate1"   
                            UniqueName="Column1"   
                            HeaderText="ChildObj">  
                        </telerik:GridDateTimeColumn> 
                        <telerik:GridTemplateColumn  
                            SortExpression='Dobj.RefDate1.ToString("s")' 
                            UniqueName="Column2"   
                            HeaderText="WorkAround1">  
                            <ItemTemplate> 
                                <asp:Label ID="Label1" runat="server"   
                                    Text='<%# String.Format("{0:MM/dd/yyyy}", Eval("Dobj.RefDate1")) %>' 
                                > 
                                </asp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridDateTimeColumn  
                            SortExpression='Dobj.RefDate2.ToString("s")' 
                            DataFormatString="{0:MM/dd/yyyy}" 
                            DataField="Dobj.RefDate2"   
                            UniqueName="Column3"   
                            HeaderText="WorkAround2">  
                        </telerik:GridDateTimeColumn>                    
                    </Columns> 
                </MasterTableView> 
            </telerik:RadGrid> 
        </div> 
    </form> 
</body> 
</html> 
 

default.aspx.cs:

using System;  
using System.Data;  
using System.Configuration;  
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 System.Collections.Generic;  
 
public partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
    {  
        RadGrid1.DataSource = GetDataList();  
    }  
 
    protected List<PObject> GetDataList()  
    {  
        DateTime refdt = new DateTime(2008, 12, 20);  
        var dlist = new List<PObject>();  
        for (int i = 1; i < 20; i++)  
        {  
           var dt = refdt.AddDays(i);  
           dlist.Add(   
                        new PObject   
                        {  
                            Dobj = new DObject { RefDate1 = dt, RefDate2 = dt },  
                            RefDate = dt  
                        }  
                    );  
        }  
        return dlist;  
    }  
}  
 
public class PObject  
{  
    public DObject Dobj { get; set; }  
    public DateTime RefDate { get; set; }  
}  
 
public class DObject  
{  
    public DateTime RefDate1 { get; set; }  
    public DateTime RefDate2 { get; set; }  
} 

You will notice that the first column "ParentObj" sorts fine since the bound property is part of the data object. The second column "ChildObj" is bound to a nested/child object of the main data object. This one does not sort properly. The third column "WorkAround1" is a way to work around the problem using a GridTemplateColumn and a SortExpression using .ToString("s"). Since using a GridTemplateColumn is kind of cumbersome, I thought I'd try adding the .ToString("s") to the SortExpression of a GridDateTimeColumn, but this causes an exception. This is demonstrated when trying sort the "WorkAround2" column. Although this exception should probably fixed anyway (it doesn't make sense that it works for a GridTemplateColumn and not any other kind of bound column), getting the grid to support sorting on a DateTime property of a nested object either way is fine with me.

Mohan Bhandari
Top achievements
Rank 1
 answered on 22 Dec 2009
2 answers
102 views
Hi guys,

I just got a issue with RadComboBox + RadAjaxManager.
The Scenaria:

Two cbb1 and cbb2 on the web page.
I use RadAjaxManager to update cbb2 when cbb1 posted back.
And when cbb1 selectedindex changed, pop up an new window.

but whatever I setup for RadAjaxManager the new window never popup.


<Format Code Block>
form id="form1" runat='server'>        
             <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
             </telerik:RadScriptManager>
             <telerik:RadAjaxManager id="amgr1" runat="server" >
                  <AjaxSettings>
                        
                      <telerik:AjaxSetting AjaxControlID="rcbbTest1">
                        <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="rcbbTest2" />
                           <telerik:AjaxUpdatedControl ControlID="rcbbTest1" />
                        </UpdatedControls>
                     </telerik:AjaxSetting>
                     <telerik:AjaxSetting AjaxControlID="rcbbTest2">
                        <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="rcbbTest2" />
                         
                        </UpdatedControls>
                     </telerik:AjaxSetting>
                     <telerik:AjaxSetting AjaxControlID="rcbbTest3">
                        <UpdatedControls>
                           <telerik:AjaxUpdatedControl ControlID="rcbbTest3" />
                        </UpdatedControls>
                     </telerik:AjaxSetting>
                  </AjaxSettings>
             </telerik:RadAjaxManager>
            <table>
               <tr>
                  <td>
                     <telerik:RadComboBox ID="rcbbTest1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rcbbTest1_OnSelectedIndexChanged">
                        <Items>
                           <telerik:RadComboBoxItem Text="1"  />
                            <telerik:RadComboBoxItem Text="11"  />
                        </Items>
                     </telerik:RadComboBox>
                  </td>
               </tr>
                <tr>
                  <td>
                     <telerik:RadComboBox ID="rcbbTest2" runat="server" AutoPostBack="true"  OnSelectedIndexChanged="rcbbTest2_OnSelectedIndexChanged">
                        <Items>
                           <telerik:RadComboBoxItem Text="2"  />
                            <telerik:RadComboBoxItem Text="22"  />
                        </Items>
                     </telerik:RadComboBox>
                  </td>
               </tr>
                <tr>
                  <td>
                     <telerik:RadComboBox ID="rcbbTest3" runat="server" AutoPostBack="true"  OnSelectedIndexChanged="rcbbTest3_OnSelectedIndexChanged">
                        <Items>
                           <telerik:RadComboBoxItem Text="3"  />
                            <telerik:RadComboBoxItem Text="33"  />
                        </Items>
                     </telerik:RadComboBox>
                  </td>
               </tr>
            </table>              
      </form>
-- C#
protected void rcbbTest1_OnSelectedIndexChanged(object sender, EventArgs e)
      {
         string url = "Request.aspx?subject='Request Client Access1'";

         Telerik.Web.UI.RadWindow newWindowClient = new Telerik.Web.UI.RadWindow();
         newWindowClient.NavigateUrl = url;
         newWindowClient.VisibleOnPageLoad = true; // Set the VisibleOnPageLoad to true
         newWindowClient.Title = "1";
         this.Page.Form.Controls.Add(newWindowClient);
      }
</Format Code Block>

Thanks for your help


Alex
Alex Zhang
Top achievements
Rank 1
 answered on 22 Dec 2009
1 answer
155 views

I have to generate simple graph at the run time which is based on couple of group and I have problem with it.

 

Here is the Data

 

Total

Year

Type

4

2009

Type1

1

2008

Type1

2

2008

Type2

3

2008

Type3

 

 

 So my X – axis will have Year and Y axis will be Total. I need to show Type for each Year. Since Type is missing for the Year 2009, I have seeing this issue.

 

 

Schlurk
Top achievements
Rank 2
 answered on 22 Dec 2009
1 answer
81 views
My requirment

Am having 10 students in a class ,i will give fromdate and todate and get the attendence percentages of the students for the specified period.Now i want to show the barchart showing students name and attendence percentage in the bar,different colour for different percentages.

Am new to radcharts plz help me to find the solution.
Schlurk
Top achievements
Rank 2
 answered on 22 Dec 2009
1 answer
128 views

We have a radGrid which is loaded many columns.

Each column’s wide is narrower so more columns can be displayed.

One of the columns has radCombo box as a drop down list, and the record count label text extended outside of the comboBox.

This looks very undesirable.

Here is a screen shoot http://lh4.ggpht.com/_ohpx5KZcsi0/SzDjYr35nHI/AAAAAAAAFHU/AH-wzDkTMBI/comboBoxOverlap.JPG

 

Can this problem be fixed?

Yana
Telerik team
 answered on 22 Dec 2009
3 answers
112 views
The RadMenu is ignoring the SelectedCssClass property when using ItemTemplates. It is correctly applied if ItemTemplates are not used.

CSS:
        .TabFormat  
        {  
            height:50px !important;  
            background-color:#263144 !important;  
            padding:0px;  
        }  
        .TabFormat:hover  
        {  
            background-color:#212631 !important;  
            color:#f78f1e;  
        }  
        .TabSelected   
        {  
            background-color:#212631 !important;  
            color:#f78f1e !important;  
        }  
        .NavMenuItem  
        {  
            width:150px;  
            height:50px;  
        }  
        .NavMenuItem a, a:hover, a:active  
        {  
            cursor:default;  
            text-decoration:none;  
            color:#f78f1e;  
        }  
        .NavMenuTitle  
        {  
            font-size:12pt;  
            padding:5px 0px 5px 15px;  
        }  
        .NavMenuSubTitle  
        {  
            padding-left:15px;  
            font-size:8pt;  
        }  
 

Markup:
                <telerik:RadMenuItem IsSeparator="true" /> 
                <telerik:RadMenuItem runat="server"   
                    Text="how it works"   
                    CssClass="TabFormat"   
                    SelectedCssClass="TabSelected"   
                    NavigateUrl="~/HowItWorks.aspx" 
                    > 
                    <ItemTemplate> 
                        <a href="../HowItWorks.aspx">  
                            <div class="NavMenuItem">  
                                <div class="NavMenuTitle">  
                                    How it works  
                                </div> 
                                <div class="NavMenuSubTitle">  
                                    we'll show you  
                                </div> 
                            </div> 
                        </a> 
                    </ItemTemplate> 
                </telerik:RadMenuItem> 
 

Codebehind (VB) with work-around:
        Dim currentItem As RadMenuItem  
        If Request.Url.PathAndQuery.Contains("/products/") Then  
            currentItem = RadMenu1.FindItemByText("products")  
        Else  
            currentItem = RadMenu1.FindItemByUrl(Request.Url.PathAndQuery)  
        End If  
        If Not IsNothing(currentItem) Then  
            currentItem.Selected = True 
 
            ' NOTE: This is a workaround to a bug in the RadMenu that fails to apply the "selectedCSS"   
            '       when using Templates.  
            currentItem.CssClass = "TabSelected" 
        End If  
 
Yana
Telerik team
 answered on 22 Dec 2009
1 answer
90 views
I have a line chart that has one Series of data.
Is there a way to add points to the line?
or taking it from a differant way....is there a way to add a connecting line to a Point chart?

Thanks.
Schlurk
Top achievements
Rank 2
 answered on 22 Dec 2009
2 answers
543 views
I am using the auto-generated edit form on the grid and handling any errors in ItemInserted/ItemUpdated event. My question is - what is the proper way to display an error message inside the edit form? If that's not possible, do you have any sample code that would illustrate some other technique like display a popup or anything user friendly? Thank you.
Albert
Top achievements
Rank 1
 answered on 22 Dec 2009
1 answer
117 views
RadControls for ASP.NET AJAX Q2 2009 SP1 3.5 2008 Visual Basic.NET

Requirements

RadControls version

.NET version

Visual Studio version

programming language

browser support

all browsers supported by RadControls


PROJECT DESCRIPTION
This is an alternative way to handle [ENTER] key to perform insert/update operation inside a RadGrid FormTemplate (EditFormType="Template") within a Content Page (Master Page template). For unknown reason (probably the FormTemplate with customized insert/update and cancel button), I was unable to handle the [ENTER] key event so this is a possible solution:

 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
        <script type="text/javascript" language="javascript"> 
            function onKeyPress(sender, eventArgs) { 
                // 13 is the keycode for enter key 
                if (eventArgs.get_keyCode() == 13) { 
                    // LblUpdateButtonId it's an hidden label that contain the id of my custom insert/update button 
                    var temp = document.getElementById("<%=LblUpdateButtonId.ClientID %>"); 
                    var button_id = temp.innerHTML.replace(/_/g, "$"); 
                    // perform postback 
                    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(button_id, "", true, "", "", false, true)); 
                    // inhibit event bubbling 
                    eventArgs.set_cancel(true); 
                } 
            } 
    </script> 
    </telerik:RadCodeBlock> 

The custom insert/update asp:button calls a sub on OnLoad event (OnLoad="SetUpdateButtonId") to store his client id in the hidden label because I was unable to retrieve it in a different way:

Protected Sub SetUpdateButtonId(ByVal sender As Object, ByVal e As System.EventArgs) 
      LblUpdateButtonId.Text = CType(sender, Button).ClientID 
End Sub 


Iana Tsolova
Telerik team
 answered on 22 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?