Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
99 views
Hello good people,

I'm having a problem with a ajaxfied grid on ASP.NET, I'm able to populate the grid first time on Page Load (without ajax), and then again using the form to filter the records displayed on page (this WITH ajax), the grid IS populated, but then all controls on page stops responding.

Target framework .net 4.5

Any advice will help.

Code is posted here below.

Thanks in advance!

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DashboardContabilidade.aspx.cs" Inherits="GaragemMaintenance.DashboardContabilidade" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%--<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>--%>
 
<!DOCTYPE html>
<head id="Head1" runat="server">
<title>Dashboard Estapar</title>
<script src="Scripts/jquery-2.0.3.js"></script>
<%--<script src="Scripts/jquery-ui-1.10.3.js"></script>--%>
<%--<link href="Content/themes/base/jquery-ui.css"  rel="stylesheet" type="text/css"/>--%>
<%--<link type="text/css" rel="stylesheet" href="Content/themes/css/style.css" />--%>
<%--<link rel='stylesheet' type='text/css' href='Styles/StaticHeader.css' />--%>
<style>
.hidden
{
    display: none;
}
 
body
{
    /*background: #FFF;
    color: #000;*/
    font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
    /*margin: 10px;*/
    padding: 0;
}
 
td
{
    font: normal normal 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
}
 
th
{
    font: normal normal 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
}
 
