Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
347 views
I have a radgrid in inline edit mode which has two raddatepicker in edit mode. when someone is typing some text that is not a date the datepicker will display an error sign inside the dateinput but when the person is clicking update button it updates the database by null. I want to cancel editing  when the error sign is in the inputdate box when the user click on update button. How can I do that?  my code is as below:
protected void ToolkitList_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem dataItem = (GridEditableItem)e.Item;
RadDatePicker pickerdue = (RadDatePicker)dataItem["ToolkitDueDate"].Controls[0];
pickerdue.ShowPopupOnFocus = true;
pickerdue.DatePopupButton.Visible = false;
pickerdue.Width = Unit.Pixel(80);


RadDatePicker pickerboard = (RadDatePicker)dataItem["BoardMeetingDate"].Controls[0];
pickerboard.ShowPopupOnFocus = true;
pickerboard.DatePopupButton.Visible = false;
pickerboard.Width = Unit.Pixel(80);


}

}

protected void ToolkitList_UpdateCommand(object sender, GridCommandEventArgs e)
{
try
{
if (e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editedItem = e.Item as GridEditableItem;


if (editedItem != null && editedItem.IsInEditMode)
{
                               
                        
                        int myUniqueId =
Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][" ID"]);
string labeloneText = string.Empty;
string labeltwoText = string.Empty;
RadDatePicker pickerdue = (RadDatePicker) editedItem["ToolkitDueDate"].Controls[0];
RadDatePicker pickerboard = (RadDatePicker) editedItem["BoardMeetingDate"].Controls[0];

if (!pickerdue.IsEmpty && !pickerboard.IsEmpty)
{

labeloneText = pickerdue.SelectedDate.ToString();
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
Convert.ToDateTime(labeloneText), Convert.ToDateTime(labeltwoText),
_currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}

// Update the toolkit's due date.
if (pickerdue.IsEmpty && pickerboard.IsEmpty)
{

labeloneText = pickerdue.SelectedDate.ToString();
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
null, null, _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}

if (pickerdue.IsEmpty && !pickerboard.IsEmpty)
{
labeltwoText = pickerboard.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
null, Convert.ToDateTime(labeltwoText), _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}
if (!pickerdue.IsEmpty && pickerboard.IsEmpty)
{
labeloneText = pickerdue.SelectedDate.ToString();
bool success = _masterPage.ToolkitBo.UpdateDueandBoardDateForToolkit(myUniqueId,
Convert.ToDateTime(labeloneText), null, _currentUser.FullName);

// Rebind the toolkit list to reflect the changes.
ToolkitList.Rebind();

// If it was not successful, throw an error.
if (!success)
{
throw new InvalidOperationException("Failed to add new due date.");
}
}
}
}

}
catch (Exception err)
{
                
 }
Princy
Top achievements
Rank 2
 answered on 26 Aug 2014
4 answers
540 views

For example

There is a radgrid whose width is 3000 px, and the resolution of my scree is 1920 * 1080.

Because of 1920 < 3000,  there is scroll bar in this radgrid.

This problem is that the grid's width is not set  (Means Auto? I guess...).

I tried to get value from RadGrid1Width but get nothing.

I also tried count all column width with loop like...

-----------------------------------------------------
double TotalSize = 0;

foreach (GridItem tmpIt in p_Grid.MasterTableView.Columns)
{
    TotalSize += tmpIt.Width.Value;
}
//TotalSize == 0.0
-----------------------------------------------------

How can I get 3000 px from the radgrid?

If I need to count all the column's width, what event I could use?

Thanks.
Princy
Top achievements
Rank 2
 answered on 26 Aug 2014
2 answers
175 views
I am using the sticky footer example and also a master page.  I have added a asp:panel inside a LayoutColumn which is in a LayoutRow and that of course is inside a RadPageLayout.

I can manually add the button and the panel to the ajax manager but the loading panel is never fired.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ButtonContact">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelContactForm" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Glow" MinDisplayTime="5000">
        </telerik:RadAjaxLoadingPanel>

If I try to use the ajax config wizard then neither the button or the panel are available to me. How can I reference them so they are ajax-ed? I have tried multiple combinations of the following as well.

protected void Page_Load(object sender, EventArgs e)
       {
           Panel PanelContactForm1 = (Panel)PageLayoutMaster.FindControl("PanelContactForm");
           Button ButtonContact1 = (Button)PanelContactForm1.FindControl("ButtonContact");
           RadAjaxManager1.AjaxSettings.AddAjaxSetting(ButtonContact1, PanelContactForm1);
       }

Thanks, Marty



