Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
144 views
I am building up the grid dynamically based on metadata. When I started building the grid, the sorting and grouping worked. Then after some time I found out that it is not working anymore. When I click on the column header, the SortCommand event is not raised. I checked that the AllowSorting property is set to true.

I tried to find out what caused the sorting to stop working, but cannot find it. What could cause this?

PS I use the __EVENTARGS in a postback to indicate what action the user wants to be performed. Do you use that too?
Ewald
Top achievements
Rank 1
 answered on 15 Oct 2011
2 answers
364 views
Hello,

I have created a composite control with the RadDatePicker and 2 CompareValidators and 1 CustomValidator.  When I try to attach the RadDatePicker to a RequiredFieldValidator from the calling page i am getting the Error

Unable to find control id 'calendarControl_CtcRadDatePicker' referenced by the 'ControlToValidate' property of 'reqValidator'.


Control
/// <summary>
    /// Summary description for CalendarControl
    /// </summary>
    [ToolboxData("<{0}:CalendarControl runat=server></{0}:CalendarControl>")]
    [ValidationProperty("SelectedDate")]
    public class CalendarControl : CompositeControl
    {
        private const string DEFAULT_SKIN = "CentreTelerik";

        private RadDatePicker _radDatePicker;
        private CompareValidator _cpvMaxDateOccurred;
        private CompareValidator _cpvMinDateOccurred;
        private CustomValidator _custValidator;

        public CalendarControl()
        {

        }

        #region Instance properties

        public DateTime MinDate
        {
            get { return (DateTime)(ViewState["CtcMinDate"] ?? _radDatePicker.MinDate); }
            set
            {
                ViewState["CtcMinDate"] = value;
                EnsureChildControls();
                _radDatePicker.MinDate = value;
            }
        }

        public DateTime MaxDate
        {
            get { return (DateTime)(ViewState["CtcMaxDate"] ?? _radDatePicker.MaxDate); }
            set
            {
                ViewState["CtcMaxDate"] = value;
                EnsureChildControls();
                _radDatePicker.MaxDate = value;
            }
        }

        public DateTime SelectedDate
        {
            get { EnsureChildControls(); return _radDatePicker.SelectedDate.GetValueOrDefault(); }
            set { EnsureChildControls(); _radDatePicker.SelectedDate = value; }
        }

        public string ClientIDWrapper
        {
            get { EnsureChildControls(); return _radDatePicker.ClientID; }
        }

        #endregion

        #region Override Instance methods

        protected override ControlCollection CreateControlCollection()
        {
            EnsureChildControls();
            return base.CreateControlCollection();
        }

        protected override void CreateChildControls()
        {
            Controls.Clear();

            base.CreateChildControls();

            _radDatePicker = new RadDatePicker();
            _radDatePicker.ID = "CtcRadDatePicker";
            _radDatePicker.EnableEmbeddedSkins = false;
            _radDatePicker.Calendar.EnableEmbeddedSkins = false;
            _radDatePicker.Calendar.ShowRowHeaders = false;
            _radDatePicker.DateInput.EnableEmbeddedSkins = false;

            _cpvMaxDateOccurred = new CompareValidator();
            _cpvMaxDateOccurred.ID = "CtcMaxValidator";
            _cpvMaxDateOccurred.Type = ValidationDataType.Date;
            _cpvMaxDateOccurred.Operator = ValidationCompareOperator.LessThanEqual;
            _cpvMaxDateOccurred.Display = ValidatorDisplay.Dynamic;
            _cpvMaxDateOccurred.ControlToValidate = _radDatePicker.ClientID;
            _cpvMaxDateOccurred.ValueToCompare = _radDatePicker.MaxDate.ToShortDateString();
            _cpvMaxDateOccurred.SetFocusOnError = true;

            _cpvMinDateOccurred = new CompareValidator();
            _cpvMinDateOccurred.ID = "CtcMinValidator";
            _cpvMinDateOccurred.Type = ValidationDataType.Date;
            _cpvMinDateOccurred.Operator = ValidationCompareOperator.GreaterThanEqual;
            _cpvMinDateOccurred.Display = ValidatorDisplay.Dynamic;
            _cpvMinDateOccurred.ControlToValidate = _radDatePicker.ClientID;
            _cpvMinDateOccurred.ValueToCompare = _radDatePicker.MinDate.ToShortDateString();
            _cpvMinDateOccurred.SetFocusOnError = true;

            _custValidator = new CustomValidator();
            _custValidator.ID = "CtcCustomValidatorInvalidDate";
            _custValidator.ControlToValidate = _radDatePicker.ClientID;
            _custValidator.Display = ValidatorDisplay.Dynamic;
            _custValidator.ErrorMessage = "Invalid Date";

            Controls.Add(_radDatePicker);
            Controls.Add(_cpvMaxDateOccurred);
            Controls.Add(_cpvMinDateOccurred);
            Controls.Add(_custValidator);

            FooterTemplate template = new FooterTemplate(_radDatePicker.ClientID, "Today", !IsTodayDisabled());
            _radDatePicker.Calendar.FooterTemplate = template;

            
        }

        protected override void OnDataBinding(EventArgs e)
        {
            EnsureChildControls();
            base.OnDataBinding(e);
        }

        protected override void OnPreRender(EventArgs e)
        {
            _radDatePicker.Skin = DEFAULT_SKIN;
            _radDatePicker.DateInput.Skin = DEFAULT_SKIN;
            _radDatePicker.Calendar.Skin = DEFAULT_SKIN;
            _radDatePicker.Enabled = Enabled;
            _radDatePicker.DateInput.ClientEvents.OnError = "CalendarControlOnError";
            _radDatePicker.DatePopupButton.ToolTip = ToolTip;

            _cpvMaxDateOccurred.Enabled = Enabled;
            _cpvMaxDateOccurred.ValueToCompare = _radDatePicker.MaxDate.ToShortDateString();
            _cpvMaxDateOccurred.ErrorMessage = "Max date error";

            _cpvMinDateOccurred.Enabled = Enabled;
            _cpvMinDateOccurred.ValueToCompare = _radDatePicker.MinDate.ToShortDateString();
            _cpvMinDateOccurred.ErrorMessage = "Min date error";

            _custValidator.ClientValidationFunction = "CalendarControlClientValidationFunction";
            _custValidator.ValidateEmptyText = true;

            base.OnPreRender(e);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            _radDatePicker.RenderControl(writer);
            _cpvMaxDateOccurred.RenderControl(writer);
            _cpvMinDateOccurred.RenderControl(writer);
            _custValidator.RenderControl(writer);
        }
        #endregion

        #region Private methods
        private bool IsTodayDisabled()
        {
            bool todayDisabled = false;
            foreach (RadCalendarDay disabled in _radDatePicker.Calendar.SpecialDays)
            {
                if (disabled.IsToday)
                {
                    todayDisabled = true;
                    break;
                }
            }
            return todayDisabled;
        }
        #endregion


        sealed class FooterTemplate : ITemplate
        {
            private string _clientId;
            private string _todayText;
            private bool _enabled;

            #region ITemplate Members
            public FooterTemplate(string clientId, string todayText, bool enabled)
            {
                _clientId = clientId;
                _todayText = todayText;
                _enabled = enabled;
            }

            public void InstantiateIn(Control container)
            {
                RadCodeBlock block = new RadCodeBlock();
                block.ID = "footerCodeBlock";

                LiteralControl link = new LiteralControl();
                link.ID = "todayLink";
                link.DataBinding += new EventHandler(link_DataBinding);
                StringBuilder text = new StringBuilder();
                text.Append("<div style=\"text-align:center; width:100%;\">");
                if (_enabled)
                {
                    text.AppendFormat("<a href=\"\" onclick=\"javascript: var picker = $find('{0}');  picker.set_selectedDate(new Date());  picker.hidePopup(); return false;\">{1}</a>", _clientId, _todayText);
                }
                else
                {
                    text.AppendFormat("{0}", _todayText);
                }
                text.Append("</div>");
                link.Text = text.ToString();
                block.Controls.Add(link);

                container.Controls.Add(block);
            }

            void link_DataBinding(object sender, EventArgs e)
            {
                LiteralControl literalControl = (LiteralControl)sender;
                DataListItem list = (DataListItem)literalControl.NamingContainer;
            }
            #endregion
        }
    }
