Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
115 views
In RadGrid i was using GridTemplateColumn, inside that i was using link button. While exporting to excel, only those column values are not exported to the grid.
This is my code
.aspx
<telerik:RadGrid ID="RadGrid_Invbystatus" runat="server" AllowPaging="True" AllowSorting="True"
                        GridLines="Both" EnableLinqExpressions="false" Width="95%" AutoGenerateEditColumn="false"
                        AutoGenerateColumns="False" OnPageIndexChanged="RadGrid_Invbystatus_PageIndexChanged"
                        Visible="false" OnExcelExportCellFormatting="RadGrid_Invbystatus_ExportCellFormatting"
                        GroupHeaderItemStyle-HorizontalAlign="Left">
                        <PagerStyle Mode="NextPrevAndNumeric" />
                        <HeaderStyle BorderStyle="Solid" Font-Bold="true" HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Left" Font-Underline="false" />
                        <AlternatingItemStyle HorizontalAlign="Left" Font-Underline="false" />
                        <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                        </ExportSettings>
                        <MasterTableView AllowPaging="true" CommandItemDisplay="Top" GridLines="Both" ShowGroupFooter="true">
                            <GroupByExpressions>
                                <telerik:GridGroupByExpression>
                                    <SelectFields>
                                        <telerik:GridGroupByField FieldAlias="STATUS" FieldName="STATUS" HeaderText="Status">
                                        </telerik:GridGroupByField>
                                    </SelectFields>
                                    <GroupByFields>
                                        <telerik:GridGroupByField FieldName="STATUS" HeaderText="Status"></telerik:GridGroupByField>
                                    </GroupByFields>
                                </telerik:GridGroupByExpression>
                            </GroupByExpressions>
                            <CommandItemSettings ShowExportToPdfButton="true" ShowExportToWordButton="true" ShowExportToExcelButton="true"
                                ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToCsvButton="false" />
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Product" UniqueName="Product" DataField="PROD_ID"
                                    ItemStyle-HorizontalAlign="Left" SortExpression="PROD_ID">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkprodNum" runat="server" OnClick="lnkprodNum_Click" ForeColor="DarkBlue"
                                            Text='<%# DataBinder.Eval (Container.DataItem, "PRODUCT_CODE") %>' ValidationGroup='<%# DataBinder.Eval (Container.DataItem, "PROD_ID") %>'>
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn HeaderText="Description" UniqueName="Description" DataField="PROD_DESC"
                                    ItemStyle-HorizontalAlign="Left">
                                    <ItemStyle Width="15%" />
                                    <HeaderStyle Width="15%" />
                                </telerik:GridBoundColumn>
                                <telerik:GridCalculatedColumn HeaderText="Qty" UniqueName="qty" ItemStyle-HorizontalAlign="Right"
                                    DataFields="QTTY, PACKSHORT_DESC" Expression='{0}+ " " +{1}'>
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridCalculatedColumn>
                                <telerik:GridBoundColumn HeaderText="Lot" UniqueName="lot" DataField="LOT_CODE" ItemStyle-HorizontalAlign="Left">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridBoundColumn>
                                <telerik:GridDateTimeColumn DataType="System.DateTime" HeaderText="Exp. Date" UniqueName="expDate"
                                    ItemStyle-HorizontalAlign="Left" DataField="EXP_DT" DataFormatString="<%$Appsettings:dateformat%>">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridDateTimeColumn>
                                <telerik:GridDateTimeColumn DataType="System.DateTime" HeaderText="Received" UniqueName="recvDate"
                                    ItemStyle-HorizontalAlign="Left" DataField="RECV_DATE" DataFormatString="<%$Appsettings:dateformat%>">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridDateTimeColumn>
                                <telerik:GridTemplateColumn HeaderText="Order No." UniqueName="Order_No." DataField="ORDER_NO"
                                    ItemStyle-HorizontalAlign="Left" SortExpression="ORDER_NO">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkOrdNum" runat="server" OnClick="lnkrefNum_Click" ForeColor="DarkBlue"
                                            CommandArgument='<%# DataBinder.Eval (Container.DataItem, "ORDER_NO2") %>' Text='<%# DataBinder.Eval (Container.DataItem, "ORDER_NO") %>'
                                            ValidationGroup='<%# DataBinder.Eval (Container.DataItem, "SRORDER_ID") %>'>
                                        </asp:LinkButton>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn HeaderText="Reference No" UniqueName="Reference_No" DataField="ORDER_NO2"
                                    ItemStyle-HorizontalAlign="Left">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="Warehouse" UniqueName="Warehouse" ItemStyle-HorizontalAlign="Left"
                                    DataField="WAREHOUSE_CODE">
                                    <ItemStyle Width="10%" />
                                    <HeaderStyle Width="10%" />
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
.cs
protected void RadGrid_InvAdjus_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName ||
                e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName ||
                e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
            {
                ConfigureFilter();
            }
            else if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToPdfCommandName)
            {                
                filter = "Owner:" + ddlOwner.SelectedItem.Text + "Warehouse:" + ddlwarehouse.SelectedItem.Text;
                if (!string.IsNullOrEmpty(txtSupplier.Text))
                {
                    filter += "Supplier:" + txtSupplier.Text + "Supplier Description:" + txtsupplierdesc.Text;
                }
                if (!string.IsNullOrEmpty(txtproductcode.Text))
                {
                    filter += "Product Code:" + txtproductcode.Text + "Product Description:" + txtproddesc.Text;
                }
                filter += "Product Type:" + ddlprodtype.SelectedItem.Text + "Start Date:" + rdpStartDate.SelectedDate + "End Date:" + rdpEndDate.SelectedDate;
                //RadGrid_InvAdjus.MasterTableView.Caption = filter;
                RadGrid_InvAdjus.ExportSettings.Pdf.PageTitle = filter;
            }

         
        }

        protected void RadGrid_InvAdjus_ExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e)
        {
            GridDataItem item = e.Cell.Parent as GridDataItem;

            if (e.FormattedColumn.UniqueName == "Date")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Product")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Description")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "qty")
            {
                e.Cell.Style["text-align"] = "right";
            }
            if (e.FormattedColumn.UniqueName == "lot")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Order_No")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Reference_No")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Warehouse")
            {
                e.Cell.Style["text-align"] = "left";
            }
            if (e.FormattedColumn.UniqueName == "Template1")
            {
                e.Cell.Style["text-align"] = "left";

            }

            GridHeaderItem HeaderItem = (GridHeaderItem)RadGrid_InvAdjus.MasterTableView.GetItems(GridItemType.Header)[0];
            foreach (TableCell cell in HeaderItem.Cells)
            {
                cell.Style["text-align"] = "left";
                cell.Style["color"] = "#ff0000";
                cell.Style["border"] = "thin solid black";
                cell.Style["background-color"] = "#cccccc";
                cell.Style["font-weight"] = "normal";               
            }  
        }

