Telerik Forums
UI for ASP.NET AJAX Forum
9 answers
365 views
I'm binded the result of a wcf service call to a grid on the client side. All good. I'm also trying to put tooltips on various columns in the grid (also clientside). Putting the tooltips on isn't the problem. The problem starts when I go to page 2. The tooltip IDs for page 1 still exist and so the tooltip breaks. So question is how do you remove the tooltips from the tooltipmanager on the clientside. I've seen the way to so this on the server side i.e. RadToolTipManager1.TargetControls.Clear(); But there doesn't seem to be an equivalent on the client side.
Any help would be appreciated.
Thanks
Svetlina Anati
Telerik team
 answered on 10 Feb 2010
1 answer
119 views
Hi,

I had a group by grid working well and then added a nested view to allow extra details to be displayed for a selected item.  It all works - expanding collapsing groups until I expand one of the nested views - then the group expansion/collapse is broken until I refresh the view.

Any ideas?  Here's a portion of the code...

 

 

        <telerik:RadGrid ID="HitRadGrid" runat="server" 
            AllowCustomPaging="True" 
            AllowMultiRowSelection="True"   
            AllowPaging="True"   
            AllowSorting="False"   
            AutoGenerateColumns="False" 
            ShowGroupPanel = "false" 
            SortingSettings-EnableSkinSortStyles="false" 
            SortingSettings-SortedAscToolTip = "Ascending" OnItemDataBound="GridItemDataBound" 
            SortingSettings-SortedDescToolTip="Descending" GridLines="None"   
            Skin="Web20">  
            <PagerStyle Mode="NextPrevAndNumeric" ></PagerStyle>  
            <MasterTableView  
                AutoGenerateColumns="false"   
                AllowSorting="false" GroupLoadMode="Client" 
                AllowCustomSorting="true"   
                AllowMultiColumnSorting="true"   
                ClientDataKeyNames="Reference" 
                DataKeyNames="Reference" AllowNaturalSort="False">  
                <GroupByExpressions> 
                    <telerik:GridGroupByExpression> 
                        <SelectFields> 
                            <telerik:GridGroupByField FieldName="Year" />                             
                        </SelectFields> 
                        <GroupByFields> 
                            <telerik:GridGroupByField FieldName="Year" SortOrder="Descending"/>                           
                        </GroupByFields> 
                    </telerik:GridGroupByExpression> 
                    <telerik:GridGroupByExpression> 
                        <SelectFields> 
                            <telerik:GridGroupByField FieldName="Author" />                           
                        </SelectFields> 
                        <GroupByFields> 
                            <telerik:GridGroupByField FieldName="Author" SortOrder="Ascending"/>                              
                        </GroupByFields> 
                    </telerik:GridGroupByExpression> 
                </GroupByExpressions> 
                <Columns> 
                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">  
                        <HeaderStyle Width="32px" /> 
                    </telerik:GridClientSelectColumn> 
                    <telerik:GridHyperLinkColumn UniqueName="TitleColumn" DataTextField="Title" HeaderText="Title" DataNavigateUrlFields="Reference"></telerik:GridHyperLinkColumn> 
                    <telerik:GridBoundColumn UniqueName="AuthorColumn" DataField="AUTHOR" HeaderText="Author" /> 
                    <telerik:GridBoundColumn UniqueName="DateColumn" DataField="DATE" HeaderText="Date" /> 
                    <telerik:GridHyperLinkColumn UniqueName="RelatedColumn" Text="Related..." DataNavigateUrlFields="Related"></telerik:GridHyperLinkColumn> 
                </Columns> 
                <NestedViewSettings> 
                    <ParentTableRelation> 
                        <telerik:GridRelationFields DetailKeyField="Reference" MasterKeyField="Reference" /> 
                    </ParentTableRelation> 
                </NestedViewSettings> 
                <NestedViewTemplate> 
                <asp:Panel ID="NestedViewPanel" runat="server" CssClass="viewWrap">  
                    <div class="contactWrap">  
                        <fieldset style="padding: 10px;">  
                            <legend style="padding: 5px;"><b>Detail info for document:&nbsp; &nbsp;<%#Eval("Title") %></b>  
                            </legend> 
                            <table> 
                                <tbody> 
                                    <tr> 
                                        <td> 
                                            <table> 
                                                <tbody> 
                                                    <tr> 
                                                        <td> 
                                                            Reference:  
                                                        </td> 
                                                        <td> 
                                                            <%#Eval("reference") %> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td> 
                                                            Location:  
                                                        </td> 
                                                        <td> 
                                                            <%#Eval("LOCATION") %> 
                                                        </td> 
                                                    </tr> 
 
                                                </tbody> 
                                            </table> 
                                        </td> 
                                    </tr> 
                                </tbody> 
                            </table> 
                        </fieldset> 
                    </div> 
                </asp:Panel> 
                </NestedViewTemplate> 
                <NoRecordsTemplate> 
                    No Results Found  
                </NoRecordsTemplate> 
            </MasterTableView> 
            <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true" AllowGroupExpandCollapse="true" > 
                <Resizing AllowColumnResize="true" EnableRealTimeResize="true" /> 
                <Selecting AllowRowSelect="true"></Selecting> 
            </ClientSettings> 
            <SortingSettings EnableSkinSortStyles="False" SortedAscToolTip="Ascending"   
                SortedDescToolTip="Descending" /> 
        </telerik:RadGrid> 
 
        <div class="searchMsgDiv">  
            <asp:Label ID="MessageLabel" runat="server" EnableViewState="false" Visible="false" /> 
        </div> 
    </asp:Panel> 
