Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
76 views
Hi,

I added export to Excel/Word/Pdf to my RadGrid. Export to excel works perfectly, but export to pdf and Word just corrupt my Grid's layout (header and footer aren't displayed anymore). After another postback (e.g. when sorting), the Grid is correctly 
displayed.

These are my settings:
grid.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
grid.MasterTableView.CommandItemSettings.ShowExportToPdfButton = true;
grid.MasterTableView.CommandItemSettings.ShowExportToWordButton = true;
grid.ExportSettings.IgnorePaging = true;
grid.ExportSettings.ExportOnlyData = true;
grid.ExportSettings.OpenInNewWindow = true;


I don't have any special logic for excel. This is the only thing I do in the GridItemCommand event handler:

if (e.CommandName == RadGrid.ExportToExcelCommandName ||
   e.CommandName == RadGrid.ExportToPdfCommandName
   || e.CommandName == RadGrid.ExportToWordCommandName)
{
   foreach (GridColumn column in grid.MasterTableView.Columns)
   {
      if (!(column is GridBoundColumn) && !(column is GridCheckBoxColumn))
      {
         column.Visible = false;
      }
   }
}

I don't get any server or client-side errors/warnings when exporting, so what could that be?
JP
Top achievements
Rank 1
 answered on 06 Jun 2012
3 answers
123 views
Hi,

I have a RadComboBox defined as follows:

<telerik:RadComboBox
    ID="ddlValue"
    runat="server"
    AllowCustomText="True"
    Width="320px"
    MarkFirstMatch="True"
    AutoCompleteSeparator=";"
    AutoPostBack="true"
    OnSelectedIndexChanged="ddlValue_SelectedIndexChanged">
</telerik:RadComboBox>

And this code-behind

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        var datasource = new RadComboBoxItemCollection(ddlValue)
        {
            new RadComboBoxItem("", ""),
            new RadComboBoxItem("David Larkin", Guid.NewGuid().ToString()),
            new RadComboBoxItem("Ahmed Warreth", Guid.NewGuid().ToString()),
            new RadComboBoxItem("Ryan Estes", Guid.NewGuid().ToString()),
            new RadComboBoxItem("Antonio Siqueira", Guid.NewGuid().ToString())
        };
 
        ddlValue.DataSource = datasource;
        ddlValue.DataTextField = "Text";
        ddlValue.DataValueField = "Value";
        ddlValue.DataBind();
    }
}
 
protected void ddlValue_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    ltrSelection.Text = (sender as RadComboBox).Text;
}
I'm experiencing the following behaviour:
  1. Choose David Larkin from the combo box
  2. David Larkin appears in the label as expected
  3. Place the cursor in the combo box at the end of the text, type ";Ah" and press Enter
  4. David Larkin;Ahmed Warreth appears in the label as expected
  5. Choose the first item in the combo box
  6. I would expect the text of the combo box to become an empty string, but it is actually "David Larkin;"

Is there some property that I'm not setting that would cause this, or is it a bug in the control?

I'm using version 2011.1.413.40.

Thanks,

David
Princy
Top achievements
Rank 2
 answered on 06 Jun 2012
1 answer
287 views
Hi,

Is there anyway I can hide the expand/collapse icons based on a value calculated in the GridGroupByExpression?

For example I want to hide the icon if the the GroupByField 'Count' aggregate = 0:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadGrid ID="rdgSurveys" runat="server" AllowPaging="false" Skin="Office2010Silver"
                OnNeedDataSource="rdgSurveys_NeedDataSource" OnItemDataBound="rdgSurveys_ItemDataBound"
                OnItemCreated="rdgSurveys_ItemCreated">
                <MasterTableView AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" HierarchyDefaultExpanded="false">
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldName="Ref" FieldAlias="Survey" />
                                <telerik:GridGroupByField FieldAlias="Count" FieldName="SumField" Aggregate="Sum" />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="Ref" SortOrder="Ascending"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>
                    <Columns>
                        <telerik:GridBoundColumn DataField="DateCreated" DataType="System.DateTime" HeaderText="Date Created"
                            UniqueName="DateCreated" DataFormatString="{0:dd MMM yyy hh:mm}" />
                        <telerik:GridBoundColumn DataField="Version" DataType="System.String" HeaderText="Version"
                            UniqueName="Version" />
                        <telerik:GridBoundColumn DataField="Respondent" DataType="System.String" HeaderText="Completed By"
                            UniqueName="Respondent" />
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

 
Abhishek
Top achievements
Rank 2
 answered on 06 Jun 2012
