Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
68 views
HI FRIENDS
   i'm using RadNumericTextBox in my asp.net page but i assign value in code behind in RadNumericTextBoxid="" thats not working in IE8
but its working in IE7 and other browser    anybody knows tell me
 
Sebastian
Telerik team
 answered on 08 Jun 2010
1 answer
354 views
Hi I have problem in exporting to excel from the grid. It throws exception if I set
<Excel Format = "excelML">
for <Excel Format="html"> its working fine.
Here is my grid settings.

 

 

 

 

<telerik:RadGrid ID="grdCheckData" runat="server" AllowPaging="True"  AllowSorting ="true"  GridLines="both"  OnPageIndexChanged="grdCheckData_PageIndexChanged" OnPageSizeChanged="grdCheckData_PageSizeChanged"    
    OnSortCommand="grdCheckData_SortCommand"  ShowGroupPanel="true"  ><%--OnExcelExportCellFormatting="grdCheckData_ExcelExportCellFormatting" OnExcelMLExportRowCreated="grdCheckData_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="grdCheckData_ExcelMLExportStylesCreated" --%> 
     
         <ClientSettings  AllowColumnsReorder ="true"  AllowDragToGroup="true"  ReorderColumnsOnClient="true"  Scrolling-AllowScroll="true"   > 
             <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" 
                            AllowColumnResize="True"></Resizing> 
                  
            </ClientSettings> 
            <GroupingSettings ShowUnGroupButton="true" UnGroupTooltip ="Drag the field to group by." /> 
            <SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" /> 
            <ExportSettings FileName ="CheckInfo" OpenInNewWindow="true"   IgnorePaging ="true" ExportOnlyData="true"  > 
<Excel Format="excelML"   /> 
<Pdf AllowPrinting="true" /> 
</ExportSettings> 
        <MasterTableView AutoGenerateColumns ="false"  > 
         
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn > 
            <Columns  > 
            <telerik:GridBoundColumn DataField ="BANK"  UniqueName ="BANK" SortExpression="BANK" ReadOnly ="true" HeaderText ="Bank" > <ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="BANKNO" UniqueName ="BANKNO" SortExpression ="BANKNO" ReadOnly ="true" HeaderText ="Bank ID" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="PMSID" UniqueName ="PMSID" SortExpression ="PMSID" ReadOnly ="true" HeaderText ="PMS ID" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="SSN" UniqueName ="SSN" ReadOnly ="true" SortExpression ="SSN" HeaderText ="SSN" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="FNAME" UniqueName ="FNAME" ReadOnly ="true" SortExpression ="FNAME" HeaderText ="First Name" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="LNAME" UniqueName ="LNAME" ReadOnly ="true" SortExpression ="LNAME" HeaderText ="Last Name" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="LET" UniqueName ="LET" ReadOnly ="true" HeaderText ="Let" SortExpression ="LET" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="CHECKNUM" UniqueName ="CHECKNUM" ReadOnly ="true" SortExpression ="CHECKNUM" HeaderText ="Check No." ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="CHECKDT" UniqueName ="CHECKDT" ReadOnly ="true" SortExpression ="CHECKDT" HeaderText ="Check Date" DataType = "System.DateTime" DataFormatString="{0:MM/dd/yyyy}"  HtmlEncode="false" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="NETPAY" UniqueName ="NETPAY" DataFormatString="{0:$###,###.##}" ReadOnly ="true" SortExpression ="NETPAY" HeaderText ="Net Amt." ><ItemStyle Width ="100" /></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField ="DISPDT" UniqueName ="DISPDT" ReadOnly ="true" SortExpression ="DISPDT"  HeaderText ="Disp. Date" DataType = "System.DateTime" DataFormatString="{0:MM/dd/yyyy}"  HtmlEncode="false" > 
            <ItemStyle Width ="100" /> 
            </telerik:GridBoundColumn> 
              
            </Columns> 
        </MasterTableView> 
      
    </telerik:RadGrid> 

