Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
147 views

Question 1: How can we reset the drill down level from the code-behind? 

Question 2: How can always open to 2nd level (or perhaps 3rd level) from the code-behind? 

Plamen
Telerik team
 answered on 04 Feb 2016
1 answer
325 views

Using Entity Framework, Models, DataAnnotation and ASP WebForms, you can leverage the asp 'DynamicControl' and 'DynamicField' controls, which refer back to the model declaration and reflect the proper formatting and validation rules without having to duplicate those values in the markup or code behind.

 

The article, http://www.asp.net/web-forms/overview/older-versions-getting-started/getting-started-with-ef/the-entity-framework-and-aspnet-getting-started-part-8, goes into detail on how to get this to work with the basic ASP gridview and dataform controls.

 

Attempting to apply this technique to the RadDataForm, a control that can be strongly typed, results in the error: "The DynamicControl/DynamicField needs to exist inside a data control that is bound to a data source that supports Dynamic Data."

Huh? The RadDataForm doesn't support Dynamic Data?

Google search is frustrating due to the search returns dominated by the topic of "Dynamic Control" instead of "DynamicControl", and searched on this forum came up empty.

How can I place a DynamicControl into the EditItemTemplate of a RadDataForm and benefit from the formatting and other annotations listed on the Model?

 

Konstantin Dikov
Telerik team
 answered on 04 Feb 2016
5 answers
144 views
I am experimenting with this new control bound to a SiteMapDataSource. I am finding that, even when there is acres of space to display all the top level nodes, the final top level node always ends up under the sandwich-like button. Is there any way to fix this so that the control displays all top level nodes when there is sufficient space to do so?




Plamen
Telerik team
 answered on 04 Feb 2016
1 answer
89 views

Thanks in advance for your assistance.

 We've been using the RadEditor for years now.  When we recently updated the Telerik controls to the 2015.3.1111.40 version we experienced a very significant slowdown in responsiveness.  It became virtually un-useable due to the delay between a keystroke and the echo of that keystroke.

We were able to improve the situation somewhat by clearing the modules in our code-behind.  The delay is still significant, more delay than before the update to the 2015.3.1111.40 version and not really acceptable to our users but at least they are able to edit documents now.

As another attempt to resolve this problem we tried updating again - to the 2016.1.113.40 version.  That had no noticeable effect on the problem.

What do you suggest as a way to restore our use of the RadEditor to its previous responsiveness?

 

Here is the source from the web page where we define the RadEditor control: 

<telerik:RadEditor ID="reContent" ContentAreaMode="Iframe" EditModes="Design,Preview" ToolbarMode="Default" ToolsFile="~/Telerik/ToolsFile.xml" ContentAreaCssFile="EditorContentArea.css" AutoResizeHeight="true" Width="100%" runat="server">
<ImageManager MaxUploadFileSize="1000000" EnableImageEditor="true" />
<SpellCheckSettings DictionaryPath="~/Telerik/RadSpell" AllowAddCustom="false" SpellCheckProvider="EditDistanceProvider" EditDistance="2" FragmentIgnoreOptions="All" WordIgnoreOptions="UPPERCASE,WordsWithNumbers" />
</telerik:RadEditor>

 

Here is the source from the code behind - from the Page Load sub - where we added code to clear the modules to help with performance.

reContent.ImageManager.ViewPaths = Split(ImageManagerURL)
reContent.ImageManager.UploadPaths = Split(ImageManagerURL)
reContent.ImageManager.DeletePaths = Split(ImageManagerURL)
reContent.Modules.Clear()
'-----------------------------
If so.Manage_Security Then
reContent.EditModes = Telerik.Web.UI.EditModes.All
End If

 

Ianko
Telerik team
 answered on 04 Feb 2016
4 answers
509 views
I have a project requirement to show the totals from my radgrid in the header instead of the footer because the users don't want to have to scroll down to the bottom of the grid to see the totals. Is this possible? I know how to do it in the footer based on this article, but can it easily be done in the header? If not, I guess I'll have to switch to a RadListView which is going to be a bit of a pain, but not sure what else to do.
Jaicon
Top achievements
Rank 1
 answered on 03 Feb 2016