Add My excel will be like this(Product column is empty, and i want to left align the caption part)




Nithya Rani
Top achievements
Rank 1
 answered on 10 Jan 2012
1 answer
177 views
I am using a RAD Grid and I want to span column and rows in header..... how it can be possible??????
Shinu
Top achievements
Rank 2
 answered on 10 Jan 2012
1 answer
96 views
Issue with radgrid, it doesnt time while loading locally but in webserver it takes too long to load

here is the code

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="HotelGrid" />
            </UpdatedControls>
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="AirlineGrid" />
            </UpdatedControls>
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ServiceGrid" />
            </UpdatedControls>
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="VehicleGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="HotelGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="HotelGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="AirlineGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="AirlineGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ServiceGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ServiceGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="VehicleGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="VehicleGrid" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Hay"
    Height="16px" Width="192px">
</telerik:RadAjaxLoadingPanel>
<div id="hotelblock" title="hotel">
    <telerik:RadGrid ID="HotelGrid" runat="server" AutoGenerateColumns="False" GridLines="None"
            AllowSorting="True" AllowPaging="True" Width="100%" ViewStateMode="Enabled" CellPadding="10"
            CellSpacing="10" Skin="Hay" BackColor="#DEE0C8" ShowFooter="True" CssClass="RadGrid"
            PageSize="5">
            <ClientSettings AllowAutoScrollOnDragDrop="False">
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" />
                <Resizing ClipCellContentOnResize="False" />
            </ClientSettings>
            <MasterTableView Dir="RTL" HorizontalAlign="Right" EditMode="EditForms" DataKeyNames="SrNo"
                InsertItemPageIndexAction="ShowItemOnCurrentPage" Width="100%" CommandItemDisplay="Top"
                ViewStateMode="Enabled" EnableViewState="true">
                <CommandItemSettings AddNewRecordText="Add Hotel"></CommandItemSettings>
                <Columns>
                 
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="SrNo" HeaderText="Sr. No"
                        DataField="SrNo" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="HotelCode" HeaderText="Hotel Code"
                        DataField="HotelCode" Visible="false">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="Hotel" HeaderText="Hotel"
                        DataField="Hotel">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="AreaCode" HeaderText="Area Code"
                        DataField="AreaCode" Visible="false">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="AreaDesc" HeaderText="Area Desc"
                        DataField="AreaDesc">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="FromDate" HeaderText="From Date"
                        DataFormatString="{0:dd/MM/yyyy}" DataField="FromDate">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="TotalDays" HeaderText="Total Days"
                        DataField="TotalDays">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="ToDate" HeaderText="To Date"
                        DataFormatString="{0:dd/MM/yyyy}" DataField="ToDate">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="HotelStar" HeaderText="Hotel Star"
                        DataField="HotelStar">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="CompanyCode" HeaderText="Company Code"
                        DataField="CompanyCode" Visible="false">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DefaultInsertValue="" UniqueName="Company" HeaderText="Company"
                        DataField="Company">
                        <ItemStyle Width="20px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="Confirmed" DefaultInsertValue="" HeaderText="Confirmed"
                        UniqueName="Confirmed">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn Aggregate="Sum" DataField="Total" DefaultInsertValue=""
                        HeaderText="Total" UniqueName="Total">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" ConfirmText="Are You Sure To Delete"
                        ConfirmTitle="Delete" Text="Delete" UniqueName="Delete">
                        <ItemStyle Width="10px" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings UserControlName="HotelDetail.ascx" EditFormType="WebUserControl">
                </EditFormSettings>
                <CommandItemSettings AddNewRecordText="Add Hotel" />
                <ExpandCollapseColumn ButtonType="ImageButton" Visible="False" UniqueName="ExpandColumn">
                    <HeaderStyle Width="19px"></HeaderStyle>
                </ExpandCollapseColumn>
            </MasterTableView>
        </telerik:RadGrid>