Here is my code for export.

protected void btnExportExl_Click(object sender, EventArgs e)  
        {  
            try  
            {  
                if ((!IsPostBack) || (!IsValid))  
                    return;  
 
                RadGrid grdCheckData = (RadGrid)dataPanel.FindItemByValue("CheckData").FindControl("grdCheckData");  
                  
                grdCheckData.MasterTableView.ExportToExcel();  
            }  
            catch (Exception ex)  
            {  
                throw;  
            }  
        }  
 
        protected void grdCheckData_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e)  
        {  
              
        }  
 
        protected void grdCheckData_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e)  
        {  
            foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles)  
            {  
                if (style.Id == "headerStyle")  
                {  
                    style.FontStyle.Bold = true;  
                    style.FontStyle.Color = System.Drawing.Color.Brown;  
                    style.InteriorStyle.Color = System.Drawing.Color.Wheat;  
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;  
                }  
                else if (style.Id == "itemStyle")  
                {  
                    style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.NumberFormatType.Currency;  
                    style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Left;  
                    style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke;  
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;  
                }  
                else if (style.Id == "alternatingItemStyle")  
                {  
                    style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.NumberFormatType.Currency;  
                    style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Left;  
                    style.InteriorStyle.Color = System.Drawing.Color.LightGray;  
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;  
                }  
 
 
            }  
        }  
 
        protected void grdCheckData_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)  
        {  
            if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.HeaderRow)  
            {  
                Telerik.Web.UI.GridExcelBuilder.RowElement row = new Telerik.Web.UI.GridExcelBuilder.RowElement();  
                Telerik.Web.UI.GridExcelBuilder.CellElement cell = new Telerik.Web.UI.GridExcelBuilder.CellElement();  
                cell.Data.DataItem = "NYC Department Of Education";  
                row.Cells.Add(cell);  
                e.Worksheet.Table.Rows.Insert(0, row);  
            }    
 
        }  
 
        

And this is the Error I m getting after execution of btnExport_Click event.
Object reference not set to an instance of an object.   
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.NullReferenceException: Object reference not set to an instance of an object.  
 
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:   
 
 
[NullReferenceException: Object reference not set to an instance of an object.]  
   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +864  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19  
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +8676409  
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32  
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99  
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40  
   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +93  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19  
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266  
 
   
 
 
--------------------------------------------------------------------------------  
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082  

Daniel
Telerik team
 answered on 08 Jun 2010
4 answers
132 views
I have a page where there are multiple editors on the screen, on the initial load only one editor is visible to the user and using javascript the divs style are changed from display: none to display: block in IE 7 when the editor is initially hidden and then told to display the toolbar is missing.  Works in FF/Chrome/IE 8

Is there a way to have the toolbar show up for IE 7 in this instance:

<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
    <script type="text/javascript"
        function ChangeDisplay(elm) { 
            var div = document.getElementById("Wrapper2"); 
            if (elm.value == "0") { 
                div.style.cssText = "display: none;"
            } 
            else { 
                div.style.cssText = "display: block;"
            } 
        } 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="SM" runat="server"></asp:ScriptManager> 
            <asp:ListBox ID="LB1" runat="server" onchange="ChangeDisplay(this);" Rows="1" SelectionMode="Single"
            <asp:ListItem Text="Hide" Value="0"></asp:ListItem> 
            <asp:ListItem Text="Show" Value="1"></asp:ListItem> 
        </asp:ListBox> 
        <div id="Wrapper"
        <div style="float: left; padding-top: 2px;"
            <telerik:RadEditor ID="RadEditor1" runat="server"  Skin="Default" Height="200" Width="610"   ContentFilters="RemoveScripts" EnableResize="false" EditModes="Design"
            </telerik:RadEditor> 
        </div> 
        </div> 
        <div id="Wrapper2" style="display: none;"
        <div style="float: left; padding-top: 2px;"
            <telerik:RadEditor ID="RadEditor2" runat="server"  Skin="Default" Height="200" Width="610" ContentFilters="RemoveScripts" EnableResize="false" EditModes="Design"
            </telerik:RadEditor> 
        </div> 
        </div> 
    </form> 