.ImageButtons
{
    padding-top: 5px;
    padding-right: 5px;
}
</style>
<script>
function onRequestStart(sender, args) {
    if (args.get_eventTarget().indexOf("Export") >= 0) {
        args.set_enableAjax(false);
    }
}
</script>
</head>
<body>
<form id="form1" runat="server" style="background-color: white;">
    <input id="scrollPos" runat="server" type="hidden" value="0" />
    <div>
        <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>
            <Services>
                <asp:ServiceReference Path="DataManager.svc" />
            </Services>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <ClientEvents OnRequestStart="onRequestStart" />
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="radGrdContabil_GridHeader">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlGrid" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="radGrdContabil">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="radGrdContabil" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnFiltrar">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMain" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnExportExcel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnExportExcel" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnExportPdf">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnExportPdf" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnExportWord">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnExportWord" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnExportCsv">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnExportCsv" LoadingPanelID="loadingPanel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server" Height="75px" Width="75px" Transparency="25">
            <img alt="Carregando..." style="border:0;" src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadFormDecorator ID="RadFormDecorator1" DecoratedControls="All" runat="server" Skin="Office2010Silver" EnableRoundedCorners="true" />
        <telerik:RadNotification ID="radNotification" runat="server" EnableRoundedCorners="true" EnableShadow="true" Position="Center" Title="Aviso" Width="400" Height="150"
            Text="A execução desta consulta sem filtro retorna mais linhas do que o ERP consegue exportar, por favor selecione algum outro filtro.">
        </telerik:RadNotification>
        <telerik:RadNotification ID="radNotificationData" runat="server" EnableRoundedCorners="true" Position="Center" Title="Aviso" Width="400" Height="150"
            EnableShadow="true" Text="A execução desta consulta exige ao menos um filtro de data.">
        </telerik:RadNotification>
        <div>
            <asp:Label ID="Label1" runat="server" Text="DashBoard Contabilidade" Font-Bold="True" Font-Size="20pt"></asp:Label>
        </div>
        <telerik:RadAjaxPanel runat="server" ID="pnlMain">
            <div>
                <table style="width: 1100px">
                    <tr>
                        <td>
                            <table class="" style="width: 700px">
                                <tr>
                                    <td colspan="5">
                                        <p></p>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                        <asp:Label ID="Label5" runat="server" Text="Datas:"></asp:Label>
                                    </td>
                                    <td rowspan="8">
                                        <table style="width: 150px; position: relative">
                                            <tr>
                                                <td style="width: 50px">
                                                    <asp:ImageButton runat="server" ID="btnExportExcel" OnClick="btnExportExcel_Click" CssClass="ImageButtons" ImageUrl="~/Images/file-extension-xls-html-icon.png" />
                                                </td>
                                                <td style="width: 50px">
                                                    <asp:ImageButton runat="server" ID="btnExportPdf" OnClick="btnExportPdf_Click" CssClass="ImageButtons" ImageUrl="~/Images/file-extension-pdf-icon.png" />
                                                </td>
                                                <td style="width: 50px">
                                                    <asp:ImageButton runat="server" ID="btnExportWord" OnClick="btnExportWord_Click" CssClass="ImageButtons" ImageUrl="~/Images/file-extension-doc-icon.png" />
                                                </td>
                                                <td style="width: 50px">
                                                    <asp:ImageButton runat="server" ID="btnExportCsv" OnClick="btnExportCsv_Click" CssClass="ImageButtons" ImageUrl="~/Images/file-extension-csv-icon.png" />
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label4" runat="server" Text="Mês De:"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadMonthYearPicker ID="mesDe" runat="server" Culture="pt-BR" DateInput-Culture="pt-BR" DateInput-DateFormat="MM/yyyy"
                                            Skin="Office2010Silver" MonthYearNavigationSettings-TodayButtonCaption="Hoje" Width="95px" />
                                    </td>
                                    <td>
                                        <asp:Label ID="Label6" runat="server" Text="Mês Até:"></asp:Label></td>
                                    <td>
                                        <telerik:RadMonthYearPicker ID="mesAte" runat="server" Culture="pt-BR" DateInput-Culture="pt-BR" DateInput-DateFormat="MM/yyyy"
                                            Skin="Office2010Silver" MonthYearNavigationSettings-TodayButtonCaption="Hoje" Width="95px" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                        <asp:Label ID="Label9" runat="server" Text="Contas:"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label7" runat="server" Text="De:"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlContasDe" runat="server" Font-Size="9px" Font-Names="Verdana" DataTextField="Descricao" DataValueField="CT1_CONTA" Width="300px" />
                                    </td>
                                    <td>
                                        <asp:Label ID="Label8" runat="server" Text="Até:"></asp:Label></td>
                                    <td>
                                        <asp:DropDownList ID="ddlContasAte" runat="server" Font-Size="9px" Font-Names="Verdana" DataTextField="Descricao" DataValueField="CT1_CONTA" Width="300px" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                        <asp:Label ID="Label13" runat="server" Text="Centro de Custo:"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label12" runat="server" Text="De:"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlCentrosDe" runat="server" Font-Size="9px" Font-Names="Verdana" DataTextField="Descricao" DataValueField="CTT_CUSTO" Width="300px" />
                                    </td>
                                    <td>
                                        <asp:Label ID="Label2" runat="server" Text="Até:"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlCentrosAte" runat="server" Font-Size="9px" Font-Names="Verdana" DataTextField="Descricao" DataValueField="CTT_CUSTO" Width="300px" />
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 50px"></td>
                                    <td>
                                        <asp:Button ID="btnFiltrar" runat="server" Text="Filtrar" OnClick="btnFiltrar_Click" />
                                    </td>
                                    <td>
                                        <asp:Button ID="btnLimpar" runat="server" Text="Limpar" OnClick="btnLimpar_Click" />
                                    </td>
                                    <td>
                                        <asp:Button ID="btnMenu" runat="server" Text="Menu" OnClick="btnMenu_Click" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <p></p>
                <telerik:RadGrid ID="radGrdContabil" runat="server" Skin="Office2010Blue" Width="95%" Height="500px" AutoGenerateColumns="True" CellSpacing="0"
                    GridLines="None" AllowPaging="true" ShowHeader="true" Style="margin-left: 20px" ShowStatusBar="true" StatusBarSettings-LoadingText="Carregando"
                    PageSize="200" OnSortCommand="radGrdContabil_SortCommand" OnPageIndexChanged="radGrdContabil_PageIndexChanged"
                    OnPageSizeChanged="radGrdContabil_PageSizeChanged">
                    <ClientSettings>
                        <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" />
                    </ClientSettings>
                    <MasterTableView AutoGenerateColumns="True" EnableColumnsViewState="false" AllowSorting="true">
                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                        <NoRecordsTemplate>
                            <div>Não existem registros para os filtros selecionados!</div>
                        </NoRecordsTemplate>
                    </MasterTableView>
                </telerik:RadGrid>
            </div>
        </telerik:RadAjaxPanel>
    </div>