-------------------------------------------------
Calling Page
form id="form1" runat="server">
    <div>
    
        <script type="text/javascript">
        var invalidInput = false;

        function CalendarControlOnError(sender, args) {
            
            sender.updateCssClass();   
            if (args.get_reason() == Telerik.Web.UI.InputErrorReason.OutOfRange) {
                args.set_cancel(true);
                event.cancelBubble = true;
            }
            else {
                //args.set_cancel(true);
                //event.cancelBubble = true;
                invalidInput = true;
            }
        }

        function CalendarControlClientValidationFunction(sender, args) {
            if (invalidInput)
                args.IsValid = false;
            invalidInput = false;
        }
        </script>
        
        <telerik:RadScriptManager ID="radScriptManager" runat="server" />
        <centre:CalendarControl ID="calendarControl" runat="server" />
        
        <asp:RequiredFieldValidator ID="reqValidator" runat="server" ErrorMessage="Required" />
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="Save_OnClick" />
    </div>
-----------------------------------------------
code behind
protected override void OnInit(EventArgs e)
        {
            reqValidator.ControlToValidate = calendarControl.ClientIDWrapper;
            base.OnInit(e);
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                calendarControl.MaxDate = DateTime.Today;
                calendarControl.SelectedDate = DateTime.Today;
            }
        }

        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;
        }