</div> 

 

Radoslav
Telerik team
 answered on 10 Feb 2010
2 answers
105 views
Hi,
I know you can enter totals in the footer row
Dim boundItem As GridFooterItem = CType(e.Item, GridFooterItem)  
dim str as String = "200.00" 
boundItem("SubTotal").Text = str  
 
but I need to show the taxes as well as the shipping costs and a Grand total. The taxes need to be dynamic as clients will have to set up their own taxes. Is it possible to put a repeater in the footer of a radgrid. I know it can be done by concatenating a string with <br> tags but there must be a better way.
This is what I want to achieve:

Total:             $200.00
P.S.T.:             $16.00
G.S.T.:             $10.00
Shipping:         $21.00
Grand Total:  $247.00
Rob Venable
Top achievements
Rank 1
 answered on 10 Feb 2010
1 answer
59 views
Hi, I am using RadEditor version 2009.3.1016 and I get this issue infrequently in IE8. Is this common? Has it been addressed in a later version. It looks like the height 100% on the cell wrapping the content area is calculating it size before the toolbars are loaded, but sometimes the toolbars load first. I am not positive however. Thanks!

Rumen
Telerik team
 answered on 10 Feb 2010
8 answers
153 views
Hello,

In our project we have background image and color defined for the BODY tag within global stylesheet. When I put RAD Editor on the page the text area of the editor inherits image and background color. How to specify different image/color for the text area of the editor?

I've tried to modify EditorContentArea.css to specify those attributes but it doesn't seem to work.

Thank you.
Rumen
Telerik team
 answered on 10 Feb 2010
40 answers
3.5K+ views
Has anyone seen the following error before?  It comes up randomly when opening a RadWindow, usually after building a project/solution.  I have not been able to track down what causes it to appear.

Server Error in '/XXX/YYY' Application.