</form>
</body>
</html>

And the CS File

using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
/* adicionar o namespace para o .NET carregar o método extendido AuthRedirect */
using Estapar.Security;
using Estapar.Security.Web;
 
namespace GaragemMaintenance
{
    public partial class DashboardContabilidade : EstaparPage
    {
        public bool rebind = false;
        private const string sessionDataID = "ContabilData";
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                mesDe.SelectedDate = DateTime.Now;
                mesAte.SelectedDate = DateTime.Now;
 
                ddlContasDe.DataSource = DAO.GetContasCorrentes();
                ddlContasDe.DataBind();
                ddlContasDe.Items.Insert(0, new ListItem("Selecione...", ""));
 
                ddlContasAte.DataSource = DAO.GetContasCorrentes();
                ddlContasAte.DataBind();
                ddlContasAte.Items.Insert(0, new ListItem("Selecione...", ""));
 
                ddlCentrosDe.DataSource = DAO.GetCentroCustos();
                ddlCentrosDe.DataBind();
                ddlCentrosDe.Items.Insert(0, new ListItem("Selecione...", ""));
 
                ddlCentrosAte.DataSource = DAO.GetCentroCustos();
                ddlCentrosAte.DataBind();
                ddlCentrosAte.Items.Insert(0, new ListItem("Selecione...", ""));
 