</body> 
</html> 

mohammed
Top achievements
Rank 1
 answered on 08 Jun 2010
1 answer
131 views

Hello ,

I'm using radticker in my form in that I need to take data from xml file but I'm getting error, FOA I'm using following XML code

<test>
  <test Heading="Heading One" Body="This is Body"/>
  <test Heading="Heasing two" Body="This is body two."/>
</test>

below is what I'm using in aspx code

    <telerik:RadRotator ID="RadRotator1" runat="server" ScrollDirection="Left" ScrollDuration="7000" DataSourceID="XmlDataSource1" RenderingCompatibility="3.5" Skin="Windows7">
    <ItemTemplate>
        <telerik:RadTicker ID="RadTicker1" runat="server" AutoStart="true" LineDuration="4000" Loop="true">
        <Items>
            <telerik:RadTickerItem Text='<%# XPath("Heading") %>'>
            </telerik:RadTickerItem>
            <telerik:RadTickerItem Text='<%# XPath("Body") %>'>
            </telerik:RadTickerItem>
        </Items>
    </telerik:RadTicker>
    </ItemTemplate>
    </telerik:RadRotator>
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml">
    </asp:XmlDataSource>

After running this I don't get any output in browser, but if I put simple text instead of xpath.... it appears in browser tickering & rotating but not if I choose from xml file

In above code what I need to do is that firstly heading1 and body1 should ticker in first rotation and heading2 and body2 should ticker in second rotation

If anyone could provide solution for this that would be great for me I tried for this a lot but with no success till now

Plz reply

Thanks

Fiko
Telerik team
 answered on 08 Jun 2010
