Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
70 views
Hi I am using the RadEditor for SharePoint 2010.

I am using the following html in RadEditor

<style>.maincontent     { color:#fff; padding:30px; width:100%; height:34.444em; margin-top:0;background:url(/Partner-Us/PublishingImages/banner.jpg) no-repeat top left;} </style> <div class="maincontent"> Sample Content  </div>

in my RadEditor i have the following setting

               <radE:RadHtmlField id="PageContent"  FieldName="PublishingPageContent" runat="server" AllowScripts="true" AllowSpecialTags="true">
            </radE:RadHtmlField>

But still it strips the background image. I happens for the javascript also, any solution to overcome this ?
Ianko
Telerik team
 answered on 28 Aug 2014
1 answer
89 views
Hi,

I have a issue in displaying label values when i click on a tab inside a radgrid.
please find the aspx and aspx.cs files

aspx file

<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="233px"
                            Width="475px" >
                            <MasterTableView ShowHeadersWhenNoRecords="true">
                           
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                            <div class="contactWrap">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td>                                                                                                               
                                                           <asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id'></asp:Label>  
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName'></asp:Label>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="LoadTabRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" >
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>


aspx.cs file

protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
           
        string selectedtabindex = e.Tab.Text;
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        switch (selectedtabindex)
        {
            case "Details":
                {
                                        break;
                }
            case "Compartments":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdLoad = (RadGrid)page.FindControl("LoadTabRadGrid");                            
                    List<LoadingDetailEntity> loadingTabListinstance = new List<LoadingDetailEntity>();
                    loadingTabListinstance = loadingDetailManager.GetLoadingDetailListByShipmentId(shipmentID);
                    grdLoad.DataSource = loadingTabListinstance;
                    grdLoad.DataBind();
                  
                    //e.Tab.Controls.Add(grdLoad);
                    break;
                }
            case "Products":
                {
                    break;
                }
        }
    }

What to write in the Case:"details" section to get the required values.please find the attached file.
Princy
Top achievements
Rank 2
 answered on 28 Aug 2014
2 answers
110 views
Hi,
I have a radgrid displayed on the screen.it has some rows.

when i expand each row i need to present with three tabs inside that grid.
once i click on the each tab i need to display another  grid with some other records.How to achieve this.
P,ease find the aspx and aspx.cs code i have written.
the aspx for this
<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="233px"
                            Width="475px" >
                            <MasterTableView ShowHeadersWhenNoRecords="true">
                           
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="LoadTabRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" >
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime">
                                    </telerik:GridBoundColumn>
                                </Columns>
                             <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                              </telerik:RadPageView>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
aspx.cs file
  protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
               
        string selectedtabindex = e.Tab.Text;
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        RadGrid grdLoad=new RadGrid();
       
        switch (selectedtabindex)
        {
            case "Details":
                {
                   
                    break;
                }
            case "Compartments":
                {
                    List<LoadingDetailEntity> loadingTabListinstance = new List<LoadingDetailEntity>();
                    loadingTabListinstance = loadingDetailManager.GetLoadingDetailListByShipmentId(shipmentID);
                    grdLoad.DataSource = loadingTabListinstance;
                    grdLoad.DataBind();
                  
                    e.Tab.Controls.Add(grdLoad);
                    break;
                }
            case "Products":
                {
                    break;
                }
        }
    }

this is what i have written in aspx and aspx.cs files.But i didn't achieved the desired result.

The problem i am facing is that i am not able to get the LoadtabRadgrid control in aspx.cs when i try to bind the data in the  LoadTabStip_TabClick method.
please suggest me the correct way to achieve this reult.
Sudhakar
Top achievements
Rank 1
 answered on 28 Aug 2014
1 answer
199 views
Hello,

I am working on a project with a RadGrid.

My project requirement is that the user can change the order of the columns.
After the user drags a column nothing happens; the order of columns doesn’t change. [See Video]

My code (vb.net): 
RadGrid1.ClientSettings.AllowColumnsReorder = True


How do I solve this?

Thank,
Daniel.
Princy
Top achievements
Rank 2
 answered on 28 Aug 2014
1 answer
270 views
Hi,
I want to change the height of the telerik DropDownlist I changed the CSS as follows :

.RadDropDownList_Default
  {
  height: 35px !important;
  font-size: 16px !important;
  }

.RadDropDownList_Default .rddlFocused
  {
  height: 35px !important;
  font-size: 16px !important;
  }

But the result is not as expected. Please check the screenshot attached for reference.

And the second thing is that I want word wrap to be disabled but the width of the dropdownlist unaffected(means only the string that can be accomadated should be displayed) and the complete string should be displayed when we hover over the list Item.
 
Shinu
Top achievements
Rank 2
 answered on 28 Aug 2014
1 answer
222 views
Hi,

I am using below source code the grid is working very slow. But the data from DB is fetching very fast less then a sec.

Please suggest for a fix! Thanks






<%@ Page Language="VB" MasterPageFile="~/Views/Common/PTRMasterPage.master" AutoEventWireup="false"
    CodeFile="ActivityMaster.aspx.vb" Inherits="Views_Masters_ActivityMaster" Title="Activity Master"
    StylesheetTheme="PetrofacSkin" %>
 
<%@ Register Namespace="PTRCustomClasses" TagPrefix="custom" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script src="../../JScript/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../JScript/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script>
    <script src="../../JScript/jquery.history.js" type="text/javascript"></script>
    <script src="../../JScript/jquery.tooltip.js" type="text/javascript"></script>
    <script src="../../JScript/scriptbreaker-multiple-accordion.js" type="text/javascript"></script>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script language="javascript" type="text/javascript">
            function onRequestStart(sender, args) {
                //debugger;
                if ((args.get_eventTarget().indexOf("ExportToExcel") > 0))
                    args.set_enableAjax(false);
            }
        </script>
        <style type="text/css">
            .AjaxLoading
            {
                background-repeat: no-repeat;
                background-position: center;
            }
        </style>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ddlMethodology">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelStatusLabel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
        Width="75px" Transparency="5">
        <img style="margin-top: 350px;" alt="Loading..." src="../../Images/Telerik Images/Ajax/loading7.gif" />
        <%--    <asp:Image id="Image1" runat="server" style="margin-top: 350px;" ImageUrl="~/Images/Telerik%20Images/Ajax/loading3.gif"  alternatetext ="Loading..."  >
                ImageUrl="~/Ajax/Img/loading1.gif"
  </asp:Image>
        --%>
    </telerik:RadAjaxLoadingPanel>