paul
Top achievements
Rank 1
 answered on 14 Oct 2011
1 answer
186 views
I am sure I am missing something simple here.

I have created a function to call a storeproc and want to return the results to a listbox:

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    rgd_CurrentGroups.DataSource = GetGroups()
    rgd_CurrentGroups.DataBind()
    RadListBox1.DataSource = GetGroups().DefaultView
    RadListBox1.DataBind()
End Sub
Private Function GetGroups() As DataTable
    'Dim UserName As String = Request.QueryString("UserName")
    Dim UserName As String = "fred"
    Dim connectionString As String = DirectCast(ConfigurationManager.ConnectionStrings("IT_CentralConnectionString").ConnectionString, String)
    Dim connection As New SqlConnection(connectionString)
    Dim command As New SqlCommand(connectionString, connection)
    command = New SqlCommand("procGetGroupUsers", connection)
    command.CommandType = CommandType.StoredProcedure
    command.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName
    command.Connection.Open()
    Dim myDataAdapter As New SqlDataAdapter(command)
    Dim myDataSet As New DataSet
    Dim dtData As New DataTable
    myDataAdapter.Fill(myDataSet)
    Return myDataSet.Tables(0)
    command.Connection.Close()
End Function

If I use a radgrid the grid populates correctly but if I use a listbox the funtion only returns system.data.datarowview.

Can some one please set me straight.

Thank you.


Allan
Top achievements
Rank 2
 answered on 14 Oct 2011
1 answer
65 views
How can i graph 2 different series against the samy y-axis. I have been able to successfully do 2 series, on the y-axis and secondary y-axis, but now I'd like to have them scaled on the same y-axis.
Becky Bryda
Top achievements
Rank 1
 answered on 14 Oct 2011
2 answers
116 views
When I make a change to the schedule, or if I view the AdvancedEditForm for a particular appointment, I start getting the following error when I hover over an appointment:

Unable to get value of the property 'get_allowDelete': object is null or undefined

If I add a new appointment the page refreshes (via Ajax, not a full postback).  I can hover over the new appointment without a problem, but any existing appointments will throw this error.

When I step through the JavaScript debugger, I see that there is a call to get_element(), and this method looks in the first position of the _domElements array.  In my case, the first entry is null, but the second contains the element that it should be returning.
Chet
Top achievements
Rank 1
 answered on 14 Oct 2011
1 answer
59 views

Hi telerik ppl:

Im using this code to swap languages for the column headers and also for the grouping fields labels within the group panel.
 

protected void RadGrid1_ItemCreated(object sender,GridItemEventArgs e){
            if (e.Item is GridHeaderItem)
            {
                string strControl = "";
                GridHeaderItem headerItem = e.Item as GridHeaderItem;
                headerItem["IDColumn"].Text = GetResource("Document ID");
                headerItem["companyColumn"].Text = GetResource("Company");
                headerItem["nameColumn"].Text = GetResource("Name, First");
                headerItem["dueDateColumn"].Text = UBGlobal.GetResource("Due Date");
                headerItem["ageColumn"].Text = GetResource("Age");
                headerItem["assignedToColumn"].Text = GetResource("Assigned To");
                headerItem["activityTypeCodeColumn"].Text = GetResource("Next Activity");
                headerItem["subjectColumn"].Text = GetResource("Last Activity Notes");
                headerItem["phoneColumn"].Text = GetResource("Phone");
                 
            }
 
 
            if (RadGrid1.GroupPanel.GroupPanelItems.Count > 0)
            {
                RadGrid1.GroupPanel.GroupPanelItems.Count.ToString());
                for (int i = 0; i < RadGrid1.GroupPanel.GroupPanelItems.Count; i++)
                {
                    RadGrid1.GroupPanel.GroupPanelItems[i].Text = GetResource(RadGrid1.GroupPanel.GroupPanelItems[i].Text);
                }
            }           
}

 
The problem here is that the objects within the Group Panel are not being translated when loading the grid or after draging and drop a column into the group panel.......the traslations are only being done when colapsing or expanding the grid rows.

I think this is because the Group Panel doesnt have elements when the ItemCreated Event is fired.....so my questions are:

1.- When is the Group Panel being populated.
and/or
2.- is there a better way to localize the Group Panel elements.......

This must be done in CODEBEHIND.....srry about the caps, are only to emphasize the fact that I cant use the fieldAlias property due to the fact that 3 different language translations must be done and the texts are changed so oftenly.