0 answers
84 views
Hi all!

I have a RadGrid with rows and each row contains a RadNumericTextBox. When I edit the value of this RadNumericTextbox (using the spinbuttons) I have a AjaxLoadingPanel over the RadNumericTextbox which is edited (according to this demo). This is working fine in compatibility mode in IE9, but not in normal mode. This is the code:

.cs
RadAjaxManager.GetCurrent(Page).ClientEvents.OnRequestStart = "RequestStart";
RadAjaxManager.GetCurrent(Page).ClientEvents.OnResponseEnd = "ResponseEnd";

.ascx
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="grdItems">
        <UpdatedControls>          
            <telerik:AjaxUpdatedControl ControlID="grdItems" />
        </UpdatedControls>
        </telerik:AjaxSetting>        
    </AjaxSettings>        
</telerik:RadAjaxManagerProxy>


<script type="text/javascript">
    var currentLoadingPanel = null;
    var currentUpdatedControl = null;
    function RequestStart(sender, args) {
        currentLoadingPanel = $find("<%= RadAjaxLoadingPanel1.ClientID %>");
        currentUpdatedControl = args.get_eventTarget();            
        currentLoadingPanel.show(currentUpdatedControl);
    }
    function ResponseEnd() {
        //hide the loading panel and clean up the global variables
        if (currentLoadingPanel != null)
            currentLoadingPanel.hide(currentUpdatedControl);
                          
        currentUpdatedControl = null;
        currentLoadingPanel = null;
    }
</script>

What can I do so that it works fine in IE9?

Thanks in advance.

Regards,
Peter

Peter
Top achievements
Rank 1
 asked on 06 Jun 2012
1 answer
146 views

I have  radgrid  which  displays information on 2 grouping levels
Based on selction from dropdown  above the radgrid, it retrieves the  Radgrid.

On first load of the page or whenever there is change in the selection in the search drop down. I need the Group1 not to  expand and  user should able to expand the group  which should result the groups inside it  and then  expand I should able to expand the 2nd group again.

I was  able to to do the following  in the load


If
Not IsPostBack Then

 RadGrid1.MasterTableView.GroupsDefaultExpanded = False

Else

 RadGrid1.MasterTableView.GroupsDefaultExpanded = True   <--- I have to do this otherwise it stays FALSE on subsequest page loads

End If

And on the change selection of dropdown I am doing

 

RadGrid1.MasterTableView.GroupsDefaultExpanded = FALSE

With the above codigng  the first load of grid  displays fine with not expanded , when i click on the group expand button, the symbol changes that it expanded but it does not display the expanded groups. Now If I clcik again the same buttons ,it shows  everything with all 2 level groups also  expanded .
So basically on  1st time you don't see any change in the display of screen ( except the higher level group shows expanded sysmbol).
Clicking on it agian  it shows everything expanded.

How to control the two level groupings for the scenario I mentioned above.

Thanks
 



Tsvetina
Telerik team
 answered on 06 Jun 2012
1 answer
102 views
Hi,

Is it possible to clear the grouping/sorting expression clientside
I know I can do it serverside using the following, but I would like to do it clientside.

rgvGrid.MasterTableView.SortExpressions.Clear()

rgvGrid.MasterTableView.GroupByExpressions.Clear()

Also, can I set the expressions clientside.
I can set it serverside using the following;

 