<%--    <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>--%>
    <div id="divCont01" style="display: block; width: 99%">
        <table cellpadding="0" cellspacing="5">
            <tr>
                <td width="15%">
                    <asp:Label ID="Label5" CssClass="labelStyle" Font-Bold="true" Text="Methodology"
                        runat="server"></asp:Label>
                </td>
                <td width="75%">
                    <asp:DropDownList ID="ddlMethodology" runat="server" AppendDataBoundItems="True"
                        TabIndex="3" CssClass="dropdownStylePTR" AutoPostBack="True">
                    </asp:DropDownList>
                </td>
                <%-- <td width="10%">
                    <asp:Button ID="btnExport2Excel" runat="server" Text="Export Activiites to Excel"
                        CssClass="buttonStyle" Visible="True" />
                    <br />
                </td>--%>
            </tr>
        </table>
    </div>
    <br />
    <telerik:RadAjaxPanel ID="radAjaxMainPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
        ClientEvents-OnRequestStart="onRequestStart">
        <div id="divCont02" style="display: block; width: 99%">
            <table style="width: 100%;">
                <tr>
                    <td style="vertical-align: top; padding-top: 0px; padding-bottom: 0px; padding-left: 0px;
                        border-top-width: 0px;">
                        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
                            Skin="Office2007" AllowFilteringByColumn="True"  ShowStatusBar="false" PageSize="12"
                            Width="95%">
                            <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
                            <MasterTableView BorderWidth="0" DataKeyNames="ACT_ID" EditMode="PopUp" AutoGenerateColumns="False"
                                CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add New Activity">
                                <NoRecordsTemplate>
                                    <div style="width: 300px;">
                                        There are no records to display</div>
                                </NoRecordsTemplate>
                                <CommandItemTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td style="text-align: left; width: 30%">
                                                <img style="border: 0px" alt="" src="../../Images/Telerik%20Images/AddRecord.gif" />
                                                <asp:LinkButton ID="btnAdd" Text="Add New Activity" CommandName="InitInsert" runat="server">
             
                                                </asp:LinkButton>
                                            </td>
                                            <td style="text-align: right;">
                                                <asp:LinkButton runat="server" ID="LinkButton1" Text="Clear Filters" CommandName="ClearFilters" />
                                                <img style="border: 0px" alt="" src="../../Images/Telerik%20Images/Refresh.gif" />
                                                <asp:LinkButton ID="btnRefresh" Text="Refresh" CommandName="Rebind" runat="server">
                                                </asp:LinkButton>
                                                <asp:Image ID="Image1" runat="server" AlternateText="Add" ImageUrl="~/Images/Telerik Images/GridExportToExcel.gif" />
                                                <asp:LinkButton ID="lnkBtnExportToExcel" CssClass="lnkMedium" runat="server" Text="Export to Excel"
                                                    OnClick="btnExport2Excel_Click"></asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </CommandItemTemplate>
                                <Columns>
                                    <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Edit">
                                        <ItemStyle Wrap="false" Width="42px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="42px" />
                                    </telerik:GridButtonColumn>
                                    <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
                                        ConfirmText="Are you sure to Delete the Record?'" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete">
                                        <ItemStyle Wrap="false" Width="55px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="55px" />
                                    </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn DataField="ACT_CODE" HeaderText="Act Code" SortExpression="ACT_CODE"
                                        UniqueName="ACT_CODE" FilterListOptions="VaryByDataType" FilterControlWidth="65%">
                                        <ItemStyle Wrap="false" Width="110px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="110px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ACT_DESC" HeaderText="Act Description" SortExpression="ACT_DESC"
                                        UniqueName="ACT_DESC" FilterListOptions="VaryByDataType" FilterControlWidth="90%">
                                        <ItemStyle Wrap="false" Width="350px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="350px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ACT_WF" DataType="System.Decimal" HeaderText="Act Wt.Factor"
                                        SortExpression="ACT_WF" UniqueName="ACT_WF" FilterListOptions="VaryByDataType"
                                        FilterControlWidth="74%">
                                        <ItemStyle Wrap="false" Width="115px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="115px" />
                                    </telerik:GridBoundColumn>
                                    <custom:rgCustomCol_Filter_Dropdown HeaderText="Department" DataField="DEPT_DESC"
                                        SortExpression="DEPT_DESC" UniqueName="DEPT_DESC_FILTER" HeaderStyle-HorizontalAlign="Center">
                                        <ItemStyle Wrap="false" Width="142px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="142px" />
                                    </custom:rgCustomCol_Filter_Dropdown>
                                    <custom:rgCustomCol_Filter_Dropdown HeaderText="Milestone" DataField="MLSTN_NAME"
                                        SortExpression="MLSTN_NAME" UniqueName="MLSTN_NAME_FILTER">
                                        <ItemStyle Wrap="false" Width="499px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="499px" />
                                    </custom:rgCustomCol_Filter_Dropdown>
                                    <telerik:GridDateTimeColumn DataField="ACT_EARLY_START_DT" HeaderText="Early Start Dt"
                                        SortExpression="ACT_EARLY_START_DT" UniqueName="ACT_EARLY_START_DT" FilterControlWidth="75%"
                                        DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="105px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="105px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="ACT_EARLY_FINISH_DT" DataFormatString="{0:dd/MM/yyyy}"
                                        DataType="System.DateTime" HeaderText="Early Finish Dt" SortExpression="ACT_EARLY_FINISH_DT"
                                        UniqueName="ACT_EARLY_FINISH_DT" FilterListOptions="VaryByDataType" FilterControlWidth="75%"
                                        PickerType="DatePicker">
                                        <ItemStyle Wrap="false" Width="105px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="105px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridBoundColumn DataField="ACT_EARNED_WT" DataType="System.Decimal" HeaderText="Earned Wt"
                                        SortExpression="ACT_EARNED_WT" UniqueName="ACT_EARNED_WT" FilterListOptions="VaryByDataType"
                                        FilterControlWidth="50%">
                                        <ItemStyle Wrap="false" Width="82px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="82px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ACT_PROGRESS_PERC" DataType="System.Decimal"
                                        HeaderText="% Prog." SortExpression="ACT_PROGRESS_PERC" UniqueName="ACT_PROGRESS_PERC"
                                        FilterListOptions="VaryByDataType" FilterControlWidth="50%">
                                        <ItemStyle Wrap="false" Width="65px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="65px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridDateTimeColumn DataField="Start_DT1" HeaderText="Start DT1" SortExpression="Start_DT1"
                                        UniqueName="Start_DT1" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="END_DT1" HeaderText="End DT1" SortExpression="END_DT1"
                                        UniqueName="END_DT1" ItemStyle-Wrap="true" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="Start_DT2" HeaderText="Start DT2" SortExpression="Start_DT2"
                                        UniqueName="Start_DT2" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="END_DT2" HeaderText="End DT2" SortExpression="END_DT2"
                                        UniqueName="END_DT2" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="Start_DT3" HeaderText="Start DT3" SortExpression="Start_DT3"
                                        UniqueName="Start_DT3" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridDateTimeColumn DataField="END_DT3" HeaderText="End DT3" SortExpression="END_DT3"
                                        UniqueName="END_DT3" FilterControlWidth="75%" DataFormatString="{0:dd/MM/yyyy}">
                                        <ItemStyle Wrap="false" Width="78px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="78px" />
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridBoundColumn DataField="WBS_Code" HeaderText="WBS Code" SortExpression="WBS_Code"
                                        UniqueName="WBS_Code" FilterControlWidth="75%">
                                        <ItemStyle Wrap="false" Width="100px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="100px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ServiceMH" HeaderText="ServiceMH" SortExpression="ServiceMH"
                                        UniqueName="ServiceMH" FilterControlWidth="75%">
                                        <ItemStyle Wrap="false" Width="100px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="100px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Budget_Cost" HeaderText="Budget Cost" SortExpression="Budget_Cost"
                                        UniqueName="Budget_Cost" FilterControlWidth="75%">
                                        <ItemStyle Wrap="false" Width="100px" />
                                        <HeaderStyle HorizontalAlign="Left" Wrap="false" Font-Size="8pt" Width="100px" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <EditFormSettings PopUpSettings-Width="48%" EditFormType="Template" ColumnNumber="2"
                                    CaptionDataField="ACT_CODE" EditColumn-HeaderText="Activity Details:" CaptionFormatString="{0}"
                                    PopUpSettings-Modal="true">
                                    <FormTemplate>
                                        <table id="Table1" width="100%" cellspacing="1" cellpadding="1" border="0">
                                            <tr>
                                                <td>
                                                    Activity Code:
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="txtActCode" runat="server" Text='<%# Eval("ACT_CODE") %>' MaxLength="20"
                                                        Width="80" TabIndex="1" CssClass="textboxStyle"> 
                                                    </asp:TextBox>
                                                    <span id="spanrfd1" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtActCode"
                                                        ErrorMessage="Activity Code is required!!" runat="server" Display="Dynamic" Text="*">
                                                    </asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Description:
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="txtActDesc" runat="server" Text='<%# Eval("ACT_DESC") %>' TabIndex="2"
                                                        MaxLength="255" Width="255" CssClass="multitextboxStyle" TextMode="MultiLine"> 
                                                    </asp:TextBox>
                                                    <span id="span1" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtActDesc"
                                                        ErrorMessage="Activity Description is required!!" runat="server" Display="Dynamic"
                                                        Text="*">
                                                    </asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Weight Factor:
                                                </td>
                                                <td>
                                                    <asp:TextBox ID="txtActWf" runat="server" Text='<%# Eval("ACT_WF") %>' MaxLength="9"
                                                        Width="60" TabIndex="3" CssClass="textboxStyle"> 
                                                    </asp:TextBox>
                                                    <span id="span2" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtActWf"
                                                        ErrorMessage="Activity Weight Factor is required!!" runat="server" Display="Dynamic"
                                                        Text="*">
                                                    </asp:RequiredFieldValidator>
                                                    <asp:CompareValidator runat="server" ID="comvali1" ControlToValidate="txtActWf" Type="Double"
                                                        Operator="LessThanEqual" ValueToCompare="999999999" ErrorMessage="Weight Factor Should be a Positive Number & Limited Upto 9 Digits!!"
                                                        Text="Invalid!!" Display="Dynamic"></asp:CompareValidator>
                                                    <asp:CompareValidator runat="server" ID="comvali2" ControlToValidate="txtActWf" Type="Double"
                                                        Operator="GreaterThanEqual" ValueToCompare="0" ErrorMessage="Weight Factor Should be a Positive Number & Limited Upto 9 Digits!!"
                                                        Text="Invalid!!" Display="Dynamic"></asp:CompareValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Department:
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlDept" runat="server" Style="z-index: 1;" SelectedValue='<%# Bind("DEPT_ID") %>'
                                                        AppendDataBoundItems="True" TabIndex="4" CssClass="dropdownStyle">
                                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                                    </asp:DropDownList>
                                                    <span id="span3" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="ddlDept"
                                                        ErrorMessage="Department is required!!" runat="server" Display="Dynamic" Text="*">
                                                    </asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    MileStone:
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlMileStone" runat="server" SelectedValue='<%# Bind("MLSTN_ID") %>'
                                                        AppendDataBoundItems="True" TabIndex="5" CssClass="dropdownStyle">
                                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                                    </asp:DropDownList>
                                                    <span id="span4" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="ddlMileStone"
                                                        ErrorMessage="Milestone is required!!" runat="server" Display="Dynamic" Text="*">
                                                    </asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Early Start Date:
                                                </td>
                                                <td>
                                                    <%--SelectedDate='<%# IIF (TypeOf Container is GridEditFormInsertItem, Now.Today , Eval("ACT_EARLY_START_DT")) %>'--%>
                                                    <telerik:RadDatePicker ID="RdpESdt" runat="server" SelectedDate='<%# IIf(TypeOf Container Is GridEditFormInsertItem, Now.Today, IIf(IsDBNull(Eval("ACT_EARLY_START_DT")), Nothing, Eval("ACT_EARLY_START_DT"))) %>'>
                                                        <DateInput ID="DateInput2" runat="server" TabIndex="6" DateFormat="dd/MM/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                    <%--              <span id="span5" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="RdpESdt"
                                                        ErrorMessage="Early Start Date is required" runat="server" Display="Dynamic"
                                                        Text="*">
                                                    </asp:RequiredFieldValidator>--%>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Early Finish Date:
                                                </td>
                                                <td>
                                                    <telerik:RadDatePicker ID="RdpEFdt" runat="server" TabIndex="7" SelectedDate='<%# IIf(TypeOf Container Is GridEditFormInsertItem, Now.Today, IIf(IsDBNull(Eval("ACT_EARLY_FINISH_DT")), Nothing, Eval("ACT_EARLY_FINISH_DT"))) %>'>
                                                        <DateInput ID="DateInput1" runat="server" DateFormat="dd/MM/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                    <%--      <span id="span6" style="color: red;">*</span>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" ControlToValidate="RdpEFdt"
                                                        ErrorMessage="Early Finish Date is required!!" runat="server" Display="Dynamic"
                                                        Text="*">
                                                    </asp:RequiredFieldValidator>
                                                    <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Early Finish Date Should be More than Early Start Date!!"
                                                        ControlToCompare="RdpESdt" ControlToValidate="RdpEFdt" Operator="GreaterThan"
                                                        Text="Invalid!!" Display="Dynamic"> </asp:CompareValidator>--%>
                                                </td>
                                            </tr>
                                        </table>
                                        <table style="width: 100%">
                                            <tr>
                                                <td style="text-align: center" colspan="2">
                                                    <asp:Button ID="Button1" Text='<%# IIF (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>'
                                                        runat="server" CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'
                                                        CssClass="gridButtonColStyle"></asp:Button
                                                    <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                                        CssClass="gridButtonColStyle"></asp:Button>
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true"
                                            ShowSummary="false" />
                                    </FormTemplate>
                                    <PopUpSettings Modal="True"></PopUpSettings>
                                </EditFormSettings>
                            </MasterTableView>
                            <HeaderStyle Height="1%" />
                            <ValidationSettings CommandsToValidate="PerformInsert,Update" />
                            <StatusBarSettings LoadingText="Loading... Please wait!" ReadyText="Ready.." />
                            <ExportSettings>
                                <Pdf FontType="Subset" PaperSize="Letter" />
                                <Excel Format="ExcelML" FileExtension=".xls" />
                                <Csv ColumnDelimiter="Colon" RowDelimiter="NewLine" />
                            </ExportSettings>
                            <ClientSettings AllowColumnsReorder="True">
                                <Selecting AllowRowSelect="True" />
                                <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="True" ScrollHeight="250px" />
                         <%--       <Resizing AllowColumnResize="true" />--%>
                            </ClientSettings>
                            <FilterMenu EnableTheming="True">
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                            </FilterMenu>
                        </telerik:RadGrid>
                    </td>
                </tr>
            </table>
        </div>
    </telerik:RadAjaxPanel>
    <telerik:RadAjaxPanel ID="PanelStatusLabel" runat="server">
    </telerik:RadAjaxPanel>