                FillGrid(false);
            }
        }
 
        private void FillGrid(bool useCache)
        {
            DataTable res = new DataTable();
 
            try
            {
                if (!useCache || Session[sessionDataID] == null)
                {
                    res = DAO.GetDashboardDataContabilCC(mesDe.SelectedDate.Value, mesAte.SelectedDate.Value, ddlContasDe.SelectedValue, ddlContasAte.SelectedValue, ddlCentrosDe.SelectedValue, ddlCentrosAte.SelectedValue);
                    Session[sessionDataID] = res;
                }
                else
                {
                    res = (DataTable)Session[sessionDataID];
                }
 
                radGrdContabil.DataSource = res;
                radGrdContabil.ColumnCreated += radGrdContabil_ColumnCreated;
                radGrdContabil.DataBind();
            }
            catch (Exception Ex)
            {
                radNotification.Show(Ex.Message);
            }
        }
 
        private bool NenhumaData()
        {
            return ((!mesDe.SelectedDate.HasValue) && (!mesAte.SelectedDate.HasValue));
        }
 
        protected void btnFiltrar_Click(object sender, EventArgs e)
        {
            radNotification.Visible = false;
            if (NenhumaData())
            {
                radNotificationData.Show();
                return;
            }
 
            FillGrid(false);
        }
 
        void radGrdContabil_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            var col = e.Column;
 
            if (col.UniqueName == "ExpandColumn")
                e.Column.Visible = false;
 
            if (col.UniqueName == "CONTA")
            {
                col.HeaderStyle.Width = new Unit("60px");
                col.HeaderText = "Conta";
            }
            else if (col.UniqueName == "DESC_CONTA")
            {
                col.HeaderStyle.Width = new Unit("250px");
                col.HeaderText = "Nome Conta";
            }
            else if (col.UniqueName == "CENTRO_CUSTO")
            {
                col.HeaderStyle.Width = new Unit("60px");
                col.HeaderText = "Centro";
            }
            else if (col.UniqueName == "DESC_CC")
            {
                col.HeaderStyle.Width = new Unit("250px");
                col.HeaderText = "Nome Centro";
            }
            else if (col.UniqueName == "TOTAL")
            {
                col.HeaderStyle.Width = new Unit("60px");
                col.HeaderText = "Total";
            }
            else if (col.UniqueName.StartsWith("M"))
            {
                col.HeaderStyle.Width = new Unit("60px");
                col.HeaderText = col.UniqueName.Remove(0, 1).Insert(4, "-");
            }
        }
 
        protected void btnLimpar_Click(object sender, EventArgs e)
        {
            mesDe.SelectedDate = DateTime.Now;
            mesAte.SelectedDate = DateTime.Now;
            ddlContasDe.SelectedIndex = 0;
            ddlContasAte.SelectedIndex = 0;
            ddlCentrosDe.SelectedIndex = 0;
            ddlCentrosAte.SelectedIndex = 0;
        }
 
        private RadGrid PrepareGridToExport()
        {
            rebind = true;
            FillGrid(true);
 
            RadGrid gv = radGrdContabil;
 
            gv.ExportSettings.OpenInNewWindow = true;
            gv.ExportSettings.UseItemStyles = true;
            gv.ExportSettings.ExportOnlyData = true;
            gv.ExportSettings.FileName = "ControleContabil";
            gv.ExportSettings.IgnorePaging = true;
            gv.MasterTableView.AllowPaging = false;              
 
            return gv;
        }
 
        protected void btnExportExcel_Click(object sender, ImageClickEventArgs e)
        {
            RadGrid gv = PrepareGridToExport();
 
            if (gv != null)
            {
                gv.ExportSettings.Excel.Format = GridExcelExportFormat.Biff;
                gv.MasterTableView.ExportToExcel();
            }
        }
 
        protected void btnExportPdf_Click(object sender, ImageClickEventArgs e)
        {
            RadGrid gv = PrepareGridToExport();
            if (gv != null)
            {        
                gv.ExportSettings.Pdf.FontType = Telerik.Web.Apoc.Render.Pdf.FontType.Subset;
                gv.ExportSettings.Pdf.PaperSize = GridPaperSize.Letter;
                gv.ExportSettings.Pdf.PageHeight = Unit.Parse("210mm");
                gv.ExportSettings.Pdf.PageWidth = Unit.Parse("397mm");
                gv.ExportSettings.Pdf.Title = "DashBoard";
                
                gv.MasterTableView.ExportToPdf();
            }
        }
 
        protected void btnExportWord_Click(object sender, ImageClickEventArgs e)
        {
            RadGrid gv = PrepareGridToExport();
             
            if (gv != null)
                gv.MasterTableView.ExportToWord();
        }
 
        protected void btnExportCsv_Click(object sender, ImageClickEventArgs e)
        {
            RadGrid gv = PrepareGridToExport();
             
            if (gv != null)
                gv.MasterTableView.ExportToCSV();
        }
 
        protected void radGrdContabil_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        {
            radGrdContabil.CurrentPageIndex = e.NewPageIndex;
            FillGrid(true);
        }
 
        protected void radGrdContabil_SortCommand(object sender, GridSortCommandEventArgs e)
        {
            //radGrdContabil.MasterTableView.SortExpressions.Add(e.NewSortOrder);
            FillGrid(true);
        }
 
        protected void radGrdContabil_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
        {
            //radGrdContabil.PageSize = e.NewPageSize;
            FillGrid(true);
        }
 
        protected void btnMenu_Click(object sender, EventArgs e)
        {
            Response.AuthRedirect("Menu.aspx", this.UsuarioLogado.UserName);
        }
    }
}
Eyup
Telerik team
 answered on 05 Dec 2013
3 answers
105 views
Is it not possible to have multiple spaces in between words when calling set_text()?
Kate
Telerik team
 answered on 05 Dec 2013