Value cannot be null or empty.
Parameter name: handler

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Value cannot be null or empty.
Parameter name: handler

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

 
[ArgumentException: Value cannot be null or empty.
Parameter name: handler]
   System.Web.UI.ScriptComponentDescriptor.AddEvent(String name, String handler) +187
   Telerik.Web.ScriptObjectBuilder.DescribeComponent(Object instance, ScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver) +1029
   Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(WebControl control) +115
   Telerik.Web.UI.RadWebControl.GetScriptDescriptors() +5
   Telerik.Web.UI.RadWebControl.System.Web.UI.IScriptControl.GetScriptDescriptors() +10
   System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +92
   System.Web.UI.ScriptManager.RegisterScriptDescriptors(IScriptControl scriptControl) +22
   Telerik.Web.UI.RadWebControl.RegisterScriptDescriptors() +24
   Telerik.Web.UI.RadWebControl.Render(HtmlTextWriter writer) +33
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +52
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +198
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +189
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +25
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +167
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +217
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +52
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +198
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +47
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +189
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +25
   System.Web.UI.Page.Render(HtmlTextWriter writer) +30
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +52
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +198
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +594
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +88
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +25
   System.Web.UI.Page.Render(HtmlTextWriter writer) +30
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +52
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +198
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5792

 


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

Yavor
Telerik team
 answered on 10 Feb 2010
3 answers
132 views
Hi,

I have a problem when I try to upload an image in the imagemanager. I keep getting the error - cannot write to destination folder (Common_MessageCannotWriteToFolder). 

I have given the NETWORK SERVICE full control to my "upload" folder. I am using windows 7 and IIS 7.5.

Any ideas?
Rumen
Telerik team
 answered on 10 Feb 2010
3 answers
375 views
Here is my code : just change the datasource to northwind database in "GetConnectionString()" method

I'm only able to edit EmployeeID = 2 ... in RadGrid2 ... All other rows can't get edited.
Besides, I'm unable to update the only editable row (EmployeeID = 2) ... 

Must I add "NeedDataSource" or something like that for RadGrid2 ? 

Any help would be great, because this is a basic thing and I waste a lot of time to figure out how to do with Telerik component ...
Is it possible to have an "EditItemTemplate" instead of all columns spreaded vertically when I click "edit" button ?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadGridMarche2.aspx.cs" Inherits="RadGridMarche2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head> 
   <title></title
    <style type="text/css"
      .StaticColumn 
      {     
          font-family: Arial,Verdana, Helvetica; 
        font-size: 14px; 
        font-weight: normal;    
          border: none; 
          position: relative; 
      }  
  
        .RadGrid td{padding:0}  
         
       .rgExpand   
        {   
          background:url('Images/CollapsedButton.gif') center no-repeat !important;        
        }   
       
       .rgCollapse   
        {   
          background:url('Images/ExpandedButton.gif') center no-repeat !important;   
        }  
         
.RadGrid_Vista tr.DetailRow 
    background:#ebe4d6; 
 
.DetailTable_Vista 
    background:#f4ede1; 
 
.RadGrid_Vista .DetailTable_Vista .GridHeader_Vista, 
.RadGrid_Vista .DetailTable_Vista .ResizeHeader_Vista 
    padding-top:2px; 
    padding-bottom:2px; 
    background-position:0 -6px; 
}         
    </style>      