</asp:Content>
Princy
Top achievements
Rank 2
 answered on 28 Aug 2014
7 answers
1.3K+ views
Hi,

In a page we have RadGrid which contain a usercontrol. Inside usercontrol we have Dropdown.
We are binding dropdown when we are modifying radgrid.

Before updating to 2014.2.618.45 it was working fine.

But now it's giving error.
While debugging found that items are present in the dropdown but findbytext is unable to find the item.

ddlAssign.SelectedValue = ddlAssign.Items.FindByText(Name).Value;


Best Regards,
Damodar
Shinu
Top achievements
Rank 2
 answered on 28 Aug 2014
1 answer
100 views
Hi,
    I have created demo for radgrid filter. if I search in first textbox filter column and press enter then focus of control goes to second textbox filter column. I change the language English to Japanese and selecting input mode hiragana for typing text in filter it works in Firefox but not working in Internet Explorer. I have attached gif file for this problem.
    Please provide solution for it.

.aspx page code are as follows
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<telerik:RadCodeBlock runat="server">
<script type="text/javascript">
function attachFocusEvent() {
$telerik.$(".rgFilterRow").find("input").focus(function (e, f) {
var cellIndex = e.target.parentNode.cellIndex;

var columnsUniqueName = $find("<%= RadGrid1.ClientID %>").get_masterTableView().get_columns()[cellIndex]._data.UniqueName;
$get("<%= HiddenField1.ClientID %>").value = columnsUniqueName;

});
}
</script>
<script type="text/javascript">

