Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
140 views

Requirements

RadControls version

2008.03.1314.20
.NET version

2.0
Visual Studio version

VS 2005
programming language C#
browser support

all browsers supported by RadControls


PROJECT DESCRIPTION
This project illustrates how to export grouped data. The Export button in the group header will export only the current group. The trick behind this is to  loop through all the grouped header  items  and their children and hide the items  which do not have  the same Group index as the clicked one. As a result, the current group is exported.

CS:
using System; 
using System.Data; 
using System.Configuration; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using Telerik.Web.UI; 
 
public partial class _Default : System.Web.UI.Page  
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
         if (e.Item is GridGroupHeaderItem)  
         { 
           GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; 
            LinkButton lnk = new LinkButton(); 
            lnk.ID = "lnkReservations"; 
             lnk.Text = "ExportGroup"; 
             lnk.Command += lnkReservations_Command;  
             item.DataCell.Controls.Add(lnk); 
     } 
      
    } 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
         if (e.Item is GridGroupHeaderItem) 
         { 
         GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; 
         LinkButton lnk = new LinkButton(); 
         lnk.ID = "lnkReservations"; 
         lnk.Text = "ExportGroup"; 
         item.DataCell.Controls.Add(lnk); 
       } 
    } 
  private void lnkReservations_Command(object sender, CommandEventArgs e) 
  { 
     LinkButton lnkReservations = (LinkButton)sender; 
     GridGroupHeaderItem currentHeaderitm = (GridGroupHeaderItem)lnkReservations.NamingContainer; 
     foreach (GridGroupHeaderItem headerItem in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
     { 
         if (headerItem.GroupIndex != currentHeaderitm.GroupIndex) 
         { 
             GridItem[] children = headerItem.GetChildItems(); 
             foreach (GridItem child in children)  
             { 
                 GridDataItem dataItem = child as GridDataItem; 
                 dataItem.Visible = false; 
             } 
             headerItem.Visible = false; 
         } 
     } 
     RadGrid1.ExportSettings.OpenInNewWindow = true; 
     RadGrid1.ExportSettings.ExportOnlyData = true; 
     RadGrid1.MasterTableView.ExportToPdf(); 
  } 
} 

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <div> 
            <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Hay" DataSourceID="SqlDataSource1" GridLines="None" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"> 
                <HeaderContextMenu> 
                    <CollapseAnimation Duration="200" Type="OutQuint" /> 
                </HeaderContextMenu> 
                <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1"> 
                     <GroupByExpressions> 
                       <telerik:GridGroupByExpression> 
                         <GroupByFields> 
                           <telerik:GridGroupByField FieldName="Country" FieldAlias="Country"  /> 
                         </GroupByFields> 
                         <SelectFields> 
                          <telerik:GridGroupByField  FieldName="Country" FieldAlias="Country" /> 
                         </SelectFields> 
                       </telerik:GridGroupByExpression> 
                     </GroupByExpressions> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" 
                            UniqueName="City"> 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="EmployeeID" DataType="System.Int32" HeaderText="EmployeeID" 
                            SortExpression="EmployeeID" UniqueName="EmployeeID"> 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName" 
                            UniqueName="LastName"> 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" 
                            UniqueName="FirstName"> 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country" 
                            UniqueName="Country"> 
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
                <FilterMenu> 
                    <CollapseAnimation Duration="200" Type="OutQuint" /> 
                </FilterMenu> 
            </telerik:RadGrid> 
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" 
                SelectCommand="SELECT [City], [EmployeeID], [LastName], [FirstName], [Country] FROM [Employees]"> 
            </asp:SqlDataSource> 
        </div> 
    </form> 
</body> 
</html> 
 


Yavor
Telerik team
 answered on 09 Mar 2009
1 answer
199 views
Hi
I am Working on Rad Grid
I am bale to caluclate the numarical(int) values totals in footter 
BUT Problem araised in Money Datatype Coloumn
When i trying to caluclate the total for money datatype coloumn
It is dispalying the  all coloumn values in footter(not the SUM Values)
Plz help out to solve the problem
Thanks in advance