</head> 
<body> 
    <form runat="server" id="mainForm" method="post">         
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
        <!-- content start --> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />   
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" />                       
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <!-- DataSourceID="SqlDataSource1" --> 
        <br /> 
            <asp:Label ID="LblRadgrid1_height" runat="server" Width="900px" BackColor="red"></asp:Label> 
        <br /> 
        <table border="0" cellspacing="0" cellpadding="0" style="height:auto;">  
        <tr> 
        <td style="vertical-align:top;height:auto;">         
        <telerik:RadGrid ID="RadGrid1" Skin="Vista" OnPreRender="RadGrid1_PreRender"  
                runat="server" DataSourceID="SqlDataSource1"  OnColumnCreated="RadGrid1_ColumnCreated" 
            OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"  
                Width="100%" onselectedindexchanged="RadGrid1_SelectedIndexChanged"
            <MasterTableView  HierarchyDefaultExpanded="false" EnableNoRecordsTemplate="false" HierarchyLoadMode="ServerBind" AllowSorting="true" Width="800px" 
                DataKeyNames="EmployeeID" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-Display="true" 
                ExpandCollapseColumn-ExpandImageUrl="Images/CollapsedButton.gif" ExpandCollapseColumn-CollapseImageUrl="Images/ExpandedButton.gif"
                <ItemStyle Wrap="false" Width="200px" BackColor="Azure" Height="17px" BorderWidth="1"/> 
                <AlternatingItemStyle Wrap="false" BackColor="BlanchedAlmond" Width="200px" Height="17px" BorderWidth="1"/> 
                <HeaderStyle Wrap="false" Width="1500px" Height="20px"/> 
                 
                <SelfHierarchySettings ParentKeyName="ReportsTo" KeyName="EmployeeID"/>                 
                 
            </MasterTableView> 
             
            <ClientSettings AllowExpandCollapse="true" EnablePostBackOnRowClick="true" EnableRowHoverStyle="true">       
            <Selecting AllowRowSelect="true" />       
            </ClientSettings> 
        </telerik:RadGrid> 
        </td> 
        <td style="vertical-align:top;height:100%;">  
            <table style="vertical-align:top" cellpadding="0" cellspacing="0">  
                <tr valign="top"
                   <td valign="top">  
                        <div style="width:800px;overflow:scroll; vertical-align:top;"
                            <telerik:RadGrid ID="RadGrid2" ShowStatusBar="true" EnableViewState="true" AllowAutomaticUpdates="True"  
                            OnItemUpdated="RadGrid2_ItemUpdated" 
                runat="server" AutoGenerateColumns="false" AllowSorting="False" AllowMultiRowSelection="False" Width="800px" GridLines="None"
                <MasterTableView ItemStyle-Wrap="false" Name="Employees" DataKeyNames="EmployeeID" >                   
                <HeaderStyle Wrap="false" Height="20px"/>             
                <AlternatingItemStyle Height="17px" Width="200px" BackColor="BlanchedAlmond" Wrap="false" />  
                <ItemStyle Height="17px" Width="100px" BackColor="Azure" Wrap="false" />             
                    <Columns>  
                      
                        <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton" 
                            DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Height="17px"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton" 
                            DataField="LastName" UniqueName="LastName" ItemStyle-Height="17px"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton" 
                            DataField="FirstName" UniqueName="FirstName" ItemStyle-Height="17px"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton" 
                            DataField="Title" UniqueName="Title" ItemStyle-Height="17px"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton" 
                            DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Height="17px"
                        </telerik:GridBoundColumn>  
                        <telerik:GridEditCommandColumn Display="true" EditImageUrl="Images/ExpandedButton.gif" AutoPostBackOnFilter="true"
                        </telerik:GridEditCommandColumn>                                                       
                    </Columns> 
                </MasterTableView> 
                <clientsettings allowexpandcollapse="false" EnableRowHoverStyle="true">                 
                        <Scrolling AllowScroll="false" UseStaticHeaders="true"></Scrolling>                                                                                    
                </clientsettings>      
                        
            </telerik:RadGrid> 
                        </div> 
                    </td> 
                </tr> 
            </table> 
        </td> 
         
        </tr>         
        </table>         
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT EmployeeID, LastName, FirstName, Title, ReportsTo from Employees" 
            runat="server" UpdateCommand="UPDATE [Employees] SET [LastName] = ?, [Company] = ? [FirstName] = ?, [Title]= ? WHERE [EmployeeID] = ?" 
             OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"
            <UpdateParameters> 
                <asp:Parameter Name="LastName" Type="String" /> 
                <asp:Parameter Name="FirstName" Type="String" /> 
                <asp:Parameter Name="Title" Type="String" /> 
                <asp:Parameter Name="original_LastName" Type="String" /> 
                <asp:Parameter Name="original_FirstName" Type="String" /> 
                <asp:Parameter Name="original_Title" Type="String" /> 
            </UpdateParameters>            
         </asp:SqlDataSource> 
        <!-- content end --> 
    </form> 
</body> 
</html> 
 
 
----------------------------------- 
 
 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
using System.Reflection; 
using System.Data; 
using System.Data.SqlClient; 
 