var donePostback = false;
function Grid(sender, args) {
try {
var grd_view = document.getElementById('ctl00_MainContent_RadGrid1');
var grd_col = grd_view.children[0].children[0]; // grid colgroup
var grd_head = grd_view.children[0].children[1]; // grid header
var grd_rows = grd_view.children[0].children[2]; // grid body

// setting grouped column header names
if (grd_head.rows[0].cells[0].textContent == undefined) {
grd_head.rows[0].cells[3].innerText = "Group Building Name";
}
else {
grd_head.rows[0].cells[3].textContent = "Group Building Name";

}
grd_col.children[0].setAttribute("style", "width:0px ");
grd_col.children[1].setAttribute("style", "width:0px ");
grd_col.children[2].setAttribute("style", "width:0px ");

if (!donePostback) {

donePostback = true;
// setting width of grouped columns
grd_col.children[2].setAttribute("style", "width:0px ");
grd_col.children[3].setAttribute("style", "width:200px ");
grd_col.children[6].setAttribute("style", "width:100px ");
try {
var grid = $find("<%= RadGrid1.ClientID %>");
var columns = grid.get_masterTableView().get_columns();
for (var i = 0; i < columns.length; i++) {
columns[i].set_resizable(true);
}
} catch (e) {
}
}
grd_col.children[7].setAttribute("style", "width:0px !important;");

for (var r = 0; r < grd_head.rows.length; r++) {
var row = grd_head.rows[r];
if (row.className == "rgFilterRow") {

// Filter Change (Change)
row.cells[3].innerHTML = row.cells[7].innerHTML;
row.cells[7].innerHTML = "";
}
}
for (var r = 0; r < grd_rows.rows.length; r++) {

var row = grd_rows.rows[r];
if (row.className == "rgGroupHeader") {
row.setAttribute("class", "rgRow RowStyle");
row.setAttribute("style", "color: Black; background-color: White;");

var cells_count = row.cells.length - 1;

row.cells[cells_count].removeAttribute("colspan");

var cell_length = grd_head.rows[0].cells.length;

for (var col = cells_count + 1; col < cell_length; col++) {

row.insertCell(col);
}
if (row.cells[0].textContent == undefined) {
var group_name = row.cells[cells_count].children[0].innerText.split(',&*KeyToDivide,')[0];
var coloman_name = row.cells[cells_count].children[0].innerText.split(',&*KeyToDivide,')[1];
var case_count = row.cells[cells_count].children[0].innerText.split(',&*KeyToDivide,')[2];
row.cells[cells_count].innerText = "";
var span_grp_name = document.createElement("span");
span_grp_name.innerText = group_name;
row.cells[cells_count - 1].appendChild(span_grp_name);

try {
if (coloman_name == "SortOrder") {
grd_rows.rows[r].setAttribute("style", "display:none !important;");
}
} catch (e) {

}
}
else {
var group_name = row.cells[cells_count].children[0].textContent.split(',&*KeyToDivide,')[0];
var coloman_name = row.cells[cells_count].children[0].textContent.split(',&*KeyToDivide,')[1];
var case_count = row.cells[cells_count].children[0].textContent.split(',&*KeyToDivide,')[2];
row.cells[cells_count].textContent = "";
var span_grp_name = document.createElement("span");
span_grp_name.textContent = group_name;
row.cells[cells_count - 1].appendChild(span_grp_name);
try {
if (coloman_name == "SortOrder") {
grd_rows.rows[r].setAttribute("style", "display:none !important;");
}
} catch (e) {

}
}
}
var cell_noc = row.cells[2].cloneNode(true);
row.deleteCell(2);
row.insertCell(0);
row.replaceChild(cell_noc, row.cells[0]);

var cell_noc = row.cells[3].cloneNode(true);
row.deleteCell(3);
row.insertCell(1);
row.replaceChild(cell_noc, row.cells[1]);

for (var c = 0; c < row.cells.length - 1; c++) {
var col = row.cells[c];
col.removeAttribute("class");
}
}
}
catch (e) {
}
}