rgvGrid.MasterTableView.GroupByExpressions.Add(New GridGroupByExpression(strExpression))



Thank you for your assistance.

Maria Ilieva
Telerik team
 answered on 06 Jun 2012
0 answers
344 views
Hi,
I've tried to create a custom editor for TimeSpan data field and it returns an error 'Specified cast is not valid' when I try to set value.

public class RadFilterTimeSpanEditor : RadFilterDataFieldEditor
    {
        RadMaskedTextBox _timePicker;
        public override void InitializeEditor(System.Web.UI.Control container)
        {
            _timePicker = new RadMaskedTextBox();
            _timePicker.Mask = "<0..5><0..9>:<0..5><0..9>";
            container.Controls.Add(_timePicker);
        }
        public override Type DataType
        {
            get
            {
                return typeof(TimeSpan);
            }
            set  {}
        }
 
        public override System.Collections.ArrayList ExtractValues()
        {
            ArrayList list = new ArrayList(1);
            if (!string.IsNullOrWhiteSpace(_timePicker.Text))
            {             
                TimeSpan ts = new TimeSpan(00, int.Parse(_timePicker.Text.Substring(0, 2)), int.Parse(_timePicker.Text.Substring(2, 2)));
                list.Add(ts);
            }
       
            return list;
        }       
 
        public override void SetEditorValues(System.Collections.ArrayList values)
        {
            if (values != null && values.Count > 0)
            {
                if (values[0] == null && !(values[0] is TimeSpan))
                    return;
                TimeSpan ts = (TimeSpan)values[0];
                _timePicker.Text = string.Format("{0:00}{1:00}", ts.Minutes, ts.Seconds);               
            }
        }
        protected override void CopySettings(RadFilterDataFieldEditor baseEditor)
        {
            base.CopySettings(baseEditor);
            var editor = baseEditor as RadFilterTimeSpanEditor;
             
        }

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RadFilterTimeSpanEditor editorTimeSpan = new RadFilterTimeSpanEditor();
            RadFilter1.FieldEditors.Add(editorTimeSpan);
            editorTimeSpan.FieldName = "ShipingDuration";
            editorTimeSpan.DisplayName = "Shipping Duration";          
        }
    }
    protected void RadFilter1_FieldEditorCreating(object sender, Telerik.Web.UI.RadFilterFieldEditorCreatingEventArgs e)
    {
        if (e.EditorType == "RadFilterTimeSpanEditor")
        {
            e.Editor = new RadFilterTimeSpanEditor();
        }
    }
}