Princy
Top achievements
Rank 2
 answered on 10 Jan 2012
1 answer
151 views
Hi is the above possible ?

When my grid is exported its too wide to fit on the page, i'd like to default the document to landscape orientation.

edit: world is meant to be word by the way :P
Princy
Top achievements
Rank 2
 answered on 10 Jan 2012
2 answers
107 views
Hi,

I have a RadGrid in inline edit mode.  Everything works perfectly, except when in edit mode, my Update and Cancel buttons show as text links instead of images.  I'm using a GridEditCommandColumn:

<telerik:GridEditCommandColumn FilterControlAltText="Filter EditCommandColumn column"
    CancelImageUrl="~/images/cancel.jpg" EditImageUrl="~/images/page_edit.gif" UpdateImageUrl="~/images/save.jpg"
    ButtonType="ImageButton">

  • The images exist at the URL specified.
  • The Edit button properly displays the image.
  • I'm using a LinqDataSource with AllowAutomaticUpdates = true

Thoughts?
Glenn Plunkett
Top achievements
Rank 1
 answered on 10 Jan 2012
1 answer
160 views
I have a list view with an item template and some radnumeric text boxes.
I'm binding the radnumerictextboxes programaticaly OnItemCreated.
When I fire a postback the values are all gone.
Any suggestions?
thank you

 <telerik:RadListView ID="RadListView1" runat="server" OnItemCreated="RadListView1_ItemCreated">
                <ItemTemplate>
                    <div>
                        <telerik:RadNumericTextBox ID="txb0" runat="server" Width="50px" />
                        <telerik:RadNumericTextBox ID="txb1" runat="server" Width="50px" />
                    </div>
                </ItemTemplate>
   </telerik:RadListView>

    protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
    {
                if (!IsPostBack)
                {
                    RadNumericTextBox txb0 = (RadNumericTextBox)e.Item.FindControl("txb0");
                    txb0.Value = 1;

                    RadNumericTextBox txb1 = (RadNumericTextBox)e.Item.FindControl("txb1");
                    txb1.Value = 2;
                }
        }
Richard
Top achievements
Rank 1
 answered on 09 Jan 2012
6 answers
379 views
Hi,

I added an expand/collapse all button in the grid header as described in http://www.telerik.com/community/code-library/aspnet-ajax/grid/custom-expand-collapse-column-with-expandall-collapseall-image-button-in-the-header.aspx.

My grid alignment changes (the master table shrinks) when I expand the grid as shown in the attached image.

I am unable to understand why this is happening. Please help.
MBEN
Top achievements
Rank 2
Veteran
 answered on 09 Jan 2012
1 answer
71 views
Hi,

I need to present to the user an input form much like an excel spread sheet - a matrix of working days in a week along the top (columns) against various containers (rows).
The exact configuration of this form changes from user to user depending on slections they have made. For example, there may be 1 row or 15 rows, but the columns remain consistent.

In each cell will be a bound textbox where users can change or input the values.

Can anyone give me some pointers on how best to achieve this - specifically around how to ensure the ID's of each control will ensure data binding and capture is robust so that te backend code knows exactly where to put data and pull data.

I could rely on object binding and let the controls manage the delta's or manually parse the grid after it's been editing...

Thanks a bunch,

SMM
Elliott
Top achievements
Rank 2
 answered on 09 Jan 2012
3 answers
248 views
I am replacing 2 grids from another third-party (Intersoft) on a page and am trying to not change any of the functionality
there is a property set which deselects any item from either grid when that grid loses focus
I tried Grid1.Attributes.Add("onblur", function_name()); but no dice

in IE, that is
I do my development in IE then post and test in the other browsers
blur works in Mozilla but not sure about the parameters - but I could just use 2 functions
Elliott
Top achievements
Rank 2
 answered on 09 Jan 2012
16 answers
418 views
Dear All,

Like in RAD Windows Grid Control, is there any option available in the Web Grid for choosing the columns?

Mohan
Top achievements
Rank 1
 answered on 09 Jan 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?