here is my C# Code

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

namespace ajaxKrunchBox
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

    
        protected void Button1_Click(object sender, EventArgs e)
        {

            Session["weekend"] = TextBox1.Text;
            Session["status"] = DropDownList4.Text;
            SqlCommand cmd = new SqlCommand("usp_CustomerPerformance_V2", new SqlConnection("Data Source=vijay;Initial Catalog=ULTIMATE_NEW;Integrated Security=True"));
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Customer", DropDownList1.Text));
            cmd.Parameters.Add(new SqlParameter("@WeekEnding", TextBox1.Text));
            cmd.Parameters.Add(new SqlParameter("@Status", DropDownList4.Text));
            cmd.Parameters.Add(new SqlParameter("@noOfWks", DropDownList3.Text));
            cmd.Connection.Open();
            RadGrid1.DataSourceID = null;
            RadGrid1.DataSource = cmd.ExecuteReader();
            //Session["variable1"] = DropDownList1.Text;
            Session["varibale2"] = TextBox1.Text;
            Session["varibale4"] = DropDownList4;
            Session["varibale3"] = DropDownList3;
            RadGrid1.DataBind();
            RadGrid1.Visible = true;
           
          
            cmd.Connection.Close();
            cmd.Connection.Dispose();
          
        }

        int total1;
        int total2;
        int total3;
        int total4;
        int total5;
        int total6;
        String  total7;
        String total8;
        int total9;
        int total10;
         protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                int fieldValue1 = int.Parse(dataItem["TYWkSales"].Text);
                total1 += fieldValue1;
                int fieldvalue2 = int.Parse(dataItem["LYWkSales"].Text);
                total2 += fieldvalue2;
                int fieldvalue3 = int.Parse(dataItem["TYL4WkSales"].Text);
                total3 += fieldvalue3;
                int fieldvalue4 = int.Parse(dataItem["LYL4WkSales"].Text);
                total4 += fieldvalue4;
                //int fieldvalue5 = int.Parse(dataItem["TYWkRRP"].Text);
                //total5 += fieldvalue5;
                //int fieldvalue6 = int.Parse(dataItem["LYWkRRP"].Text);
                //total6 += fieldvalue6;
                String fieldvalue7 = String.Format(dataItem["TYL4WkRRP"].Text);
                total7 += fieldvalue7;
                mydatatable
                //String fieldvalue8 = String.Format(dataItem["LYL4WkRRP"].Text);
                //total8 += fieldvalue8;
               
                int fieldvalue9 = int.Parse(dataItem["TYWkSOH"].Text);
                total9 += fieldvalue9;
                int fieldvalue10 = int.Parse(dataItem["LYWkSOH"].Text);
                total10 += fieldvalue10;
              
            }
            if (e.Item is GridFooterItem)
            {
                GridFooterItem footerItem = e.Item as GridFooterItem;
                footerItem["TYWkSales"].Text = "Total Units: " + total1.ToString();
                footerItem["LYWkSales"].Text = "Total Units: " + total2.ToString();
                footerItem["TYL4WkSales"].Text = "Total Units: " + total3.ToString();
                footerItem["LYL4WkSales"].Text = "Total Units: " + total4.ToString();
                //footerItem["TYWkRRP"].Text = "Total Price: " + total5.ToString();
                //footerItem["LYWkRRP"].Text = "Total Price: " + total6.ToString();
                footerItem["TYL4WkRRP"].Text = "Total Price: " + total7;
                footerItem["LYL4WkRRP"].Text = "Total Price: " + total8;
                footerItem["TYWkSOH"].Text = "Total Units: " + total9.ToString();
                footerItem["LYWkSOH"].Text = "Total Units: " + total10.ToString();
            }

           

            }
      
       

      

      

    }
}

Yavor
Telerik team
 answered on 09 Mar 2009
2 answers
65 views
Hi