</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
<asp:HiddenField runat="server" ID="HiddenField1" />
<telerik:RadGrid runat="server" ID="RadGrid1" AllowSorting="true" AllowPaging="true"
AutoGenerateColumns="false" AllowFilteringByColumn="true">
<GroupingSettings CaseSensitive="false" GroupContinuedFormatString="" GroupContinuesFormatString=""
GroupSplitDisplayFormat="" GroupSplitFormat="{0}" />
<ClientSettings AllowExpandCollapse="True" AllowDragToGroup="False" AllowColumnsReorder="False">
<Selecting AllowRowSelect="True" UseClientSelectColumnOnly="True" />
<Resizing AllowColumnResize="true" />
<ClientEvents OnGridCreated="Grid" OnCellSelected="attachFocusEvent" />
</ClientSettings>
<MasterTableView>
<GroupHeaderTemplate>
<asp:Label runat="server" ID="Label10" Text='<%# ""+ (((GridGroupHeaderItem)Container).AggregatesValues["BuildingSortOrderName"]) + ",&*KeyToDivide,SortOrder,&*KeyToDivide,"+ (((GridGroupHeaderItem)Container).AggregatesValues["BuildingSortOrderName"]) %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["BuildingSortOrderName"]) != null)%>'>
</asp:Label>
<asp:Label runat="server" ID="Label5" Text='<%#Server.HtmlEncode(""+ (((GridGroupHeaderItem)Container).AggregatesValues["BuildingName"]) +""+ ",&*KeyToDivide,Building,&*KeyToDivide,"+ (((GridGroupHeaderItem)Container).AggregatesValues["BuildingNameCount"])) %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["BuildingNameCount"]) != null)%>'>
</asp:Label>
<asp:Label ID="lblGroups" Visible="false" Text="" runat="server"></asp:Label>
</GroupHeaderTemplate>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="BuildingSortOrder" FieldAlias="BuildingSortOrderName" />
<telerik:GridGroupByField FieldName="BuildingSortOrder" FieldAlias="BuildingNameCount" />
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="BuildingSortOrder" SortOrder="None" />
</GroupByFields>
</telerik:GridGroupByExpression>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="szBuildingName" FieldAlias="BuildingNameCount"
HeaderText="BuildingName" />
<telerik:GridGroupByField FieldName="szBuildingName" FieldAlias="BuildingName" HeaderText="BuildingName" />
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="szBuildingName" HeaderText="BuildingName" />
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<Columns>
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="1">
<ItemTemplate>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="2">
<ItemTemplate>
</ItemTemplate>
<HeaderStyle Width="200px" />
</telerik:GridTemplateColumn>
<telerik:GridClientSelectColumn UniqueName="d" Groupable="false">
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField="Id" FilterControlAltText="Filter column column"
HeaderText="Id" UniqueName="Id" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Building Name" FilterControlWidth="200px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
DataField="szBuildingName" UniqueName="szBuildingName" FilterControlAltText="Filter column1 column">
<ItemTemplate>
<asp:Label ID="lbl_Id" Visible="false" runat="server" Text='<%#Eval("Id") %>'></asp:Label>
<asp:LinkButton ID="LinkButton2" CommandName="EditBuilding" runat="server" Text='<%# HttpUtility.HtmlEncode(Eval("szBuildingName")) %>'></asp:LinkButton>
<asp:Button ID="DownloadPDF" Style="display: none;" runat="server" Width="0px" CommandName="ExportToPdf" />
</ItemTemplate>
<HeaderStyle Width="250px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="Sort Order" FilterControlAltText="Filter column1 column"
HtmlEncode="true" DataField="szSortOrder" UniqueName="szSortOrder" FilterControlWidth="200px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
SortExpression="nSortOrder">
<HeaderStyle Width="100px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Building Name" FilterControlAltText="Filter column1 column"
HtmlEncode="true" DataField="szBuildingName" UniqueName="szBuildingName1" FilterControlWidth="200px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false"
SortExpression="nSortOrder">
<HeaderStyle Width="100px" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings Selecting-AllowRowSelect="true">
</ClientSettings>
</telerik:RadGrid>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel runat="server" Skin="Default" ID="RadAjaxLoadingPanel1">
</telerik:RadAjaxLoadingPanel>
</asp:Content>


and CS file code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
bool shouldFocusInput = false;
bool shouldFocusInputBuildingGroup = false;
bool shouldFocusInputSortOrder = false;
bool shouldFocusInputBuilding = false;

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
RadGrid1.ItemCommand += RadGrid1_ItemCommand;
RadGrid1.PreRender += RadGrid1_PreRender;
}

void RadGrid1_PreRender(object sender, EventArgs e)
{
if (shouldFocusInput)
{
string columnUniqeuName = HiddenField1.Value;

var col = (RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem)[columnUniqeuName];
TextBox tb = (col.Controls[0] as TextBox);
tb.Focus();
}

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "attachFocusEvent", "attachFocusEvent();", true);
if (shouldFocusInputBuildingGroup)
{
var col = (RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem)["szBuildingName1"];
TextBox tb = (col.Controls[0] as TextBox);
tb.Focus();
}
else if (shouldFocusInputSortOrder)
{
var col = (RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem)["szSortOrder"];
TextBox tb = (col.Controls[0] as TextBox);
tb.Focus();
}
else if (shouldFocusInputBuilding && RadGrid1.MasterTableView.AllowFilteringByColumn)
{
var col = (RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0] as GridFilteringItem)["szBuildingName"];
TextBox tb = (col.Controls[0] as TextBox);
tb.Focus();
}
}

void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
if ((e.CommandArgument as Pair).Second.ToString() == "szBuildingName1")
{
shouldFocusInputBuilding = true;
}
else if ((e.CommandArgument as Pair).Second.ToString() == "szBuildingName")
{
shouldFocusInputSortOrder = true;
}
else if ((e.CommandArgument as Pair).Second.ToString() == "szSortOrder")
{
shouldFocusInputBuildingGroup = true;
}
}
}