moegal
Top achievements
Rank 1
 answered on 25 Aug 2014
1 answer
209 views
I have a RadTreeView on a form that is being populated by code with the node.add method described in your documentation. (http://www.telerik.com/help/aspnet-ajax/treeview-load-on-demand-client.html)  It works great for loading the items, but when you click one or do anything that causes a PostBack, all the items disappear.

APSX
<%@ Page Title="" Language="C#"  MasterPageFile="~/Content/themes/Level_One.Master" AutoEventWireup="true" CodeBehind="RequestManager.aspx.cs" Inherits="WebApplication.Forms.RequestManager" %>
 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ MasterType VirtualPath="~/Content/themes/Level_One.Master" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%: System.Web.Optimization.Styles.Render("~/Content/css") %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main_placeholder" runat="server">
    <telerik:RadCodeBlock ID="cb1" runat="server">
        <script type="text/javascript">
            function mngRequestStarted(ajaxManager, eventArgs) {
                // alert(eventArgs.get_eventTargetElement())
                var newArr = new Array();
                for (var name in ajaxManager) {
                    newArr.push(name + "<-->" + ajaxManager[name])
 
                }
            }
 
        </script>
    </telerik:RadCodeBlock>
 
    <telerik:RadScriptManager ID="main_radscriptmanager" runat="server" EnableViewState="true"></telerik:RadScriptManager>
    <telerik:RadAjaxLoadingPanel ID="main_loading" runat="server" Skin="Metro" EnableViewState="true"></telerik:RadAjaxLoadingPanel>
 
        <telerik:RadAjaxManager ID="main_ajaxmanager" runat="server" EnableAJAX="true" EnableViewState="true" ClientEvents-OnRequestStart="mngRequestStarted">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="tvRequestList">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="tvRequestList" LoadingPanelID="main_loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
 
                <telerik:AjaxSetting AjaxControlID="main_windowmanager">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="main_windowmanager" LoadingPanelID="main_loading" />
                        <telerik:AjaxUpdatedControl ControlID="wndw_permissions" LoadingPanelID="main_loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnSave" EventName="Click">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnSave" UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnCancel"></telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
 
    <asp:Button ID="cmdTest" runat="server" OnClick="cmdTest_Click" />
    <telerik:RadSplitter ID="RadSplitter1" runat="server" Height="700px" Width="100%" EnableViewState="false">
          <telerik:RadPane ID="Pane1" runat="server" Height="100%" Width="20%">
               <telerik:RadTreeView ID="tvRequestList" runat="server"
                   Skin="Metro" PersistLoadOnDemandNodes="true"
                   OnNodeExpand="tvRequestList_NodeExpand"
                   OnNodeClick="tvRequestList_NodeClick">
 
               </telerik:RadTreeView>
          </telerik:RadPane>
          <telerik:RadSplitBar ID="RadSplitbar1" runat="server" CollapseMode="Forward">
          </telerik:RadSplitBar>
          <telerik:RadPane ID="Pane2" runat="server">
               Pane2 - 100px
          </telerik:RadPane>
  <%--        <telerik:RadSplitBar ID="Radsplitbar2" runat="server" CollapseMode="Forward">
          </telerik:RadSplitBar>
          <telerik:RadPane ID="Pane3" runat="server" Height="150">
               Pane3 - 150px
          </telerik:RadPane>--%>
     </telerik:RadSplitter>
    <telerik:RadWindowManager runat="server" ID="RadWindowManager1" EnableViewState="true"></telerik:RadWindowManager>
</asp:Content>

Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jabil.Core;
using DataEntities.Application.Context;
using DataEntities.Application.Entities;
using Telerik.Web.UI;
using System.Collections;
using System.Collections.Generic;
 
namespace WebApplication.Forms
{
    public partial class RequestManager : FrameworkPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.PageTitle = "Request Manager";
 
            if (!IsPostBack)
            {
                LoadRootNodes(tvRequestList);
            }
        }
 
        private void LoadRootNodes(RadTreeView tv)
        {
            using (RequestsDataContext rdc = new RequestsDataContext(string.Empty))
            {
                List<RequestManagerTreeList> tl = rdc.GetRequestManagerTreeViewList(1, 0, false).ToList<RequestManagerTreeList>();
                foreach (RequestManagerTreeList tlItem in tl)
                {
                    RadTreeNode tn = new RadTreeNode();
                    tn.Text = tlItem.ItemName;
                    tn.Value = ("L1" + tlItem.ItemId.ToString());
                    tn.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
                    tv.Nodes.Add(tn);
                }
            }
        }
 
        protected void tvRequestList_NodeExpand(object sender, RadTreeNodeEventArgs e)
        {
            try
            {
                using (RequestsDataContext rdc = new RequestsDataContext(string.Empty))
                {
                    string itemValue = e.Node.Value;
 
                    if (itemValue.Substring(0, 1) == "L")
                    {
                        int level = Convert.ToInt32(itemValue.Substring(1, 1)) + 1;
                        int itemId = Convert.ToInt32(itemValue.Substring(2, itemValue.Length - 2).ToString());
                        string levelTag = "L" + level.ToString();
                        List<RequestManagerTreeList> tl = rdc.GetRequestManagerTreeViewList(level, itemId, false).ToList<RequestManagerTreeList>();
                        foreach (RequestManagerTreeList tlItem in tl)
                        {
                            RadTreeNode tn = new RadTreeNode();
                            tn.Text = tlItem.ItemName;
                            tn.Value = levelTag + tlItem.ItemId.ToString();
                            if (level < 3)
                            {
                                tn.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
                            }
                            e.Node.Nodes.Add(tn);
 
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                show_error_message(ex.Message);
            }
        }
 
        protected void tvRequestList_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            show_error_message("Test");
        }
 
        private void show_error_message(string error_message)
        {
 
            string error = error_message.Replace("'", "");
 
 
            main_ajaxmanager.ResponseScripts.Add(string.Format("window.radalert(\"" + error + "\")"));
 
        }
 
        protected void cmdTest_Click(object sender, EventArgs e)
        {
            show_error_message("Test");
        }
    }
}

Scott
Top achievements
Rank 1
 answered on 25 Aug 2014
2 answers
118 views
Hi,

I'm calling a page containing a data pager. Part of my initial call url is a page number I would like to go to.
I searched around and tried a lot of things without success:
- FireCommand
- SEO Paging

What is the designed way to specify a start page for a data pager?

THANKS!
Jens-Thomas
Top achievements
Rank 1
 answered on 25 Aug 2014
2 answers
160 views
I have an application where I am dynamically creating a group of tabs, each one with a radgrid on it, from the code behind.  The radgrid includes a TemplateColumnEdit column (GridEditCommandColumn cannot be used because the link fires javascript to decide based on row data which of 7 types of dialog to present for editing).  Here is a portion of the code:

var colEdit = new GridTemplateColumn();
colEdit.UniqueName = "TemplateEditColumn";
colEdit.AllowFiltering = false;
colEdit.HeaderStyle.Width = Unit.Percentage(5);
colEdit.ItemStyle.VerticalAlign = VerticalAlign.Top;
colEdit.ItemTemplate = new TemplateColumnEdit("EditLink");

The column always says "Edit" regardless of the language/culture.  I need either to translate it, or to display ~/App_Themes/Default/RadGrid/Edit.gif.  How can this be accomplished from code behind?

Thank you.
Princy
Top achievements
Rank 2
 answered on 25 Aug 2014
17 answers
709 views
I have problem with the AutoCompleteBox where i get an Object reference not set to an instance of an object error in popup.

I have the placed the control inside a DetailsView like this

<InsertItemTemplate>
 <telerik:RadComboBox ID="CmbChemicalsInsertMode" CheckBoxes="true" Filter="Contains" HighlightTemplatedItems="true" ExpandDirection="Up" MarkFirstMatch="true" AllowCustomText="true" DataTextField="Name" EmptyMessage="Vælg stoffer" Runat="server">
</telerik:RadComboBox>
 <asp:ImageButton ID="BtnAddChemical" CausesValidation="false" ToolTip="Tilføj valgte" width="15px" height="15px" ImageUrl="~/Images/plus.png" OnClick="BtnAddChemical_Click" runat="server" ></asp:ImageButton>
<telerik:RadTextBox ID="TxtDeclaration" TextMode="MultiLine" Rows="5" Text='<%# DataBinder.Eval(Container, "DataItem.Declaration") %>' Runat="server" Skin="Metro"
              Width="170px" />
               
 <telerik:RadAutoCompleteBox ID="RACBChemicals"  InputType="Token" AllowCustomEntry="true" Skin="Metro" DataTextField="Name" DropDownWidth="400"
    DropDownHeight="250" Runat="server"></telerik:RadAutoCompleteBox>
</InsertItemTemplate>

The detailsview is located inside a RadWindow. As soon as i start typing something in the field, i get the previous mentioned popup error.
As soon as i try to move the AutoCompleteBox outside of the DetailsView, the error stops and the control works fine

Martin
Top achievements
Rank 2
 answered on 25 Aug 2014
3 answers
360 views
Hi Guys,

I'm trying to create a chart with multiple line series' below is my code:



string
sql = string.Format(@"SELECT     dbo.ProductSales.OrderDate, dbo.ProductSales.ProductID, dbo.ProductSales.UnitsSold, dbo.Product.Name
                                    FROM         dbo.ProductSales INNER JOIN
                      dbo.Product ON dbo.ProductSales.ProductID = dbo.Product.ProductID
 
                                    WHERE     (DistributionCentreID = 3) AND (dbo.Product.ProductID = 10)
                                    GROUP BY dbo.ProductSales.OrderDate, dbo.ProductSales.ProductID, dbo.ProductSales.UnitsSold, dbo.Product.Name
                                    HAVING      (OrderDate >= CONVERT(DATETIME, '01/10/2013', 103)) AND (OrderDate <= CONVERT(DATETIME, '10/10/2013', 103))");
        SqlUtils db = new SqlUtils("Charon");
 
        try
        {
            DataTable dt = db.FillTable(sql);
 
            RadHtmlChart htmlChart = new RadHtmlChart();
            htmlChart.ID = "htmlChart";
            htmlChart.Width = Unit.Pixel(680);
            htmlChart.Height = Unit.Pixel(400);
 
            htmlChart.Legend.Appearance.Position = ChartLegendPosition.Bottom;
 
            htmlChart.PlotArea.XAxis.TitleAppearance.Text = "Date";
            htmlChart.PlotArea.YAxis.TitleAppearance.Text = "Units Sold";
 
            htmlChart.PlotArea.XAxis.MajorTickType = TickType.Outside;
 
            htmlChart.PlotArea.XAxis.MinorTickType = TickType.Outside;
 
            //htmlChart.PlotArea.XAxis.DataLabelsField = row["OrderDate"].ToString();
 
 
 
            foreach (DataRow row in dt.Rows)
            {
                var lineSeries = new LineSeries { Name = row["Name"].ToString() };
 
 
                lineSeries.LabelsAppearance.Visible = true;
                lineSeries.TooltipsAppearance.Color = System.Drawing.Color.White;
                lineSeries.TooltipsAppearance.DataFormatString = string.Format("{0} x {1}", row["UnitsSold"], row["Name"]);
                lineSeries.DataFieldY = "UnitsSold";
                lineSeries.DataFieldX = "OrderDate";
 
                //SeriesItem seriesItem = new SeriesItem();
 
                var unitsSold = (int)row["UnitsSold"];
 
                //lineSeries.SeriesItems.Add(unitsSold);
 
                CategorySeriesItem seriesItem1 = new CategorySeriesItem();
 
                seriesItem1.Y = unitsSold;
 
                lineSeries.SeriesItems.Add(seriesItem1);
 
                htmlChart.PlotArea.Series.Add(lineSeries);
 
            }
 
 
 
            HtmlChartHolder.Controls.Add(htmlChart);
 
            //LineChart.DataSource = trendAnalysisbyDate(1);
            //LineChart.DataBind();
        }
        finally
        {
            db.Close();
        }



Example Data & how the chart currently looks is attached...

I've just hidden the Name column.. just a text string..

I want the chart to show Units Sold on the left (y axis) and the order date on the bottom (x axis) and the product name to the be label/ledgend..

Any help would be great. Thanks!



Shinu
Top achievements
Rank 2
 answered on 25 Aug 2014
2 answers
381 views
Hi,
I am working on a menu using a RadGrid. developing in C#

I have a MasterTableView that contains the Main information, and one GridTableView in DetailTables. (Check menu attach file)
Once I click the expanded icon on then master table, the grid table view is displayed.

I am looking at selecting a record on the GridTableView (by clicking on the record) to open a form.

However the OnSelectedIndexChanged is not firing.
So I don't know if it should be set up diferently when in a GridTableView (as it is working if I put the event in the RadGrid at a higher level)
Or if I should use another event.

This is how I have set it up (Check html file attached for more details):
- EnablePostBackOnRowClick="true" in the Client settings of the RadGrid.
- OnSelectedIndexChanged="GV_SelectedIndexChanged" set up in the GridTableView, and the C# code added accordingly.

Thank you for your help.

Anne
Anne
Top achievements
Rank 1
 answered on 25 Aug 2014
0 answers
134 views
 
hello 

I am using Telerik ReportViewer to display reports,
But when I print report ,it  exports to pdf instead of printing. as shown in attached image.



please help.
Kishor
Top achievements
Rank 2
 asked on 25 Aug 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?