public partial class RadGridMarche2 : System.Web.UI.Page 
 
    public void Page_Load(object sender, EventArgs e) 
    { 
        bindGrid2(); 
        
        if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1) 
        { 
            RadGrid1.MasterTableView.FilterExpression = @"it[""ReportsTo""] = Convert.DBNull"; 
        } 
        else 
        { 
            RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL"
        } 
         
        if (RadGrid1.MasterTableView.DetailTables != null) 
        { 
            RadGrid1.MasterTableView.DetailTables[0].AlternatingItemStyle.BackColor = System.Drawing.Color.Azure  ; 
            RadGrid1.MasterTableView.DetailTables[0].ItemStyle.BackColor = System.Drawing.Color.BlanchedAlmond; 
 
            if (RadGrid1.MasterTableView.DetailTables[0].DetailTables[0] != null) 
            { 
                RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].AlternatingItemStyle.BackColor = System.Drawing.Color.Azure; 
                RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].ItemStyle.BackColor = System.Drawing.Color.BlanchedAlmond; 
            } 
        } 
         
 
    } 
 
    public void Page_PreRenderComplete(object sender, EventArgs e) 
    { 
        HideExpandColumnRecursive(RadGrid1.MasterTableView); 
 
        string ActualNodes = string.Empty; 
 
        int counterVisibleNodes = 0
        foreach (GridDataItem dataItem in RadGrid1.Items) 
        { 
            if (dataItem.Visible) 
            { 
                ActualNodes += dataItem["EmployeeID"].Text + ","; 
                counterVisibleNodes++; 
            } 
        } 
 
 
        if (ActualNodes.Length > 0) 
            ActualNodesActualNodes = ActualNodes.Substring(0, ActualNodes.Length - 1); 
         
        RadGrid2.Controls.Clear(); 
        RadGrid2.DataSource = getDetails(ActualNodes); 
        RadGrid2.DataBind(); 
         
        if (Session["RadGrid1_SelectedValue"] != null) 
        { 
            for (int m = 0; m < RadGrid2.Items.Count; m++) 
            { 
                if (RadGrid2.Items[m]["EmployeeID"].Text.Equals(Session["RadGrid1_SelectedValue"].ToString())) 
                { 
                    RadGrid2.Items[m].Selected = true
                    break; 
                } 
            } 
            Session.Remove("RadGrid1_SelectedValue"); 
        } 
 
 
    } 
 
    public void HideExpandColumnRecursive(GridTableView tableView) 
    { 
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); 
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems) 
        { 
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) 
            { 
                nestedView.Style["border"] = "0"; 
 
                Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton"); 
                if (nestedView.Items.Count == 0) 
                { 
                    if (MyExpandCollapseButton != null) 
                    { 
                        MyExpandCollapseButton.Style["visibility"] = "hidden"; 
                    } 
                    nestedViewItem.Visible = false
                } 
                else 
                { 
                    if (MyExpandCollapseButton != null) 
                    { 
                        MyExpandCollapseButton.Style.Remove("visibility"); 
                    } 
                } 
 
                if (nestedView.HasDetailTables) 
                { 
                    HideExpandColumnRecursive(nestedView); 
                } 
            } 
        } 
    } 
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        CreateExpandCollapseButton(e.Item, "EmployeeID"); 
 
        if (e.Item is GridHeaderItem && e.Item.OwnerTableView != RadGrid1.MasterTableView) 
        { 
            e.Item.Style["display"] = "none"; 
        } 
 
        if (e.Item is GridNestedViewItem) 
        { 
            e.Item.Cells[0].Visible = false
 
            Table table = (Table)e.Item.OwnerTableView.Controls[0]; 
 
            GridItem prevItem = (GridItem)table.Rows[table.Rows.Count - 1]; 
            // Why -3? We need to skip the NestedViewItem and the preceding DataItem's invisible EditItem 
 
            if (prevItem.ItemType == GridItemType.AlternatingItem) 
            { 
                e.Item.CssClass = "DetailAltRow"
            } 
            else 
            { 
                e.Item.CssClass = "DetailRow"
            } 
            /* 
            e.Item.Cells[0].CssClass = "DetailRowCell"
            e.Item.Cells[1].CssClass = "DetailRowCell"
             */ 
        } 
 
    
    } 
 
    protected void RadGrid1_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 RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        CreateExpandCollapseButton(e.Item, "EmployeeID"); 
    } 
 
    public void CreateExpandCollapseButton(GridItem item, string columnUniqueName) 
    { 
        if (item is GridDataItem) 
        { 
            if (item.FindControl("MyExpandCollapseButton") == null) 
            { 
                Button button = new Button(); 
                button.Click += new EventHandler(button_Click); 
                button.CommandName = "ExpandCollapse"
                button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand"; 
                button.ID = "MyExpandCollapseButton"
 
                if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client) 
                { 
                    string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID); 
 
                    button.OnClientClick = script
                } 
 
                int level = item.ItemIndexHierarchical.Split(':').Length; 
                if (level > 1) 
                { 
                    button.Style["margin-left"] = level + 10 + "px"; 
                    button.Style["height"] = "15px"; 
                } 
 
 
                TableCell cell = ((GridDataItem)item)[columnUniqueName]; 
                cell.Controls.Add(button); 
 
                LiteralControl liSpace = new LiteralControl("&nbsp;"); 
                cell.Controls.Add(liSpace); 
 
                cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString())); 
                cell.Style["height"] = "15px"; 
 
            } 
        } 
    } 
 
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
 
        string ActualNodes = string.Empty; 
 
        foreach (GridDataItem dataItem in RadGrid1.Items) 
        { 
            if (dataItem.Visible) 
            { 
                ActualNodes += dataItem["EmployeeID"].Text + ","; 
            } 
        } 
 
 
        if (ActualNodes.Length > 0) 
            ActualNodesActualNodes = ActualNodes.Substring(0, ActualNodes.Length - 1); 
 
        RadGrid2.Controls.Clear(); 
        RadGrid2.DataSource = getDetails(ActualNodes); 
        RadGrid2.DataBind(); 
        //Response.Write("<script> alert(" + sTest + ");</script>");  
    } 
 
 
    void button_Click(object sender, EventArgs e) 
    { 
        ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand"; 
        LblRadgrid1_height.Text = RadGrid1.Height.Value.ToString(); 
        //Response.Write("<script language='javascript'> document.alert(" + RadGrid1.Height.Value.ToString() + ");</script>"); 
    } 
 
 
    private void bindGrid2() 
    { 
 
        RadGrid2.Controls.Clear(); 
        string initialNodes = string.Empty; 
        for (int m = 0; m < RadGrid1.Items.Count; m++) 
        { 
            if (!RadGrid1.Items[m]["EmployeeID"].Text.ToLower().Equals("&nbsp;") && RadGrid1.Items[m].Visible) 
                initialNodes += RadGrid1.Items[m]["EmployeeID"].Text + ","; 
        } 
 
        if (initialNodes.Length > 0) 
        { 
            RadGrid2.DataSource = getEmployees(initialNodes.Substring(0, initialNodes.Length - 1)); 
        } 
        else 
            RadGrid2.DataSource = getEmployees(""); 
 
        RadGrid2.DataBind(); 
    } 
 
    private DataView getEmployees(string initialNodes) 
    { 
        DataSet ds = new DataSet(); 
 
        string sqlFinal = string.Empty; 
        if (!initialNodes.Equals(string.Empty)) 
        { 
            sqlFinal = "Where EmployeeID in (" + initialNodes + ")"; 
        } 
 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand("SELECT top 1 [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] " + sqlFinal, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
 
            sqlAdapter.Fill(ds); 
        } 
 
        DataView dv = new DataView(ds.Tables[0]); 
        return dv; 
    } 
 
    private DataTable getChildNodesByID(string ParentID) 
    { 
        DataSet ds = new DataSet(); 
        string sql = "SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] Where ReportsTo = " + ParentID; 
 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand(sql, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
            sqlAdapter.Fill(ds); 
        } 
 
        DataTable dt = new DataTable(); 
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) 
            return ds.Tables[0]; 
        else 
            return null; 
    } 
 
    private DataView getDetails(string ActualNodes) 
    { 
        DataSet ds = new DataSet(); 
 
 
        //string noeuds = ActualNodes.Substring(0, ActualNodes.Length - 1);  
 
        string[] tabNoeuds = ActualNodes.Split(','); 
        string swhen = " CASE "
 
        for (int i = 0; i < tabNoeuds.Length; i++) 
        { 
            swhen += " WHEN EmployeeID = " + tabNoeuds[i] + " THEN " + (i + 1) + " "; 
        } 
        swhen += " END "; 
 
        string sql = "SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] Where EmployeeID in (" + ActualNodes + ")"; 
        sql += " ORDER BY " + swhen; 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand(sql, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
            sqlAdapter.Fill(ds); 
        } 
 
        DataView dv = new DataView(ds.Tables[0]); 
        return dv; 
    } 
 
 
 
    static private string GetConnectionString() 
    { 
        return "server=STATION00374;database=Northwind;Integrated Security=SSPI;"; 
    } 
 
 
    protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        if (Session["RadGrid1_SelectedValue"] != null) 
            Session.Remove("RadGrid1_SelectedValue"); 
 
        Session["RadGrid1_SelectedValue"] = RadGrid1.SelectedValue.ToString();  
    } 
 
    protected void RadGrid2_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e) 
    { 
        string item = getItemName(e.Item.OwnerTableView.Name); 
        string field = getFieldName(e.Item.OwnerTableView.Name); 
        if (e.Exception != null) 
        { 
            e.KeepInEditMode = true
            e.ExceptionHandled = true
            DisplayMessage(item + " " + e.Item[field].Text + " cannot be updated. Reason: " + e.Exception.Message); 
        } 
        else 
        { 
            DisplayMessage(item + " " + e.Item[field].Text + " updated"); 
        } 
    } 
 
    private String getItemName(string tableName) 
    { 
        switch (tableName) 
        { 
            case ("Employees"): 
                { 
                    return "Employees"; 
                } 
            default: return ""; 
        } 
    } 
 
    private String getFieldName(string tableName) 
    { 
        switch (tableName) 
        { 
            case ("Employees"): 
                { 
                    return "EmployeeID"; 
                } 
            default: return ""; 
        } 
    } 
 
    private void DisplayMessage(string text) 
    { 
        RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text))); 
    } 
 