void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Id");
table.Columns.Add("szSortOrder");
table.Columns.Add("szBuildingName");
table.Columns.Add("BuildingSortOrder");
for (int i = 1; i < 8; i++)
{
table.Rows.Add(i, "szSortOrder" + i.ToString(), "szBuildingName" + i.ToString(),i);
}
RadGrid1.DataSource = table;
}

}


    
Angel Petrov
Telerik team
 answered on 28 Aug 2014
1 answer
112 views
Greetings,

I have a user control with a RadGrid that I am using for data entry.  I used the examples in the following older posts, and it works, but I am experiencing severe performance issues when the grid grows to about 40 lines

http://www.telerik.com/forums/how-to-add-amp-delete-dynamic-rows-in-radgrid
http://www.telerik.com/forums/dynamically-add-new-rows-to-radgrid

Is there a better way to accomplish multi-line data entry?  I am willing to go a different direction or use a different control if necessary.  Here is my current code...

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InputFormFundsBreakdown.ascx.cs"
Inherits="Controls_InputFormFundsBreakdown" %>
<table align="left" cellpadding="5" width="100%">
  <tr>
    <td align="center" colspan="2">
      <h3>
        Funds Breakdown
        <asp:Image ID="imgFundsHelp" runat="server" ImageUrl="~/Images/help.png" />
        <telerik:RadToolTip ID="tipFundsHelp" runat="server" HideEvent="LeaveTargetAndToolTip"
                            Position="TopRight" TargetControlID="imgFundsHelp">
          Help goes here
        </telerik:RadToolTip>
      </h3>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <asp:Label ID="errFundsMessage" runat="server" ForeColor="Red"></asp:Label>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <telerik:RadGrid ID="grdFunds" runat="server" AutoGenerateColumns="False" OnDataBound="grdFunds_DataBound"
                       OnNeedDataSource="grdFunds_NeedDataSource">
        <MasterTableView DataKeyNames="RowNumber" AlternatingItemStyle-BackColor="#DAE2E8">
          <ItemStyle VerticalAlign="Top" />
          <Columns>
            <telerik:GridTemplateColumn HeaderText="Fund Name">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundName" runat="server" MaxLength="100" Width="85px"
                                    Text='<%# Eval("FundName")%>'>
                </telerik:RadTextBox>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Fund Number">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundNumber" runat="server" Width="85px" MaxLength="100"
                                    Text='<%# Eval("FundNumber")%>'>
                  <ClientEvents OnKeyPress="NumericOnly" />
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errFundNumber" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Account">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtAccount" runat="server" Width="85px" MaxLength="100" Text='<%# Eval("Account")%>'>
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errAccount" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Subledger">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtSubledger" runat="server" Width="85px" MaxLength="100"
                                    Text='<%# Eval("Subledger")%>'>
                  <ClientEvents OnKeyPress="NumericOnly" />
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errSubledger" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="T Code">
              <ItemTemplate>
                <asp:HiddenField ID="hdnTCode" runat="server" Value='<%# Eval("TCode")%>' />
                <telerik:RadDropDownList ID="ddlTCode" runat="server" Width="40px">
                  <Items>
                    <telerik:DropDownListItem Value="" Text=" " />
                    <telerik:DropDownListItem Value="W" Text="W" />
                    <telerik:DropDownListItem Value="A" Text="A" />
                  </Items>
                </telerik:RadDropDownList>
                <br />
                <asp:Label ID="errTCode" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Amount">
              <ItemTemplate>
                <telerik:RadNumericTextBox ID="txtFundAmount" runat="server" DataType="System.Decimal"
                                           Width="85px" MaxLength="100" NumberFormat-DecimalDigits="2" Type="Currency" DbValue='<%# Eval("Amount")%>'
                                           IncrementSettings-InterceptMouseWheel="False">
                </telerik:RadNumericTextBox><br />
                <asp:Label ID="errFundAmount" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Memo">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundMemo" runat="server" Width="145px" Text='<%# Eval("Memo")%>'>
                </telerik:RadTextBox>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn>
              <ItemTemplate>
                <telerik:RadButton ID="btnDeleteFundLine" runat="server" Text="Delete" CssClass="classDeleteImage"
                                   HoveredCssClass="classDeleteHoveredImage" PressedCssClass="classDeletePressedImage"
                                   OnCommand="btnDeleteFundLine_Command" CommandArgument='<%# Eval("RowNumber")%>'>
                  <Image EnableImageButton="true" />
                </telerik:RadButton>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
          </Columns>
        </MasterTableView>
      </telerik:RadGrid>
    </td>
  </tr>
  <tr>
    <td colspan="2">
        
    </td>
  </tr>
  <tr>
    <td>
      <telerik:RadNumericTextBox ID="txtNumberOfRows" runat="server" Width="50px" MinValue="1"
                                 ShowSpinButtons="true" DataType="System.Int32" NumberFormat-DecimalDigits="0" Value="1">
      </telerik:RadNumericTextBox>
      <telerik:RadButton ID="btnAddFundRow" runat="server" Font-Bold="True" Icon-PrimaryIconCssClass="rbAdd"
                         Text="Add Rows" OnClick="btnAddFundRow_Click">
      </telerik:RadButton>
    </td>
    <td align="right">
      <asp:Label ID="lblFundsTotal" runat="server" Font-Bold="true"></asp:Label>  
      <telerik:RadButton ID="btnCalculateFunds" runat="server" Font-Bold="True" Text="Calculate"
                         Icon-PrimaryIconUrl="~/Images/calc.jpg" OnClick="btnCalculateFunds_Click">
      </telerik:RadButton>
    </td>
  </tr>
</table>

using System;
using System.Data;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using dsCashTransmittalTableAdapters;
public partial class Controls_InputFormFundsBreakdown : System.Web.UI.UserControl
{
  public DataTable FundsTable
  {
    get;
    private set;
  }
  protected void Page_Load(object sender, EventArgs e)
  {
    if (ViewState["FundsTable"] == null)
    {
      FundsTable = DefineFundsDataTable();
      AddFiveRows();
    }
    else
    {
      FundsTable = (DataTable)ViewState["FundsTable"];
    }
  }
 
  public decimal CalculateTotal()
  {
    decimal totalAmount = 0;
    try
    {
      foreach (GridDataItem item in grdFunds.Items)
      {
        RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
        totalAmount += Convert.ToDecimal(txtFundAmount.Value);
      }
    }
    catch (Exception)
    {
      totalAmount = 0;
    }
    return totalAmount;
  }
 
  public int CountEntries()
  {
    int cnt = 0;
    try
    {
      foreach (GridDataItem item in grdFunds.Items)
      {
        RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
        if (txtFundAmount.Value != 0)
        {
          cnt++;
        }
      }
    }
    catch (Exception)
    {
      cnt = 0;
    }
    return cnt;
  }
 