1 answer
66 views
IE cannot resolve the URL for a server side callback when collapsing a node if the URL contains a hash symbol (#).

Since the page ScriptManager tracks history points by appending a hash code to the page URL, the treeview will fail to load when using ajax history (back button support). I have the same issue as well with RadScriptManager.

Works correctly in Firefox. Using release 2009.3.1314.35.

Sample project
Nikolay Tsenkov
Telerik team
 answered on 08 Jun 2010
4 answers
140 views
Hello,
I am working with a usercontrol to add/edit items in a RadGrid row
 
                <EditFormSettings UserControlName="EmployeeDetails.ascx" EditFormType="WebUserControl">  
                    <EditColumn UniqueName="EditCommandColumn1">  
                    </EditColumn> 
                </EditFormSettings> 
But each item/row can have associated another table in which I would like to be able to insert/edit so what i should see at the usercontrol is like another radgrid control. I have read in the live examples that this can be done with hierarchy and DetailTable, but I don´t know how to 'draw' this table in the usercontrol so the items are binded to the employee detail showed in the usercontrol.

This is my UserControl
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EmployeeDetails.ascx.cs" Inherits="telerik_webGrid.EmployeeDetails" %> 
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none" 
    style="BORDER-COLLAPSE: collapse">  
        <tr class="EditFormHeader">  
        <td colspan="2"><b>Employee Details</b></td>  
    </tr> 
    <tr> 
        <td colspan="2"><b>Personal Info:</b></td>  
    </tr> 
    <tr> 
        <td> 
            <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0">  
                <tr> 
                    <td></td>  
                    <td></td>  
                </tr> 
                <tr> 
                    <td>Country:</td> 
                    <td> 
                        <asp:TextBox id="TextBox7" runat="server" 
                        Text='<%# DataBinder.Eval( Container, "DataItem.Country"  ) %>'>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>City:</td> 
                    <td> 
                        <asp:TextBox id="TextBox8" runat="server"   
                        Text='<%# DataBinder.Eval( Container, "DataItem.City") %>' 
                         tabIndex=1>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Region:</td> 
                    <td> 
                        <asp:TextBox id="TextBox9" runat="server" 
                        Text='<%# DataBinder.Eval( Container, "DataItem.Region") %>' 
                         tabIndex=2>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Home Phone:</td> 
                    <td> 
                        <asp:TextBox id="TextBox10" runat="server"   
                        Text='<%# DataBinder.Eval( Container, "DataItem.HomePhone") %>' 
                         tabIndex=3>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Birth Date:</td> 
                    <td> 
                        <asp:TextBox id="TextBox11" runat="server"   
                        Text='<%# DataBinder.Eval( Container, "DataItem.BirthDate") %>' 
                         tabIndex=4>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Title Of Courtesy</td> 
                    <td> 
                        <asp:dropdownlist id="ddlTOC" runat="server" tabindex="7"></asp:dropdownlist></td>  
                </tr> 
            </table> 
        </td> 
        <td> 
            <table id="Table1" cellspacing="1" cellpadding="1" width="300" border="0">  
                <tr> 
                    <td>Notes:  
                    </td> 
                </tr> 
                <tr> 
                    <td> 
                        <asp:TextBox id=TextBox1 Text='<%# DataBinder.Eval( Container, "DataItem.Notes") %>' runat="server" TextMode="MultiLine" Rows="5" Columns="40" tabIndex=5>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Address:</td> 
                </tr> 
                <tr> 
                    <td> 
                        <asp:TextBox id=TextBox6 Text='<%# DataBinder.Eval( Container, "DataItem.Address") %>' runat="server" TextMode="MultiLine" Rows="2" Columns="40" tabIndex=6>  
                        </asp:textbox></td>  
                </tr> 
            </table> 
        </td> 
    </tr> 
    <tr> 
        <td colspan="2"><b>Company Info:</b></td>  
    </tr> 
    <tr> 
        <td> 
            <table id="Table4" cellspacing="1" cellpadding="1" width="300" border="0">  
                <tr> 
                    <td>FirstName:</td> 
                    <td> 
                        <asp:TextBox id=TextBox2 Text='<%# DataBinder.Eval( Container, "DataItem.FirstName") %>' runat="server" tabIndex=8>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Last Name:</td> 
                    <td> 
                        <asp:TextBox id=TextBox3 Text='<%# DataBinder.Eval( Container, "DataItem.LastName") %>' runat="server" tabIndex=9>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Hire Date:</td> 
                    <td> 
                        <asp:TextBox id=Textbox5 Text='<%# DataBinder.Eval(Container, "DataItem.HireDate") %>' runat="server" tabIndex=10>  
                        </asp:textbox></td>  
                </tr> 
                <tr> 
                    <td>Title:</td> 
                    <td> 
                        <asp:TextBox id=TextBox4 Text='<%# DataBinder.Eval( Container, "DataItem.Title") %>' runat="server" tabIndex=11>  
                        </asp:textbox></td>  
                </tr> 
            </table> 
        </td> 
        <td></td>  
    </tr> 
    <tr> 
        <td colspan="2"><b>Tests</b></td>  
    </tr> 
    <tr> 
        <td> 
            <table id="Table5" cellspacing="1" cellpadding="1" width="300" border="0">  
                <tr> 
                    <td> 
                        <!--HERE SHOULD BE THE TABLE --> 
                    </td> 
                </tr> 
            </table> 
        </td> 
        <td></td>  
    </tr> 
    <tr> 
        <td align="right" colspan="2">  
            <asp:button id="btnUpdate" text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'></asp:button> 
            <asp:button id="btnInsert" text="Insert" runat="server" CommandName="PerformInsert" Visible='<%# DataItem is Telerik.Web.UI.GridInsertionObject %>'></asp:button> 
            &nbsp;  
            <asp:button id="btnCancel" text="Cancel" runat="server" causesvalidation="False" commandname="Cancel"></asp:button></td>  
    </tr> 
 

Thank you very much.
Borja
Top achievements
Rank 1
 answered on 08 Jun 2010
2 answers
78 views
Hi,

I want to be able to show the footer of a RadGrid's detailstableview dynamically and populate a RadComboBox on a button click event.

protected void Button_Click(object sender, EventArgs e) 
    GridTableView tblView = (GridTableView)(sender as LinkButton).Parent.Parent.Parent.Parent.Parent; 
    tblView.ShowFooter = true;

    GridItem item = tblView.GetItems[GridItemType.Footer)[0];
    RadComboBox radCombo = (RadComboBox)item.FindControl("RadCombo1");
 
    DataTable dt = GetDataSource();
    radCombo.DataSource = dt;
    radCombo.DataBind();
  
     tblView.Rebind(); <-solution

 
So my problem is the footer of a RadGrid's detailstableview will not display until I collapse and then re expand the parent node. How can this all be done smoothly, to just show the footer on a button click event.

Thanks,
Bill
Bill
Top achievements
Rank 1
 answered on 08 Jun 2010
5 answers
236 views
Hey everyone, I have a self referencing hierarchy and I am unable to configure it properly to allow editing or adding records to child nodes. If it is a top level parent both functions work perfecting. However, clicking on either the add or edit command links causes the entire child node to close and disappear. Clicking refresh on another node (but not the master table) cause the rows to reappear, including the edit/add row, but the content of those rows are empty.

I came across this post and followed it's instructions to no avail. It does not seem correct for self referencing hierarchies anyways. The relevant code from my project is below. Thanks in advance!

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="TaxonomiesRadGrid"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="TaxonomiesRadGrid" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
<telerik:RadGrid runat="server" ID="TaxonomiesRadGrid" AllowMultiRowSelection="true" 
    Skin="WebBlue" AutoGenerateColumns="false" Width="90%" GridLines="None" MasterTableView-DataSourceID="TaxonomiesRGSqlDataSource" 
    MasterTableView-DataKeyNames="taxonomyItemId, taxonomyParentId" MasterTableView-GroupsDefaultExpanded="true" 
    MasterTableView-GridLines="None" MasterTableView-GroupLoadMode="Client" MasterTableView-FilterExpression="taxonomyParentId IS NULL" 
    ClientSettings-AllowGroupExpandCollapse="true" OnItemDataBound="TaxonomiesRadGrid_ItemDataBound" 
    MasterTableView-SelfHierarchySettings-MaximumDepth="100" AllowAutomaticDeletes="true" 
    AllowAutomaticInserts="true" AllowAutomaticUpdates="true" OnItemUpdated="TaxonomiesRadGrid_ItemUpdated" 
    OnItemInserted="TaxonomiesRadGrid_ItemInserted" OnItemCreated="TaxonomiesRadGrid_ItemCreated" 
    OnInsertCommand="TaxonomiesRadGrid_InsertCommand" OnUpdateCommand="TaxonomiesRadGrid_UpdateCommand" 
    ShowStatusBar="true" OnDataBound="TaxonomiesRadGrid_DataBound" OnItemCommand="TaxonomiesRadGrid_ItemCommand"
    <MasterTableView HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" CommandItemDisplay="Top" 
        CommandItemSettings-AddNewRecordText="Add a new Taxonomy Parent" EditMode="InPlace" 
        NoMasterRecordsText="No taxonomy items to display. Please select a taxonomy framework from above."
        <SelfHierarchySettings ParentKeyName="taxonomyParentId" KeyName="taxonomyItemId" /> 
        <Columns> 
            <telerik:GridBoundColumn DataField="taxonomyText" DataType="System.String" HeaderText="Taxonomy Description" 
                SortExpression="taxonomyText" UniqueName="taxonomyText"
            </telerik:GridBoundColumn> 
            <telerik:GridEditCommandColumn ButtonType="PushButton" ItemStyle-Width="120px" ItemStyle-HorizontalAlign="Right"
            </telerik:GridEditCommandColumn> 
            <telerik:GridClientDeleteColumn ButtonType="PushButton" ItemStyle-Width="50px" ItemStyle-BorderWidth="0px" 
                ItemStyle-HorizontalAlign="Center" ConfirmText="Are you sure you want to delete this taxonomy item and any items beneath it?"
            </telerik:GridClientDeleteColumn> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
<asp:SqlDataSource ID="TaxonomiesRGSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:PrimarySQLConn %>" 
    SelectCommand="GetTaxonomyDetails" SelectCommandType="StoredProcedure" InsertCommand="InsertTaxonomyItem" 
    InsertCommandType="StoredProcedure" UpdateCommand="UpdateTaxonomyItem" UpdateCommandType="StoredProcedure" 
    OnUpdating="OnUpdating"></asp:SqlDataSource> 

Code behind:
private Hashtable _expandedState; 
private Hashtable _selectedState; 
 
protected void Page_Load(object sender, EventArgs e) 
    if (!IsPostBack) 
    { 
        //reset expanded states 
        this._expandedState = null
        this.Session["_ordersExpandedState"] = null
    } 
 
public void Page_PreRenderComplete(object sender, EventArgs e) 
    HideExpandColumnRecursive(TaxonomiesRadGrid.MasterTableView); 
#region Click & Command Events 
 
protected void ShowTaxonomyDetailsButton_Click(object sender, EventArgs e) 
    TaxonomiesRGSqlDataSource.SelectParameters.Clear(); 
    TaxonomiesRGSqlDataSource.SelectParameters.Add("id", TaxonomiesListBox.SelectedValue.ToString()); 
    TaxonomiesRadGrid.DataBind(); 
#endregion 
#region Grid Message 
 
private string gridMessage = null
 
private void SetMessage(string message) 
    gridMessage = message; 
 
protected void RadGrid1_DataBound(object sender, EventArgs e) 
    if (!string.IsNullOrEmpty(gridMessage)) 
    { 
        DisplayMessage(gridMessage); 
    } 
 
private void DisplayMessage(string text) 
    TaxonomiesRadGrid.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text))); 