1 answer
108 views
Is there a way to add a pop-up after clicking the Insert link-button in the edit mode of a RadGrid that asks a User if they would like to navigate to a different URL and then takes them there if they say yes?  Would that be pure javascript?

Would it be easier to include a separate link button (IE: Insert, Link, Cancel), and have the Link open in a new window/tab?  If so, how would that be accomplished?

Thanks,
Mark
Shinu
Top achievements
Rank 2
 answered on 05 Dec 2013
1 answer
81 views
hi

is it possible to get an example or some suggestions of how to dynamically/programmatically create a html5 chart with data navigation , assuming that it is possible to do so ?

Peter.
Stamo Gochev
Telerik team
 answered on 05 Dec 2013
3 answers
108 views
Hello Telerik team.

I'm using telerik 2013.3.1114.40 version

Please look at this sample code. it's very simple code.
The problem is, if radgrid set scrolling header.  header column width and data column width are not fit slightly.
I attached screenshots IE and chrome.   please let me know any solutions.
thank you.

sample source link Downloading sample source here click me !!!!!!

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <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>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>
            <telerik:RadGrid ID="RadGridOtherMembersStateList" runat="server" Width="100%"
                OnItemDataBound="RadGridOtherMembersStateList_ItemDataBound">
                <MasterTableView AutoGenerateColumns="false" AllowSorting="false" AllowPaging="false"
                    AllowNaturalSort="false" AllowCustomPaging="false" AllowCustomSorting="false"
                    CommandItemDisplay="None" TableLayout="Auto">
                    <Columns>
                        <telerik:GridHyperLinkColumn HeaderText="State" DataTextField="StateName" UniqueName="StateName"
                            ItemStyle-HorizontalAlign="Left">
                        </telerik:GridHyperLinkColumn>
                        <telerik:GridBoundColumn HeaderText="Count" DataField="StateCount" UniqueName="StateCount"
                            HeaderStyle-Width="100" HeaderStyle-HorizontalAlign="Center"
                            ItemStyle-HorizontalAlign="Right">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <NoRecordsTemplate>
                        <div class="divNoRecordsTemplateLayout">
                            No records found.
                        </div>
                    </NoRecordsTemplate>
                </MasterTableView>
                <ClientSettings>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                </ClientSettings>
            </telerik:RadGrid>
        </div>
    </form>
</body>
</html>
Pavlina
Telerik team
 answered on 05 Dec 2013
5 answers
395 views
Hi,

I have a RadGrid with a TempleColumn and I have some problem exporting the grid to excel, the context is as follow:

The RadGrid is bound from a stored procedure in a data base, no problem here... the real difficult is when I want to export this grid to an Excel format, the grid has a template column and the data from the template never goes to exported excel file (see attachments).
The grid is created programatically and one of the columns is a template column.  The grid needs to be created programatically because the columns returned for the stored procedure are always variable (dynamics) and I need generated a templated column (some merge headers) based on these results.

Any suggestions ??  Thanks in advance to all for your help

This is the code in the .aspx page
 
<asp:Button ID="Button1" runat="server" Text="Exportar a Excel" onclick="Button1_Click" />
<br /><br />
<telerik:RadGrid ID="RadGrid1" runat="server">
</telerik:RadGrid>

//This is the .aspx.cs code
 