1 answer
96 views
Am i wrong or is the CurrentPageIndex' zero-based?
Pavlina
Telerik team
 answered on 03 Feb 2016
4 answers
188 views

I have a grid and I'm trying to add some date range filtering to.  The date range filter is on a GridDateTimeColumn, however I just need to filter on Date.  I enabled Range Filtering on the column, but the filter control didn't play nice with the grid, it extendes the width of the DateTimeColumn so the other columns are almost too small.  I then implemented a FilterTemplate with two Telerik DatePicker controls (one on top of the other) as per this demo and that seemed to work.  However, it broke other filtering that I had on the grid. 

Whenever I use any other filter, the date range filter is ignored. 

Example workflow:

  1. Enter From Date and To Date - note the records in the grid
  2. Filter on any other column - note the date range is ignored

Here is my markup 

<%@ Page Title="" Language="C#" MasterPageFile="~/pqc.Master" AutoEventWireup="true" CodeBehind="inspection.aspx.cs" Inherits="pqc.web.inspection.Inspection" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head1" runat="server">
    <telerik:RadScriptBlock runat="server" ID="radScriptBlock">
        <script type="text/javascript">
            function RowSelected(sender, args) {
                var key = args.getDataKeyValue("inspection_id");
                if (key) {
                    window.location.href = "viewinspection.aspx?id=" + key;
                }
            }
        </script>
    </telerik:RadScriptBlock>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContextMenu" runat="server">
    <div>
        <telerik:RadButton runat="server" ID="radNew" Text="New Inspection" OnClick="radNew_OnClick"></telerik:RadButton>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxManager runat="server" ID="radAjaxManager" EnableAJAX="True">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radInspection">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radInspection" LoadingPanelID="radLpInspection" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div class="title">Inspection</div>
    <telerik:RadAjaxLoadingPanel runat="server" ID="radLpInspection"></telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid runat="server" ID="radInspection" AllowPaging="True" AllowSorting="True" ShowHeader="True" GridLines="None" CellPadding="0" CellSpacing="0"
        PageSize="20" AllowFilteringByColumn="True" OnNeedDataSource="radInspection_OnNeedDataSource" OnItemCommand="radInspection_OnItemCommand"
        OnItemDataBound="radInspection_OnItemDataBound">
        <ClientSettings AllowColumnsReorder="False" EnableRowHoverStyle="True" EnablePostBackOnRowClick="False">
            <Selecting AllowRowSelect="True"></Selecting>
            <Scrolling UseStaticHeaders="True"></Scrolling>
            <ClientEvents OnRowSelected="RowSelected"></ClientEvents>
        </ClientSettings>
        <GroupingSettings CaseSensitive="False"></GroupingSettings>
        <MasterTableView DataKeyNames="inspection_id" ClientDataKeyNames="inspection_id" AutoGenerateColumns="False" AllowMultiColumnSorting="True" EnableHeaderContextMenu="True"
            AllowFilteringByColumn="True" CommandItemDisplay="TopAndBottom" Height="100%">
            <NoRecordsTemplate>No inspections.</NoRecordsTemplate>
            <CommandItemSettings ShowAddNewRecordButton="False" ShowCancelChangesButton="False" ShowSaveChangesButton="False" ShowRefreshButton="True"></CommandItemSettings>
            <Columns>
                <telerik:GridBoundColumn DataField="inspection_id" HeaderText="ID">
                    <HeaderStyle Width="1%" VerticalAlign="Top" HorizontalAlign="Right"></HeaderStyle>
                    <ItemStyle Width="1%" VerticalAlign="Top" HorizontalAlign="Right"></ItemStyle>
                    <FilterTemplate>
                        <asp:ImageButton runat="server" ID="ibClearDate" ImageUrl="images/icons/cancel.png" AlternateText="Clear filter" ToolTip="Clear filter"
                            Width="16" Height="16" OnClick="ibClearDate_OnClick" />
                    </FilterTemplate>
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="inspection_datetime" HeaderText="Inspection Date" EnableTimeIndependentFiltering="False"
                    PickerType="DateTimePicker" DataFormatString="{0:yyyy-MM-dd HH:mm tt}" UniqueName="InspectionDate" enable>
                    <ItemStyle Width="7%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                    <HeaderStyle Width="7%"></HeaderStyle>
                    <FilterTemplate>
                        <div style="float: left">
                            <telerik:RadDatePicker runat="server" ID="radFromInspectionDate" Width="110px">
                                <Calendar>
                                    <SpecialDays>
                                        <telerik:RadCalendarDay Repeatable="Today">
                                            <ItemStyle BackColor="LightGray" Font-Bold="True" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px"></ItemStyle>
                                        </telerik:RadCalendarDay>
                                    </SpecialDays>
                                </Calendar>
                                <DateInput DisplayDateFormat="yyyy-MM-dd" DateFormat="yyyy-MM-dd" EmptyMessage="From Date"></DateInput>
                                <ClientEvents OnDateSelected="FromInspectionDateSelected"></ClientEvents>
                            </telerik:RadDatePicker>
                            <br />
                            <telerik:RadDatePicker runat="server" ID="radToInspectionDate" Width="110px">
                                <Calendar>
                                    <SpecialDays>
                                        <telerik:RadCalendarDay Repeatable="Today">
                                            <ItemStyle BackColor="LightGray" Font-Bold="True" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px"></ItemStyle>
                                        </telerik:RadCalendarDay>
                                    </SpecialDays>
                                </Calendar>
                                <DateInput DisplayDateFormat="yyyy-MM-dd" DateFormat="yyyy-MM-dd" EmptyMessage="To Date"></DateInput>
                                <ClientEvents OnDateSelected="ToInspectionDateSelected"></ClientEvents>
                            </telerik:RadDatePicker>
                        </div>
                        <telerik:RadScriptBlock runat="server" ID="radInspectionScripts">
                            <script type="text/javascript">
                                function FromInspectionDateSelected(sender, args) {
                                    var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
                                    var toPicker = $find('<%# Container.FindControl("radToInspectionDate").ClientID %>');
                                    if (tableView && toPicker) {
                                        var fromDate = FormatSelectedDate(sender);
                                        var toDate = FormatSelectedDate(toPicker);
                                        tableView.filter("InspectionDate", fromDate + " " + toDate, "Between");
                                    }
                                }
                                function ToInspectionDateSelected(sender, args) {
                                    var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
                                    var fromPicker = $find('<%# Container.FindControl("radFromInspectionDate").ClientID %>');
                                    if (tableView && fromPicker) {
                                        var fromDate = FormatSelectedDate(fromPicker);
                                        var toDate = FormatSelectedDate(sender);
                                        tableView.filter("InspectionDate", fromDate + " " + toDate, "Between");
                                    }
                                }
                                function FormatSelectedDate(picker) {
                                    if (picker) {
                                        var date = picker.get_selectedDate();
                                        var dateInput = picker.get_dateInput();
                                        if (!date) {
                                            date = new Date();
                                        }
                                        var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
                                        return formattedDate;
                                    }
                                    return null;
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="inspector" HeaderText="Inspector" FilterControlWidth="75%">
                    <HeaderStyle Width="7%"></HeaderStyle>
                    <ItemStyle Width="7%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="division" HeaderText="Division" UniqueName="Division" FilterControlWidth="75%">
                    <HeaderStyle Width="5%"></HeaderStyle>
                    <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                    <FilterTemplate>
                        <telerik:RadComboBox runat="server" ID="radDivisionFilter" Width="120px" OnClientSelectedIndexChanged="DivisionIndexChanged"></telerik:RadComboBox>
                        <telerik:RadCodeBlock runat="server" ID="radDivisionCode">
                            <script type="text/javascript">
                                function DivisionIndexChanged(sender, args) {
                                    var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
                                    tableView.filter("Division", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadCodeBlock>
                    </FilterTemplate>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="full_grade" HeaderText="Grade" FilterControlWidth="75%">
                    <HeaderStyle Width="8%"></HeaderStyle>
                    <ItemStyle Width="8%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="tag_number" HeaderText="Tag #" FilterControlWidth="75%">
                    <HeaderStyle Width="5%"></HeaderStyle>
                    <ItemStyle Width="5%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="size_description" HeaderText="Width" FilterControlWidth="75%">
                    <HeaderStyle Width="4%"></HeaderStyle>
                    <ItemStyle Width="4%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="length_description" HeaderText="Length" FilterControlWidth="75%">
                    <HeaderStyle Width="4%"></HeaderStyle>
                    <ItemStyle Width="4%" VerticalAlign="Top" HorizontalAlign="Left"></ItemStyle>
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="complete" HeaderText="Completed" AllowFiltering="False">
                    <HeaderStyle Width="2%" HorizontalAlign="Right"></HeaderStyle>
                    <ItemStyle Width="2%" VerticalAlign="Top" HorizontalAlign="Right"></ItemStyle>
                </telerik:GridCheckBoxColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Content>

Here is my code-behind 

using System;
using System.Web.UI;
using pqc.web.Classes;
using Telerik.Web.UI;
 
namespace pqc.web.inspection
{
  public partial class Inspection : PageBase
  {
    private DateTime? FromDate { get; set; }
 
    private DateTime? ToDate { get; set; }
 
    protected void Page_Load(object sender, EventArgs e)
    {
      if (Session["Key"] != null)
      {
        Session["Key"] = -1;
      }
      if (!IsPostBack)
      {
        LoadData();
      }
    }
 
    private void LoadData()
    {
      var inspections = dal.Inspection.GetVInspectionHeaders();
      radInspection.DataSource = inspections;
    }
 
    protected void radInspection_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
      LoadData();
    }
 
    protected void radNew_OnClick(object sender, EventArgs e)
    {
      Session["Key"] = -1;
      Response.Redirect("header.aspx");
    }
 
    protected void radInspection_OnItemCommand(object sender, GridCommandEventArgs e)
    {
      var grid = sender as RadGrid;
      if (grid == null)
      {
        return;
      }
      if (e.CommandName == "RowClick")
      {
        var item = e.Item as GridEditableItem;
        if (item == null)
        {
          return;
        }
        var key = item.GetDataKeyValue("inspection_id").ToString();
        Response.Redirect(string.Format("viewinspection.aspx?id={0}", key));
      }
      else
      {
        var filtering = e.Item as GridFilteringItem;
        if (filtering == null)
        {
          return;
        }
        var selected = "";
        var fromDate = filtering.FindControl("radFromInspectionDate") as RadDatePicker;
        var toDate = filtering.FindControl("radToInspectionDate") as RadDatePicker;
        if (fromDate != null)
        {
          if (!string.IsNullOrEmpty(grid.MasterTableView.GetColumn("InspectionDate").CurrentFilterValue))
          {
            selected = grid.MasterTableView.GetColumn("InspectionDate").CurrentFilterValue;
            selected = selected.Split(' ')[0];
          }
          if (!string.IsNullOrEmpty(selected))
          {
            FromDate = Convert.ToDateTime(selected);
            fromDate.SelectedDate = FromDate;
          }
        }
        if (toDate != null)
        {
          if (!string.IsNullOrEmpty(grid.MasterTableView.GetColumn("InspectionDate").CurrentFilterValue))
          {
            selected = grid.MasterTableView.GetColumn("InspectionDate").CurrentFilterValue;
            selected = selected.Split(' ')[1];
          }
          if (!string.IsNullOrEmpty(selected))
          {
            ToDate = Convert.ToDateTime(selected);
            toDate.SelectedDate = ToDate;
          }
        }
      }
    }
 
    protected void radInspection_OnItemDataBound(object sender, GridItemEventArgs e)
    {
      var grid = sender as RadGrid;
      if (grid == null)
      {
        return;
      }
      var filtering = e.Item as GridFilteringItem;
      if (filtering == null)
      {
        return;
      }
      var fromDate = filtering.FindControl("radFromInspectionDate") as RadDatePicker;
      var toDate = filtering.FindControl("radToInspectionDate") as RadDatePicker;
      var cmbDiv = filtering.FindControl("radDivisionFilter") as RadComboBox;
      if (fromDate != null)
      {
        fromDate.SelectedDate = FromDate;
      }
      if (toDate != null)
      {
        toDate.SelectedDate = ToDate;
      }
      if (cmbDiv != null)
      {
        cmbDiv.ClearSelection();
        cmbDiv.Items.Clear();
        var selected = "";
        if (!string.IsNullOrEmpty(grid.MasterTableView.GetColumn("Division").CurrentFilterValue))
        {
          selected = grid.MasterTableView.GetColumn("Division").CurrentFilterValue;
        }
        ListHelper.FillDivisionsForFilter(cmbDiv, ApplicationId, selected);
      }
    }
 
    protected void ibClearDate_OnClick(object sender, ImageClickEventArgs e)
    {
      radInspection.MasterTableView.FilterExpression = string.Empty;
      foreach (var column in radInspection.MasterTableView.RenderColumns)
      {
        var b = column as GridBoundColumn;
        if (b != null)
        {
          b.CurrentFilterValue = string.Empty;
        }
      }
      radInspection.Rebind();
    }
  }
}

How can I get the date filter preserved when other columns are filtered?

Mike
Top achievements
Rank 1
 answered on 03 Feb 2016
20 answers
4.3K+ views
Hi,

 I am creating the datasource from datatable and populating the radgrid. i want to make cells as hyperlink column and navigate to url based on the cell value in the code behind. could anyone help regarding this issue.

thanks
Mubarak
Top achievements
Rank 1
 answered on 03 Feb 2016
14 answers
573 views

Hi,

I have a RadPivotGrid where my  PivotGridColumn is a date field.  When I export to Excel, the column heading comes across as some generic numeric value and not the month name - year format that's displayed in the grid. 

Is there anyway to fix this?

Thank you

 Steve

 

Here is my grid and attached is a sample of the data:

 

<telerik:RadPivotGrid ID="gvSixMonthSalesReport" runat="server" ShowColumnHeaderZone="false" ShowRowHeaderZone="false" ShowDataHeaderZone="false" EnableZoneContextMenu="false"  ColumnHeaderCellStyle-ForeColor="#003366" EmptyValue="$0.00" >
    <Fields>
        <telerik:PivotGridRowField DataField="GroupID" ZoneIndex="0" IsHidden="true" ></telerik:PivotGridRowField>
        <telerik:PivotGridRowField DataField="GroupName" ZoneIndex="1" ></telerik:PivotGridRowField>
        <telerik:PivotGridRowField DataField="Sales_Person" ZoneIndex="2"></telerik:PivotGridRowField>
        <telerik:PivotGridColumnField DataField="MarginMonth" ZoneIndex="0" DataFormatString="{0:Y}"></telerik:PivotGridColumnField>
        <telerik:PivotGridAggregateField DataField="Margin" Aggregate="Sum" DataFormatString="{0:C}"></telerik:PivotGridAggregateField>
    </Fields>
    <ExportSettings FileName="Six-Month Sales Maging Report" IgnorePaging="true" />
</telerik:RadPivotGrid>
Viktor Tachev
Telerik team
 answered on 03 Feb 2016
1 answer
115 views
I have a few rad buttons that set radCalendar1.selectedDate = "Some date" (+-1 day, +-7 days, +-1 month). The code works and the calendar does highlight the correct day but I can't see the selected date if it is in a different month/view. Is there a way to refresh the calendar view/display to update to the radCalendar1.selectedDate?
Viktor Tachev
Telerik team
 answered on 03 Feb 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?