#endregion 
#region TaxonomiesRadGrid Events 
 
protected void TaxonomiesRadGrid_ItemInserted(object source, GridInsertedEventArgs e) 
    if (e.Exception != null
    { 
        e.ExceptionHandled = true
        DisplayMessage(" Taxonomy item cannot be inserted. Reason: " + e.Exception.Message); 
    } 
    else 
    { 
        DisplayMessage(" Taxonomy item inserted"); 
    } 
 
protected void TaxonomiesRadGrid_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e) 
    if (e.Exception != null
    { 
        e.KeepInEditMode = false
        e.ExceptionHandled = true
        DisplayMessage(" Taxonomy item cannot be updated. Reason: " + e.Exception.Message); 
    } 
    else 
    { 
        DisplayMessage(" Taxonomy item updated"); 
    } 
 
protected void TaxonomiesRadGrid_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridHeaderItem && e.Item.OwnerTableView != TaxonomiesRadGrid.MasterTableView) 
    { 
        e.Item.Style["display"] = "none"
    } 
    else if (e.Item is GridCommandItem && e.Item.OwnerTableView != TaxonomiesRadGrid.MasterTableView) 
    { 
        ((Button)e.Item.Cells[0].FindControl("AddNewRecordButton")).Visible = false
        ((Button)e.Item.Cells[0].FindControl("RefreshButton")).Visible = false
 
        ((LinkButton)e.Item.Cells[0].FindControl("InitInsertButton")).Text = "Add a new taxonomy item to this parent"
    } 
    else if (e.Item is GridCommandItem && e.Item.OwnerTableView == TaxonomiesRadGrid.MasterTableView) 
    { 
        ((Button)e.Item.Cells[0].FindControl("AddNewRecordButton")).Visible = false
        ((Button)e.Item.Cells[0].FindControl("RefreshButton")).Visible = false
    } 
 