<telerik:RadFilter ID="RadFilter1" runat="server" CssClass="RadFilter RadFilter_Default RadFilter RadFilter_Default "
            FilterContainerID="RadGrid1" OnFieldEditorCreating="RadFilter1_FieldEditorCreating">
        </telerik:RadFilter>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellSpacing="0" DataSourceID="ObjectDataSource1" GridLines="None">
            <ClientSettings>
                <Selecting CellSelectionMode="None"></Selecting>
            </ClientSettings>
            <MasterTableView DataSourceID="ObjectDataSource1">
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterControlAltText="Filter OrderID column"
                        HeaderText="OrderID" SortExpression="OrderID" UniqueName="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CustomerID" FilterControlAltText="Filter CustomerID column"
                        HeaderText="CustomerID" SortExpression="CustomerID" UniqueName="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="EmployeeID" DataType="System.Int32" FilterControlAltText="Filter EmployeeID column"
                        HeaderText="EmployeeID" SortExpression="EmployeeID" UniqueName="EmployeeID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" FilterControlAltText="Filter OrderDate column"
                        HeaderText="OrderDate" SortExpression="OrderDate" UniqueName="OrderDate">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="RequiredDate" DataType="System.DateTime" FilterControlAltText="Filter RequiredDate column"
                        HeaderText="RequiredDate" SortExpression="RequiredDate" UniqueName="RequiredDate">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShippedDate" DataType="System.DateTime" FilterControlAltText="Filter ShippedDate column"
                        HeaderText="ShippedDate" SortExpression="ShippedDate" UniqueName="ShippedDate">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipVia" DataType="System.Int32" FilterControlAltText="Filter ShipVia column"
                        HeaderText="ShipVia" SortExpression="ShipVia" UniqueName="ShipVia">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Freight" DataType="System.Decimal" FilterControlAltText="Filter Freight column"
                        HeaderText="Freight" SortExpression="Freight" UniqueName="Freight">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipName" FilterControlAltText="Filter ShipName column"
                        HeaderText="ShipName" SortExpression="ShipName" UniqueName="ShipName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipAddress" FilterControlAltText="Filter ShipAddress column"
                        HeaderText="ShipAddress" SortExpression="ShipAddress" UniqueName="ShipAddress">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipCity" FilterControlAltText="Filter ShipCity column"
                        HeaderText="ShipCity" SortExpression="ShipCity" UniqueName="ShipCity">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipRegion" FilterControlAltText="Filter ShipRegion column"
                        HeaderText="ShipRegion" SortExpression="ShipRegion" UniqueName="ShipRegion">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipPostalCode" FilterControlAltText="Filter ShipPostalCode column"
                        HeaderText="ShipPostalCode" SortExpression="ShipPostalCode" UniqueName="ShipPostalCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipCountry" FilterControlAltText="Filter ShipCountry column"
                        HeaderText="ShipCountry" SortExpression="ShipCountry" UniqueName="ShipCountry">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipingDuration" DataType="System.TimeSpan" FilterControlAltText="Filter ShipingDuration column"
                        HeaderText="ShipingDuration" UniqueName="ShipingDuration" SortExpression="ShipingDuration">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="EntityState" DataType="System.Int32" FilterControlAltText="Filter EntityState column"
                        HeaderText="EntityState" ReadOnly="True" SortExpression="EntityState" UniqueName="EntityState">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
        </telerik:RadGrid>
    </div>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetOrders"
        TypeName="NORTHWINDModel.OrdersAdapter"></asp:ObjectDataSource>

public partial class Orders
    {
        public TimeSpan? ShipingDuration
        {
            get
            {
                return this.ShippedDate - this.OrderDate;
            }
            set { }
        }
    }
Dmitry
Top achievements
Rank 1
 asked on 06 Jun 2012
1 answer
311 views
Hello,

I was wondering if it were possible to implement virtual scrolling with the listview either by itself or using the datapager. Basically I am hoping that if the page is scrolled to the end of the listview, it will load the next page directly underneath it. Think Facebook and how they handle their wall posts/time line. Any advice would be great.
Maria Ilieva
Telerik team
 answered on 06 Jun 2012
1 answer
347 views
Whenever I try to call a function ("ItemErrorAlert") that contains RadConfirm from the code behind I receive a javascript error: "radconfirm is not defined". Although RadConfirm works as expected if I call it through the RadWindowManager, but I would rather call it in a javascript function.

See a code snippet below:

ASPX

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Tools.aspx.cs" Inherits="ARCHLT.Helios.Eos.Tools" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
 
<script type="text/javascript">
 
    function ItemErrorAlert(message) {
        radconfirm(message, confirmCallBackFn, 300, 100, null, "Title");
    }
 
    function confirmCallBackFn(arg) {
        radalert("<strong>radconfirm</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", null, null, "Result");
    }
 
     
</script>
 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h3>TOOLS</h3><br />
 
<!-- Rad Window Manager -->
<telerik:RadWindowManager ID="RadWindowManager" runat="server" EnableShadow="true">
</telerik:RadWindowManager>
 
<!-- Rad Ajax Manager -->
<telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
</telerik:RadAjaxManager>
 