protected void Page_Load(object sender, EventArgs e)
    {
if (!IsPostBack)
        {
            ds = obj_concentrador.ALE_ConcentradorLogros_Select("7", "2011", "6", "1", "1");
 
            RadGrid1.DataSource = ds.Tables[0].DefaultView;
            RadGrid1.MasterTableView.DataKeyNames = new string[] { "Alum_Id" };
 
            RadGrid1.ExportSettings.HideStructureColumns = false;
            RadGrid1.ExportSettings.ExportOnlyData = false;
            RadGrid1.ExportSettings.IgnorePaging = true;
            RadGrid1.ExportSettings.OpenInNewWindow = true;
            RadGrid1.ExportSettings.FileName = "Concentrador";
            //RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.Html;
 
            RadGrid1.Width = Unit.Percentage(98);
            RadGrid1.PageSize = 5;
            RadGrid1.AllowPaging = true;
            RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
            RadGrid1.AutoGenerateColumns = false;
            RadGrid1.ShowHeader = true;
            RadGrid1.ShowStatusBar = true;
 
            //Add Customers table
            RadGrid1.MasterTableView.PageSize = 50;
            RadGrid1.MasterTableView.Width = Unit.Percentage(100);
 
            RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
 
            RadGrid1.MasterTableView.CommandItemSettings.ShowExportToWordButton = false;
            RadGrid1.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
            RadGrid1.MasterTableView.CommandItemSettings.ExportToExcelText = "Exportar a Excel";
            RadGrid1.MasterTableView.CommandItemSettings.ShowExportToPdfButton = true;
            RadGrid1.MasterTableView.CommandItemSettings.ExportToPdfText = "Exportar a Pdf";
            RadGrid1.MasterTableView.CommandItemSettings.ShowExportToCsvButton = false;
             
 
            RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
 
            GridBoundColumn boundColumn1;
            boundColumn1 = new GridBoundColumn();
            RadGrid1.MasterTableView.Columns.Add(boundColumn1);
            boundColumn1.DataField = "Alum_Id";
            boundColumn1.HeaderText = "Alum_Id";
            boundColumn1.Visible = false;
 
            GridBoundColumn boundColumn2;
            boundColumn2 = new GridBoundColumn();
            RadGrid1.MasterTableView.Columns.Add(boundColumn2);
            boundColumn2.DataField = "Alum_NomApellidos";
            boundColumn2.HeaderText = "Estudiante";
            boundColumn2.ItemStyle.Width = Unit.Percentage(20);
 
            string templateColumnName = "materiaName";
            string templateColumnLogros = "logrosName";
            GridTemplateColumn templateColum;
            templateColum = new GridTemplateColumn();
             
            RadGrid1.MasterTableView.Columns.Add(templateColum);
            templateColum.ItemStyle.Width = Unit.Percentage(80);
 
            templateColum.ItemTemplate = new MyTemplate(templateColumnName, ds);
            templateColum.HeaderTemplate = new MyTemplate2(templateColumnLogros, ds);
 
            templateColum.UniqueName = "TemplateColumn";
            templateColum.InitializeTemplatesFirst = false;
        }
    }
 