protected void TaxonomiesRadGrid_InsertCommand(object source, GridCommandEventArgs e) 
    if (e.Item.OwnerTableView == TaxonomiesRadGrid.MasterTableView) 
    { 
        GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem; 
        TaxonomiesRGSqlDataSource.InsertParameters.Clear(); 
        TaxonomiesRGSqlDataSource.InsertParameters.Add("taxonomyId", TaxonomiesListBox.SelectedValue.ToString()); 
        TaxonomiesRGSqlDataSource.InsertParameters.Add("parentId", DBNull.Value.ToString()); 
    } 
    else 
    { 
        GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem; 
        TaxonomiesRGSqlDataSource.InsertParameters.Clear(); 
        TaxonomiesRGSqlDataSource.InsertParameters.Add("taxonomyId", TaxonomiesListBox.SelectedValue.ToString()); 
        TaxonomiesRGSqlDataSource.InsertParameters.Add("parentId", parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["taxonomyParentId"].ToString()); 
    } 
 
protected void TaxonomiesRadGrid_UpdateCommand(object source, GridCommandEventArgs e) 
    //GridEditableItem editedItem = e.Item as GridEditableItem; 
    //TaxonomiesRGSqlDataSource.UpdateParameters.Clear(); 
    //TaxonomiesRGSqlDataSource.UpdateParameters.Add("taxonomyItemId", editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["taxonomyItemId"].ToString()); 
    //TaxonomiesRGSqlDataSource.UpdateParameters.Add("taxonomyText", "test"); 