  public void ResetValidation()
  {
    errFundsMessage.Text = "";
    foreach (GridDataItem item in grdFunds.Items)
    {
      Label errFundNumber = (Label)item.FindControl("errFundNumber");
      errFundNumber.Text = "";
      Label errAccount = (Label)item.FindControl("errAccount");
      errAccount.Text = "";
      Label errSubledger = (Label)item.FindControl("errSubledger");
      errSubledger.Text = "";
      Label errTCode = (Label)item.FindControl("errTCode");
      errTCode.Text = "";
      Label errFundAmount = (Label)item.FindControl("errFundAmount");
      errFundAmount.Text = "";
    }
    ShowCalculatedTotals();
  }
 
  public void ShowCalculatedTotals()
  {
    lblFundsTotal.Text = "Total: " + CalculateTotal().ToString("C");
  }
 
  public bool ValidateForm(bool valid, ref string logMsg, bool twoFundsRequired, bool oneFundRequired)
  {
    bool hasFund = false;
    bool num = false;
    bool acct = false;
    bool tcode = false;
    bool sub = false;
    //bool amt = false;
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      Label errFundNumber = (Label)item.FindControl("errFundNumber");
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      Label errAccount = (Label)item.FindControl("errAccount");
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      Label errSubledger = (Label)item.FindControl("errSubledger");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      Label errTCode = (Label)item.FindControl("errTCode");
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      //Label errFundAmount = (Label)item.FindControl("errFundAmount");
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      if (txtFundAmount.Text == string.Empty)
      {
        txtFundAmount.Value = 0;
      }
      if (txtFundName.Text != string.Empty ||
          txtFundNumber.Text != string.Empty ||
          txtAccount.Text != string.Empty ||
          txtSubledger.Text != string.Empty ||
          ddlTCode.SelectedValue != string.Empty ||
          txtFundAmount.Value != 0 ||
          txtFundMemo.Text != string.Empty)
      {
        if (txtFundAmount.Value == 0)
        {
          //errFundAmount.Text = "Required";
          //amt = true;
          //txtFundAmount.Focus();
          //valid = false;
        }
        else
        {
          hasFund = true;       
          if (txtSubledger.Text != string.Empty && ddlTCode.SelectedValue == string.Empty)
          {
            errTCode.Text = "Required";
            tcode = true;
            ddlTCode.Focus();
            valid = false;
          }
          else if (ddlTCode.SelectedValue != string.Empty && txtSubledger.Text == string.Empty)
          {
            errSubledger.Text = "Required";
            sub = true;
            txtSubledger.Focus();
            valid = false;
          }
          if (txtAccount.Text == string.Empty)
          {
            errAccount.Text = "Required";
            acct = true;
            txtAccount.Focus();
            valid = false;
          }
          if (txtFundNumber.Text == string.Empty)
          {
            errFundNumber.Text = "Required";
            num = true;
            txtFundNumber.Focus();
            valid = false;
          }
        }
      }
    }
    if (!hasFund && oneFundRequired)
    {
      if (twoFundsRequired)
      {
        errFundsMessage.Text = "Enter at least two funds";
        logMsg = "<li><b>At least two Funds</b> is Required</li>" + logMsg;
      }
      else
      {
        errFundsMessage.Text = "Enter at least one fund";
        logMsg = "<li><b>At least one Fund</b> is Required</li>" + logMsg;
      }
 
      grdFunds.Focus();
      valid = false;
    }
    else
    {
      //if (amt)
      //{
      //  logMsg = "<li><b>Fund Amount</b> is Required</li>" + logMsg;
      //}
      if (tcode)
      {
        logMsg = "<li><b>Fund T Code</b> is Required</li>" + logMsg;
      }
      if (sub)
      {
        logMsg = "<li><b>Fund Subledger</b> is Required</li>" + logMsg;
      }
      if (acct)
      {
        logMsg = "<li><b>Fund Account</b> is Required</li>" + logMsg;
      }
      if (num)
      {
        logMsg = "<li><b>Fund Number</b> is Required</li>" + logMsg;
      }
      UpdateFundTableFromGrid();
    }
    return valid;
  }
 
  public void AddGridErrorMessage(string msg)
  {
    errFundsMessage.Text = msg;
  }
 
  public void ResetForm()
  {
    //FundsTable = DefineFundsDataTable();
    //BindFundGrid();
    ShowCalculatedTotals();
  }
 
  public void LoadForm(CTCommonRequests req)
  {
    FundsTable = LoadFundsDataSource(req.GetCTFundsBreakdown());
    AddFiveRows();
    FillFundFields();
    ShowCalculatedTotals();
  }
 
  public void LoadTemplate(int templateID)
  {
    TemplateFunds_vTableAdapter taFund = new TemplateFunds_vTableAdapter();
    FundsTable = LoadFundsTemplateDataSource(taFund.GetDataByTemplateID(templateID));
    AddFiveRows();
    FillFundFields();
    ShowCalculatedTotals();
  }
 
  public void UpdateFundTableFromGrid()
  {
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      if (Convert.ToDecimal(txtFundAmount.Value) != 0)
      {
        DataRow row = FundsTable.NewRow();
        row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
        RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
        row["FundName"] = txtFundName.Text;
        RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
        row["FundNumber"] = txtFundNumber.Text;
        RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
        row["Account"] = txtAccount.Text;
        RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
        row["Subledger"] = txtSubledger.Text;
        RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
        row["TCode"] = ddlTCode.SelectedValue;
        row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
        RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
        row["Memo"] = txtFundMemo.Text;
        FundsTable.Rows.Add(row);
      }
    }
  }
 
  public void UpdateTemplateFundTableFromGrid()
  {
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      if (txtFundName.Text.Trim() != string.Empty ||
          txtFundNumber.Text.Trim() != string.Empty ||
          txtAccount.Text.Trim() != string.Empty ||
          txtSubledger.Text.Trim() != string.Empty ||
          (ddlTCode.SelectedIndex > -1 && ddlTCode.SelectedValue != "") ||
          txtFundMemo.Text.Trim() != string.Empty)
      {
        DataRow row = FundsTable.NewRow();
        row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
        row["FundName"] = txtFundName.Text;
        row["FundNumber"] = txtFundNumber.Text;
        row["Account"] = txtAccount.Text;
        row["Subledger"] = txtSubledger.Text;
        row["TCode"] = ddlTCode.SelectedValue;
        row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
        row["Memo"] = txtFundMemo.Text;
        FundsTable.Rows.Add(row);
      }
    }
  }
 
  protected void grdFunds_DataBound(object sender, EventArgs e)
  {
    ShowCalculatedTotals();
  }
 
  protected void btnAddFundRow_Click(object sender, EventArgs e)
  {
    ResetValidation();
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      DataRow row = FundsTable.NewRow();
      row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      row["FundName"] = txtFundName.Text;
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      row["FundNumber"] = txtFundNumber.Text;
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      row["Account"] = txtAccount.Text;
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      row["Subledger"] = txtSubledger.Text;
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      row["TCode"] = ddlTCode.SelectedValue;
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      row["Memo"] = txtFundMemo.Text;
 
      FundsTable.Rows.Add(row);
    }
    for (int x = 0; x < txtNumberOfRows.Value; x++)
    {
      FundsTable = AddFundsRow(FundsTable);
    }
    grdFunds.Rebind();
    FillFundFields();
  }
 
  protected void btnDeleteFundLine_Command(object sender, CommandEventArgs e)
  {
    int rowNumber = Convert.ToInt32(e.CommandArgument);
    ResetValidation();
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      DataRow row = FundsTable.NewRow();
      row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      row["FundName"] = txtFundName.Text;
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      row["FundNumber"] = txtFundNumber.Text;
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      row["Account"] = txtAccount.Text;
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      row["Subledger"] = txtSubledger.Text;
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      row["TCode"] = ddlTCode.SelectedValue;
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      row["Memo"] = txtFundMemo.Text;
 
      FundsTable.Rows.Add(row);
    }
    FundsTable = DeleteFundsRow(FundsTable, rowNumber);
    //grdFunds.DataSource = FundsTable;
    grdFunds.Rebind();
    //foreach (GridDataItem item in grdFunds.Items)
    //{
    //  HiddenField hdnTCode = (HiddenField)item.FindControl("hdnTCode");
    //  RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
    //  ddlTCode.SelectedValue = hdnTCode.Value;
    //}
    FillFundFields();
  }
 
  protected void btnCalculateFunds_Click(object sender, EventArgs e)
  {
    lblFundsTotal.Text = "Total: " + CalculateTotal().ToString("C");
  }
 
  private void AddFiveRows()
  {
    for (int x = 1; x < 6; x++)
    {
      FundsTable = AddFundsRow(FundsTable);
    }
    //grdFunds.DataSource = FundsTable;
    grdFunds.Rebind();
  }
 
  private DataTable DefineFundsDataTable()
  {
    DataTable dt = new DataTable("FundsBreakdown");
    DataColumn dc = new DataColumn("RowNumber");
    dc.DataType = Type.GetType("System.Int32");
    dt.Columns.Add(dc);
    dc = new DataColumn("FundName");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("FundNumber");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Account");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Subledger");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("TCode");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Amount");
    dc.DataType = Type.GetType("System.Decimal");
    dt.Columns.Add(dc);
    dc = new DataColumn("Memo");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    return dt;
  }
 
  private DataTable AddFundsRow(DataTable dt)
  {
    DataRow row = dt.NewRow();
    row["RowNumber"] = dt.Rows.Count + 1;
    row["FundName"] = "";
    row["FundNumber"] = "";
    row["Account"] = "";
    row["Subledger"] = "";
    row["TCode"] = "";
    row["Amount"] = 0;
    row["Memo"] = "";
    dt.Rows.Add(row);
    return dt;
  }
 
  private DataTable DeleteFundsRow(DataTable dt, int deleteRow)
  {
    DataTable deletedRowTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in dt.Rows)
    {
      if (Convert.ToInt32(sourceRow["RowNumber"]) != deleteRow)
      {
        DataRow row = deletedRowTable.NewRow();
        row["RowNumber"] = deletedRowTable.Rows.Count + 1;
        row["FundName"] = sourceRow["FundName"];
        row["FundNumber"] = sourceRow["FundNumber"];
        row["Account"] = sourceRow["Account"];
        row["Subledger"] = sourceRow["Subledger"];
        row["TCode"] = sourceRow["TCode"];
        row["Amount"] = sourceRow["Amount"];
        row["Memo"] = sourceRow["Memo"];
        deletedRowTable.Rows.Add(row);
      }
    }
    return deletedRowTable;
  }
 
  private DataTable LoadFundsDataSource(DataTable sourceDT)
  {
    DataTable filledDataTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in sourceDT.Rows)
    {
      DataRow row = filledDataTable.NewRow();
      row["RowNumber"] = filledDataTable.Rows.Count + 1;
      row["FundName"] = sourceRow["FundName"];
      row["FundNumber"] = sourceRow["FundNumber"];
      row["Account"] = sourceRow["AccountNumber"];
      row["Subledger"] = sourceRow["Subledger"];
      row["TCode"] = sourceRow["TCode"];
      row["Amount"] = sourceRow["FundAmount"];
      row["Memo"] = sourceRow["FundMemo"];
      filledDataTable.Rows.Add(row);
    }
    return filledDataTable;
  }
 
  private DataTable LoadFundsTemplateDataSource(DataTable sourceDT)
  {
    DataTable filledDataTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in sourceDT.Rows)
    {
      DataRow row = filledDataTable.NewRow();
      row["RowNumber"] = filledDataTable.Rows.Count + 1;
      row["FundName"] = sourceRow["TemplateFundName"];
      row["FundNumber"] = sourceRow["TemplateFundNumber"];
      row["Account"] = sourceRow["TemplateAccountNumber"];
      row["Subledger"] = sourceRow["TemplateSubledger"];
      row["TCode"] = sourceRow["TemplateTCode"];
      row["Amount"] = 0;
      row["Memo"] = sourceRow["TemplateFundMemo"];
      filledDataTable.Rows.Add(row);
    }
    return filledDataTable;
  }
 
  private void FillFundFields()
  {
    foreach (GridDataItem item in grdFunds.Items)
    {
      HiddenField hdnTCode = (HiddenField)item.FindControl("hdnTCode");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      if (hdnTCode.Value == "")
      {
        ddlTCode.SelectedIndex = -1;
      }
      else
      {
        ddlTCode.SelectedValue = hdnTCode.Value;
      }
    }
  }
 
  protected void grdFunds_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
  {
    ViewState["FundsTable"] = FundsTable;
    grdFunds.DataSource = FundsTable;
  }
}

Any suggestions for improvement would be greatly appreciated!

Matt
Princy
Top achievements
Rank 2
 answered on 28 Aug 2014
1 answer
135 views
Hello,

I have a grid and I can click on the left arrow to expand the nested grid within. If I have a nested grid expanded then I click on a column header to sort the grid then every row will become collapsed. If I set HierarchyDefaultExpanded to true then if I collapse a nested grid then try to sort, then all of my nested grids will go back to expanded. I tried setting RetainExpandStateOnRebind to true but that doesn't help in this scenario.

How would I be able to retain expanded state when I click on a column header to sort items?


Thank you,

Brett
Princy
Top achievements
Rank 2
 answered on 28 Aug 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?