Thks in advance

Joel
Top achievements
Rank 1
 answered on 14 Oct 2011
1 answer
91 views
Hi,

In loaded event of tree I look through nodes and get reference to <img/> inside each node which is templated through <NodeTemplate>.I want the user to be able to left click on it and see context menu (same context menu as user can see by right clicking on any tree item). This is how I add 'onclick' handler to <img/>:
imgTag.click(nodes[i], function (e) {
    var menu = e.data.get_contextMenu();
    if (menu)
        menu.showAt(e.pageX, e.pageY);
 
    //$telerik.cancelRawEvent(e);
    e.stopPropagation();
});

Now when I click on img I can see the context menu, but no events are fired and obviously postback doesn't happen (regular right click based menu works as expected). I tried with treeView.showNodeContextMenu but it fails internally on get_contextMenu call.

How to fix that? :) Thank you!

Related posts with similar problems:
http://www.telerik.com/community/forums/aspnet-ajax/treeview/show-contextmenu-when-hovering-on-node-instead-of-right-click.aspx
http://www.telerik.com/community/forums/aspnet/treeview/show-context-menu.aspx
Shukhrat Nekbaev
Top achievements
Rank 1
 answered on 14 Oct 2011
1 answer
94 views
Hi guys

I i succsesfuly viev appointments from the sql sever database from my scheduler, Now all my appointments appear in the "all day" slot
While each appointment hav a start time and an end time.

How can i solve this?
Ivana
Telerik team
 answered on 14 Oct 2011
8 answers
243 views

 

 

I am trying to get the user control on th eItemcommand of the grid but it is coming null. can some one please help as in what i am missing in here.

the user control comes null. please help.......
Code Behind

protected
void GridResult_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

 

if (e.CommandName == RadGrid.EditCommandName)

 

{

 

 

GridDataItem item = e.Item as GridDataItem;

 

 

 

UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);

 

(userControl.FindControl(

 

"A") as HiddenField).Value = item["x"].Text;

 

(userControl.FindControl(

 

"B") as HiddenField).Value = item["Y"].Text;

 

}

}

Page Details.
Grid Columns:
this is my button

 

 

<telerik:GridEditCommandColumn UniqueName="actionsCommandColumn" EditText="Go" ButtonType="PushButton">

 

 

 

</telerik:GridEditCommandColumn>

<

 

 

EditFormSettings PopUpSettings-Modal="true" InsertCaption="Actions" UserControlName="CustomControl.ascx"

 

 

 

 

 

 

 

EditFormType="WebUserControl">

 

</EditFormSettings>

 

 

 

 

Pravesh
Top achievements
Rank 1
 answered on 14 Oct 2011
2 answers
544 views
PROBLEM SOLVED
Moderator can close this thread.

On the website there seems to be missing an explicit explanation that After you do an CallbackUpdate you have to add a Javascript function where you do a sender.show() so your notification window could be seen on clientside.

**********************************************************************************************************************************************************

Hello, I started using RadNotification control today and I have encountered a problem that is really weird.

The problem is that I am using a really simple implementation of this control using a callback method on the server, and this the notification doesn't Fire up when the event ends... in Fact it never FIRES up anytime the event ends.

Here is my code (I used the same code provided in the Demo website) REF: http://demos.telerik.com/aspnet-ajax/notification/examples/updateinterval/defaultcs.aspx

The only difference is that I am not using the QuickStart Library or Event Log Console.

(CODE)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ListaBase.UserControls.WebForm1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <br />
    <telerik:RadNotification ID="RadNotification1" runat="server" LoadContentOn="TimeInterval"
        Width="300" Animation="Fade" EnableRoundedCorners="true" EnableShadow="true"
        Title="Received messages" OffsetX="-20" OffsetY="-20"
        TitleIcon="none" UpdateInterval="3000" AutoCloseDelay="1500" OnCallbackUpdate="OnCallbackUpdate">
        <ContentTemplate>
            <asp:Literal ID="lbl" runat="server"></asp:Literal>
        </ContentTemplate>
    </telerik:RadNotification>
     
     
    </div>
    </form>
</body>
</html>


namespace ListaBase.UserControls
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void OnCallbackUpdate(object sender, RadNotificationEventArgs e)
        {
            int newMsgs = DateTime.Now.Second % 10;
            if (newMsgs == 5 || newMsgs == 7 || newMsgs == 8 || newMsgs == 9) newMsgs = 0;
            lbl.Text = "You have " + newMsgs + " new messages!";
            RadNotification1.Value = newMsgs.ToString();
        }
    }
}
Kristian
Top achievements
Rank 2
 answered on 14 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?