#endregion 
 
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("ctl00"); 
            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); 
            } 
        } 
    } 
#region Diagnostics 
 
protected void OnUpdating(object sender, EventArgs e) 
    EventArgs er = e; 
#endregion 
#region Child Editing 
 
//Save/load expanded states Hash from the session 
//this can also be implemented in the ViewState 
private Hashtable ExpandedStates 
    get 
    { 
        if (this._expandedState == null
        { 
            _expandedState = this.Session["_expandedState"as Hashtable; 
            if (_expandedState == null
            { 
                _expandedState = new Hashtable(); 
                this.Session["_expandedState"] = _expandedState; 
            } 
        } 
 
        return this._expandedState; 
    } 
 
//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); 
        } 
    } 
 
//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 TaxonomiesRadGrid_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.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 TaxonomiesRadGrid_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) 
        { 
            TaxonomiesRadGrid.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) 
        { 
            TaxonomiesRadGrid.Items[key].Selected = true
        } 
    } 
 
protected void grdRebind_Click(object sender, EventArgs e) 
    TaxonomiesRadGrid.Rebind(); 
#endregion 


Iana Tsolova
Telerik team
 answered on 08 Jun 2010
2 answers
152 views
I have a few questions about resizing columns in a radGrid.

1.  When I have EnableRealTimeResize=true set on my grid, a pop up appears saying the width in pixels of the column when it is being resized.  Ideally, I'd like to show this width as a % rather than a pixel width....is this possible?  If not, can I suppress this pop up?

2.  I need to change data in the grid when a column is resized.....what is the best way to go about this?  I don't see a server event that helps me.

Thanks!
Tsvetina
Telerik team
 answered on 08 Jun 2010
2 answers
109 views
Hello.I suppose i have done something to the configuration because i don't get the correct output from something like
<ul>
    <li>tt
    </li>
</ul>
I don't see the bullet.
Any ideas?


tasos
Top achievements
Rank 1
 answered on 08 Jun 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?