public class MyTemplate : ITemplate
    {
        private string colname;
        protected Label lControl;
        private DataSet ds;
 
        public MyTemplate(string cName, DataSet datos)
        {
            colname = cName;
            ds = datos;
        }
        public void InstantiateIn(System.Web.UI.Control container)
        {
            lControl = new Label();
            lControl.ID = "lControl";
            lControl.DataBinding += new EventHandler(lControl_DataBinding);
 
            container.Controls.Add(lControl);
        }
 
        public void lControl_DataBinding(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            GridDataItem container = (GridDataItem)l.NamingContainer;
             
             
            string sItem = string.Empty;
 
            sItem = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";
 
            float ancho = 80 / (ds.Tables[0].Columns.Count - 2);
 
            for (int i = 2; i < ds.Tables[0].Columns.Count; i++)
            {
                sItem += "<td align='center' style='width:" + ancho.ToString() + "%'>" + ((DataRowView)container.DataItem)[ds.Tables[0].Columns[i].ColumnName].ToString() + "</td>";
            }
 
            sItem += "</tr></table>";
 
            l.Text = sItem;
        }
    }
 
    public class MyTemplate2 : ITemplate
    {
        private DataSet ds;
        private string colname;
        protected Label lControl;
 
 
        public MyTemplate2(string cName, DataSet datos)
        {
            colname = cName;
            ds = datos;
        }
        public void InstantiateIn(System.Web.UI.Control container)
        {
            lControl = new Label();
            lControl.ID = "lControl";
            lControl.DataBinding += new EventHandler(lControl_DataBinding);
 
            container.Controls.Add(lControl);
                         
        }
 
        public void lControl_DataBinding(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            GridHeaderItem container = (GridHeaderItem)l.NamingContainer;
 
 
            string sHeader = string.Empty;
 
            sHeader = "<table id='Table1' width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";
 
            sHeader += "<td colspan='" + (ds.Tables[0].Columns.Count - 2).ToString() + "' align='center'>Nombres de Materias</td></tr><tr>";
 
            float ancho = 80 / (ds.Tables[0].Columns.Count - 2);
 
            for (int i = 2; i < ds.Tables[0].Columns.Count; i++)
            {
                sHeader += "<td align='center' style='width:" + ancho.ToString() + "%'>" + ds.Tables[0].Columns[i].ColumnName + "</td>";
            }
 
            sHeader += "</tr></table>";
 
            l.Text = sHeader;
        }
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.Columns.FindByUniqueName("TemplateColumn").Visible = true;
 
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.ExportSettings.FileName = "Concentrador";
        RadGrid1.MasterTableView.ExportToExcel();
    }
Princy
Top achievements
Rank 2
 answered on 05 Dec 2013
3 answers
219 views
Is there a way to get the client object of rad control withing the div? I have a div with class="extension" I can get hold of div using jquery. Now I want to $find all different radcontrol in that div and modify using client methods.. .. I cannot use if because they are within listview | raddockzone | custom usercontrol | div with class
Princy
Top achievements
Rank 2
 answered on 05 Dec 2013
3 answers
112 views
Is there any way to replace a text box in edit mode with a drop down list?

Thanks,
Mark
Princy
Top achievements
Rank 2
 answered on 05 Dec 2013
6 answers
263 views
Hi Team,


       I'm facing with user control edit form js call to parent page js function and ajax error. I'm try to do the sample like User Control Edit Form. I wrote the js function in user control and attach to button onclientclick. When i click the button on user control error said function is not have. And then i move my js function to default.aspx and click it work. At the same time i put ajax manager on my user control, when i click cancel button it show error "Error: Sys.WebForms.PageRequestManagerServerErrorException: A control with ID 'RadGrid1$ctl00$ctl24$EditFormControl$_radAjManagers' could not be found for the trigger in UpdatePanel 'RadGrid1$ctl00$ctl24$EditFormControl$_lblstatusPanel'." But cancel button is not fire to any ajax event. I did simple rad grid edit form and call to user control. I can't understand what wrong my code.

      So i tried to look live demo sample and i modified code at "C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2011 SP1\Live Demos\Grid\Examples\DataEditing\UserControlEditForm". If i comment this

protected void RadGrid1_PreRender(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.RadGrid1.MasterTableView.Items[1].Edit = true;
                this.RadGrid1.MasterTableView.Rebind();
            }
        }
does not work and same as my sample code.

          I hope someone can help to me this problem.