I am working on hierarchy Grid where I am having Master table and 4 DetailTables. I am getting plus-minus image at Mastertable level only but not getting that at DetailTable level.

Please suggest how to get that all detailTable level.

Thanks
Pradip
pradip
Top achievements
Rank 1
 answered on 09 Mar 2009
1 answer
105 views
i have a database with 2 date columns one is starting date and one is ending date plus other fields...i linked them to the table but it didnt work the scheduler is always empty... here is my code

<telerik:RadScheduler ID="RadScheduler1" runat="server" 
        DataEndField="Installariondate" DataKeyField="Sales_Order" 
        DataRecurrenceField="Status" DataRecurrenceParentKeyField="Sales_Order" 
        DataSourceID="SqlDataSource2" DataStartField="Requireddate" 
        DataSubjectField="Nodecode" HoursPanelTimeFormat="htt" Skin="Office2007" 
        style="top: -1px; left: 1px" ValidationGroup="RadScheduler1" SelectedView="WeekView"  >
        <ResourceTypes ><telerik:ResourceType DataSourceID="sqldatasource2" KeyField="Sales_Order"  Name="Nodecode" TextField="Status" ForeignKeyField="Sales_Order"/></ResourceTypes>
        
        
    </telerik:RadScheduler>
did i do any thing wrong?? help
Peter
Telerik team
 answered on 09 Mar 2009
2 answers
615 views
I need to create a way for users to 'bulk edit' data in a datagrid, for example changing the AssignedTo value of every row in the datagrid (or at least every row where a checkbox is checked) at once. Here is how I was hoping to do it but I am not sure how.

The user has a grid full of data.
The first column is checkboxes.
The user checks the rows he wants to update

In the first row there would be a field that would correspond to the data in that column. For example there is an AssignedTo column. At the top of that column would be a combobox which the user would choose a name from and then hit a button and it would update all of the rows that were checked. If I can't put the edit controls in the first row of the grid I would be happy to put them outside of the grid as well.

I haven't found any examples of this. Could someone let me know if this is feasible and how I might go about it.

Thanks,
Blake
Blake
Top achievements
Rank 1
 answered on 09 Mar 2009
1 answer
128 views
Hi Everyone,

I have a master and detail table, and in my master table, I've positioned my edit/delete buttons all the way to the right.

How do I do the same thing in the detail table?

Thanks!
Daniel
Telerik team
 answered on 09 Mar 2009
1 answer
101 views
I have a RadAjaxManager setup to update a RadGrid with a FormTemplate.  The RadGrid enters edit mode just fine with the expected ajax  behavior but once the FormTemplate content is loaded, there is a Javascript error and none of the buttons in the FormTemplate work.  I used Firebox/Firebug to see it: "Node cannot be inserted at the specified point."  I've followed a similar post which recommends setting EnablePageHeadUpdate to false and tried that but although that does away with the error, the result is that the buttons now don't do anything.  My setup includes 1 level of nested master pages and the controls are placed in a page that inherits from the nested master page.  I'm not doing anything funky beside the setup on the sample Form Template RadGrid on this site.

Source: http://www.telerik.com/community/forums/aspnet/general-discussions/firefox-and-node-cannot-be-inserted-a-the-specified-point.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx
Iana Tsolova
Telerik team
 answered on 09 Mar 2009
4 answers
501 views
How do I remove the Top and Bottom padding to make the rows tighter in my grid. I keep seeing references to "overflow:hidden" but can't find the property.

I am using VB to create the grid with V 2008.3.1125.35

Thanks,

Rob
Rob Diamant
Top achievements
Rank 1
 answered on 09 Mar 2009
3 answers
127 views

Hi,

We are testing the grid connecting to a table with a million of records. We are using paging but it take time to load the next page. We do not want to use LINQ. How can we speed up this operation?

Thanks

Sebastian
Telerik team
 answered on 09 Mar 2009
7 answers
280 views
Hello,

RadGrid is loosing sizing set by users when paging.
Thanks for a way to keep it until it is corrected.

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