Tsvetoslav
Telerik team
 answered on 10 Feb 2010
4 answers
77 views
Hi,
I created a aspx with just the editor in it.

I got a javascript error when I insert a table.
then I select then table.
reposition mouse inside a table cell while table is selected.
press right mouse button.
and select setCellPropertys
when the table settings window appears I press cancel.

I get the error in IE8 in comatible modes.
telerik.web.ui.dll (2008.3.1314.20)

Best regards,




martin stehouwer
Top achievements
Rank 1
 answered on 10 Feb 2010
5 answers
172 views
Guys,

I have a grid that has the DataKeyNames and ClientDataKeyNames properties set to couple of columns. One of the columns is the timestamp column (of type timestamp in the database and byte array in the DataSet that comes from the DAL) and the grid does not store that column's value in the Key Values; instead it stores the name of the type "System.Byte[]".

The problem is that I need the column's value instead of the type name on the client side.

I was hoping to capture some event on the server side to convert the timestamp column's value from byte array to a Base64 encoded string and put it back in the KeyValues so that I could retrieve the value on the client side, but so far I could not find a way to change the key values.

Any thoughts about how should I approach this problem? If changing the grid key values is not supported, then is there any other hidden place (except the hidden column) where I could store the base64 encoded string?

Thanks,
Manny
Iana Tsolova
Telerik team
 answered on 10 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?