Sample Code.

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form runat="server" id="mainForm" method="post">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            //Put your JavaScript code here.
            function fnUpdate() {
                alert('Default.aspx');
                return false;
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
     //If i didn't comment this one when i click cancel i got error
      <
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True"
        CssClass="RadGrid" AutoGenerateColumns="False" ShowStatusBar="True" OnNeedDataSource="RadGrid1_NeedDataSource"
        PageSize="10" CellSpacing="0">
        <MasterTableView DataKeyNames="row_id" EditMode="PopUp" HorizontalAlign="Left">
            <CommandItemSettings />
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="row_id" DataType="System.Int32" FilterControlAltText="Filter row_id column"
                    HeaderText="Row" ReadOnly="True" SortExpression="row_id" UniqueName="row_id">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="description" FilterControlAltText="Filter description column"
                    HeaderText="Description" SortExpression="description" UniqueName="description">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="status" DataType="System.Boolean" FilterControlAltText="Filter status column"
                    HeaderText="Status" SortExpression="status" UniqueName="status">
                </telerik:GridCheckBoxColumn>
            </Columns>
            <EditFormSettings UserControlName="control/WebUserControl.ascx" EditFormType="WebUserControl"
                PopUpSettings-Modal="true" CaptionFormatString="Current Editing row no. {0}"
                CaptionDataField="row_id">
                <EditColumn UniqueName="EditCommandColumn">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [row_id], [description], [status] FROM [tbl_sample]"></asp:SqlDataSource>
    </form>
</body>
</html>

Default.cs

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using System.Data.SqlClient;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
 
    private static DataTable GetDataTable(string queryString)
    {
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection MySqlConnection = new SqlConnection(ConnString);
        SqlDataAdapter MySqlDataAdapter = new SqlDataAdapter();
        MySqlDataAdapter.SelectCommand = new SqlCommand(queryString, MySqlConnection);
 
        DataTable myDataTable = new DataTable();
        MySqlConnection.Open();
        try
        {
            MySqlDataAdapter.Fill(myDataTable);
        }
        finally
        {
            MySqlConnection.Close();
        }
 
        return myDataTable;
    }
 
    private DataTable Employees
    {
        get
        {
            object obj = this.Session["_tbl"];
            if ((!(obj == null)))
            {
                return ((DataTable)(obj));
            }
            DataTable myDataTable = new DataTable();
            myDataTable = GetDataTable("SELECT * FROM tbl_sample");
            this.Session["_tbl"] = myDataTable;
            return myDataTable;
        }
    }
 
    protected void RadGrid1_PreRender(object sender, System.EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.RadGrid1.MasterTableView.Items[1].Edit = true;
            this.RadGrid1.MasterTableView.Rebind();
        }
    }
 
    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        this.RadGrid1.DataSource = this.Employees;
        this.Employees.PrimaryKey = new DataColumn[] { this.Employees.Columns["row_id"] };
    }
 
    protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e)
    {       
    }
}

User Control.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"
    Inherits="control_WebUserControl" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript" language="javascript">
        //Put your JavaScript code here.
        function fnUpdate() {
            alert('Control');// should be call this function
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadAjaxManager ID="_radAjManagers" runat="server" OnAjaxRequest="_radAjManager_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="_radAjManagers" EventName="OnAjaxRequest">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="_lblstatus" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
<div>
    <asp:Label runat="server" ID="_lblstatus"></asp:Label>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.Description" ) %>'></asp:TextBox>
    <br />
    <asp:Button ID="btnInsert" Text="Insert" runat="server" OnClientClick="javascript:fnUpdate();return false;">
    </asp:Button>
    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
        CommandName="Cancel"></asp:Button>
</div>

User Control.ascx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
 
public partial class control_WebUserControl : System.Web.UI.UserControl
{
    private object _dataItem = null;
 
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    //protected void Button1_Command(object sender, CommandEventArgs e)
    //{
    //    //
    //}
 
    protected void _radAjManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        _lblstatus.Text = "Done....";
    }
 
    public object DataItem
    {
        get
        {
            return this._dataItem;
        }
        set
        {
            this._dataItem = value;
        }
    }
}

Sample Code Link : Sample
Regards,
Alex
Eric
Top achievements
Rank 1
 answered on 04 Dec 2013
2 answers
153 views
Hello All

I am trying to get the event TreeView1_NodeClick to fire.  When I click to select a single node there is no problem, but when I intend to select multiple nodes by clicking and holding ctrl or shift keys the event won't fire!

Is there any other event similar to achieve this?

Regards
nfigueroa
Top achievements
Rank 1
 answered on 04 Dec 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?