<div style="float:left;">
    <telerik:RadTextBox ID="txt_InputData" runat="server" TextMode="MultiLine" EmptyMessage="Enter TagID or Item GUID Here. (Comma, Line or Space Delimited)" Width="500px" Height="200px" />
       <br /><br />
    <telerik:RadButton ID="btn_ValidateInputData" runat="server" Text="Validate" OnClick="ValidateInputData" />
    <telerik:RadButton ID="btn_Execute" runat="server" Text="Execute" Visible="false" OnClick="ExecuteInputData"/>
</div>
<asp:Panel ID="panel_DataManipulation" runat="server" Enabled="false">
    <div style="float:left;">
        <span>Set Status: </span><telerik:RadComboBox ID="rcb_SetStatus" runat="server" EmptyMessage="Select Status">
            <Items>
                <telerik:RadComboBoxItem Text="" Value="" />
                <telerik:RadComboBoxItem Text="Checked In" Value="1" />
                <telerik:RadComboBoxItem Text="Checked Out" Value="2" />
                <telerik:RadComboBoxItem Text="Consumed/Allocated" Value="3" />
                <telerik:RadComboBoxItem Text="Transferred" Value="4" />
            </Items>
        </telerik:RadComboBox>
        <span>Set Location: </span><telerik:RadComboBox ID="rcb_SetLocation" runat="server" EmptyMessage="Select Location" />
         
            <br /><br />
 
        <span>Set Expiration: </span><telerik:RadDatePicker ID="rdp_SetExpiration" runat="server" />
 
    </div>
</asp:Panel>
</asp:Content>


C#

protected void ValidateInputData(object sender, EventArgs e)
{
    bool ResultItemID = false;
    bool ResultTagID = false;
    // Parse the input data into a list
    List<string> ParsedInputData = ParseInputData(txt_InputData.Text);
 
    // Check if the input data is a TagID or Item.ID
    if (IsItemID(ParsedInputData))
    {
        // Check to see if there are any errors
        if (ErrorID.Count > 0)
        {
            string sErrorMsg = "";
            sErrorMsg += "A few of the IDs you inputed did not validate: ";
 
            foreach (string s in ErrorID)
            {
                sErrorMsg += "'" + s + "',";
            }
 
            // Remove trailing comma
            sErrorMsg.Remove(sErrorMsg.Count() - 1);
 
            sErrorMsg += "Would you like to try to validate again without these IDs?";
 
            //RadWindowManager.RadConfirm(sErrorMsg, "confirmCallBackFn", 330, 100, null, "Input Data Validation");
 
            ScriptManager.RegisterStartupScript(this, this.GetType(), "itemerroralert", "ItemErrorAlert(\"" + sErrorMsg + "\");", true);
        }
        else
        {
            ResultItemID = true;
            inputDataType = IDType.ItemID;
            RadWindowManager.RadAlert("The input data has been validated as an Item.ID. Please choose what you would like to do from the panel on the right", 300, 100, "Validation Alert", null);
        }
    }
    else if (IsTagID(ParsedInputData))
    {
        ResultTagID = true;
        inputDataType = IDType.TagID;
        ScriptManager.RegisterStartupScript(this, this.GetType(), "radalert", RadPopup.GenerateConfirmScript("The input data has been validated as a TagID. Please choose what you would like to do from the panel on the right"), true);
    }
 
 
    // Turn on
    if ((ResultItemID) || (ResultTagID))
    {
        panel_DataManipulation.Enabled = true;
        btn_ValidateInputData.Visible = false;
        btn_Execute.Visible = true;
    }
}
Princy
Top achievements
Rank 2
 answered on 06 Jun 2012
1 answer
280 views
Hi

Is there any way to select an item in RadListView on right mouse click?? I use this demo http://demos.telerik.com/aspnet-ajax/listview/examples/client/webservicedatabinding/defaultcs.aspx to populate the ListView, but the right click always shows me the browsers contextMenu.

Thanks
Tsvetina
Telerik team
 answered on 06 Jun 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?