Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
75 views

Hi,

Appointment popup is not close after click on save/close button.

Here is my clode.

aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="vendorzone.aspx.cs" Inherits="MwsMainGui.vendorzone" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Scheduler demo</title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <div class="demo-container no-bg">
            <telerik:RadScheduler runat="server" ID="RadScheduler1" DayStartTime="08:00:00" DayEndTime="18:00:00" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
                OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" DisplayDeleteConfirmation="true" OnAppointmentDelete="RadScheduler1_AppointmentDelete"
                DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"
                DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentId"
                DataReminderField="Reminder" AppointmentStyleMode="Simple" FirstDayOfWeek="Monday">
                <AdvancedForm Modal="true"></AdvancedForm>
                <TimelineView UserSelectable="false"></TimelineView>
                <TimeSlotContextMenuSettings EnableDefault="true">
                </TimeSlotContextMenuSettings>
                <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
                <Reminders Enabled="false"></Reminders>
            </telerik:RadScheduler>
        </div>
    </form>
</body>
</html>

 

aspx.cs page :

 

 public partial class vendorzone : System.Web.UI.Page
    {
        private const string AppointmentsKey = "Scheduler";

        private List<AppointmentInfo> Appointments
        {
            get
            {
                List<AppointmentInfo> sessApts = Session[AppointmentsKey] as List<AppointmentInfo>;
                if (sessApts == null)
                {
                    sessApts = new List<AppointmentInfo>();
                    Session[AppointmentsKey] = sessApts;
                }

                return sessApts;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!IsPostBack)
            {
                Session.Remove(AppointmentsKey);
                InitializeResources();
                InitializeAppointments();
            }

            RadScheduler1.DataSource = Appointments;
        }

        protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Add(new AppointmentInfo(e.Appointment));
        }

        protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
            AppointmentInfo appointmentInfo = FindById(e.ModifiedAppointment.ID);
            RecurrenceRule rrule;

            if (RecurrenceRule.TryParse(e.ModifiedAppointment.RecurrenceRule, out rrule))
            {
                rrule.Range.Start = e.ModifiedAppointment.Start;
                rrule.Range.EventDuration = e.ModifiedAppointment.End - e.ModifiedAppointment.Start;
                TimeSpan startTimeChange = e.ModifiedAppointment.Start - e.Appointment.Start;
                for (int i = 0; i < rrule.Exceptions.Count; i++)
                {
                    rrule.Exceptions[i] = rrule.Exceptions[i].Add(startTimeChange);
                }
                e.ModifiedAppointment.RecurrenceRule = rrule.ToString();
            }

            appointmentInfo.CopyInfo(e.ModifiedAppointment);
            RadScheduler1.DataSource = Appointments;
        }

        protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Remove(FindById(e.Appointment.ID));
        }

        private void InitializeResources()
        {
            ResourceType resType = new ResourceType("User");
            resType.ForeignKeyField = "UserID";

            RadScheduler1.ResourceTypes.Add(resType);
            RadScheduler1.Resources.Add(new Resource("User", 1, "Alex"));
            RadScheduler1.Resources.Add(new Resource("User", 2, "Bob"));
            RadScheduler1.Resources.Add(new Resource("User", 3, "Charlie"));
        }

        private void InitializeAppointments()
        {
            DateTime start = DateTime.UtcNow.Date;
            start = start.AddHours(6);
            Appointments.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, new Reminder(30).ToString(), 1));
            Appointments.Add(new AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));

            start = start.AddDays(-1);
            DateTime dayStart = RadScheduler1.UtcDayStart(start);
            Appointments.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, string.Empty, 1));
            Appointments.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));

            start = start.AddDays(2);
            Appointments.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
        }

        private AppointmentInfo FindById(object ID)
        {
            foreach (AppointmentInfo ai in Appointments)
            {
                if (ai.ID.Equals(ID))
                    return ai;
            }
            return null;
        }

        class AppointmentInfo
        {
            private readonly string _id;
            private string _subject;
            private DateTime _start;
            private DateTime _end;
            private string _recurrenceRule;
            private string _recurrenceParentId;
            private string _reminder;
            private int? _userID;

            public string ID
            {
                get
                {
                    return _id;
                }
            }

            public string Subject
            {
                get
                {
                    return _subject;
                }
                set
                {
                    _subject = value;
                }
            }

            public DateTime Start
            {
                get
                {
                    return _start;
                }
                set
                {
                    _start = value;
                }
            }

            public DateTime End
            {
                get
                {
                    return _end;
                }
                set
                {
                    _end = value;
                }
            }

            public string RecurrenceRule
            {
                get
                {
                    return _recurrenceRule;
                }
                set
                {
                    _recurrenceRule = value;
                }
            }

            public string RecurrenceParentID
            {
                get
                {
                    return _recurrenceParentId;
                }
                set
                {
                    _recurrenceParentId = value;
                }
            }

            public int? UserID
            {
                get
                {
                    return _userID;
                }
                set
                {
                    _userID = value;
                }
            }

            public string Reminder
            {
                get
                {
                    return _reminder;
                }
                set
                {
                    _reminder = value;
                }
            }

            private AppointmentInfo()
            {
                _id = Guid.NewGuid().ToString();
            }

            public AppointmentInfo(string subject, DateTime start, DateTime end,
                string recurrenceRule, string recurrenceParentID, string reminder, int? userID)
                : this()
            {
                _subject = subject;
                _start = start;
                _end = end;
                _recurrenceRule = recurrenceRule;
                _recurrenceParentId = recurrenceParentID;
                _reminder = reminder;
                _userID = userID;
            }

            public AppointmentInfo(Appointment source)
                : this()
            {
                CopyInfo(source);
            }

            public void CopyInfo(Appointment source)
            {
                Subject = source.Subject;
                Start = source.Start;
                End = source.End;
                RecurrenceRule = source.RecurrenceRule;
                if (source.RecurrenceParentID != null)
                {
                    RecurrenceParentID = source.RecurrenceParentID.ToString();
                }

                if (!String.IsNullOrEmpty(Reminder))
                {
                    Reminder = source.Reminders[0].ToString();
                }

                Resource user = source.Resources.GetResourceByType("User");
                if (user != null)
                {
                    UserID = (int?)user.Key;
                }
                else
                {
                    UserID = null;
                }
            }
        }

}

 

Help me.

 

Thanks,

Ankita​

Maria Ilieva
Telerik team
 answered on 16 Jun 2015
3 answers
158 views

Hello,

I'm just sticking with a problem regarding the viewstate of a RadButton.

I want to create a RadButton dynamically and use it then further on. This given, I have two szenarios:

1. I create a RadButton and check it with the mouse. On the following PostBack, everything is OK and the checked- property has the expeted value.

2. I create a RadButton and check it during creation. If I don't change the state in the frontend, then the checked- property is alsways false, not matter, what I set it to.

The shown value of the RadButton is always correct, until the mysterious PostBack. If I try to produce the behaviour with the ASP:CheckBox, everything works fine.

Has somebody a hint, what my mistake is?

Yours Aljoscha

 

Here is my example code to reproduce:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!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>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <div id="myDiv" runat="server">
            <telerik:RadButton runat="server" OnClick="Unnamed_Click"></telerik:RadButton>
            <asp:Label runat="server" ID="lbText"></asp:Label>
        </div>
 
    </form>
</body>
</html>

protected void Page_Load(object sender, EventArgs e)
   {
 
       RadButton rb = (RadButton)LoadControl(typeof(RadButton), new object[0]);
       // RadButton rb = new RadButton();
       rb.ID = "Test1234";
       rb.ButtonType = RadButtonType.ToggleButton;
       rb.ToggleType = ButtonToggleType.CheckBox;
       rb.Text = "Testcheck RadButton";
       rb.AutoPostBack = false;
 
       CheckBox cb = new CheckBox();
       cb.ID = "Test3456";
       cb.Text = "Testcheck CheckBox";
       cb.AutoPostBack = false;
 
       if (!IsPostBack)
       {
           rb.Checked = true;
           cb.Checked = true;
       }
 
       myDiv.Controls.Add(rb);
       myDiv.Controls.Add(cb);
   }
 
   protected void Unnamed_Click(object sender, EventArgs e)
   {
       foreach (Control ctrl in myDiv.Controls)
       {
           if (ctrl is RadButton)
           {
               RadButton rb = ctrl as RadButton;
               lbText.Text += "RadButton " + rb.ID + " : " + rb.Checked.ToString() + "<br/>\r\n";
           }
 
           if (ctrl is CheckBox)
           {
               CheckBox cb = ctrl as CheckBox;
               lbText.Text += "CheckBox " + cb.ID + " : " + cb.Checked.ToString() + "<br/>\r\n";
           }
       }
   }

 

Danail Vasilev
Telerik team
 answered on 16 Jun 2015
11 answers
1.7K+ views
hi
i am using radgrid to  export data from radgrid to excel.i want the excel format with total and total should be highlighted like some colors and i am not using bound fields in  radgrid .i am using column created by  programmatic

(thanks )
suresh.S
Daniel
Telerik team
 answered on 16 Jun 2015
3 answers
215 views

I have the following code setup in the onKeyPressing event of my RadComboBox.  When I execute it, if there are multiple results from the callback, the dropdown quickly opens and shuts (line 65 is where I open the combo box).  Based on my interpretation of the client side events, the combo box should remain open.  

I've also tried executing the .commitChanges() call before the .showDropDown() as well as attempted to event_args.setCancel(true), but neither worked. 

What am I missing?

01.function rrKeyPress(sender, eventArgs) {
02.    if (eventArgs.get_domEvent().keyCode == 13) {
03. 
04.        var clientId = sender.get_id();
05.        //var comboBox = document.getElementById(clientId);
06. 
07.        var comboBox = $find(clientId);
08.         
09.        var userEntry = comboBox._text;
10.        var matches = document.getElementById('txtNumEntries').value;
11. 
12.        var epmsDataHandler = '<%= ResolveUrl("~/EPMSDataHandler.ashx") %>';
13.        var randomNum = Math.round(+new Date() / 1000);
14. 
15.        var xhReq = new XMLHttpRequest();
16. 
17.        sURL = epmsDataHandler + "?userEntry=" + userEntry + "&matches=" + matches + "&randomNum=" + randomNum;
18. 
19.        xhReq.open("GET", sURL, false);
20.        xhReq.send(null);
21. 
22.        comboBox.clearItems();
23. 
24.        try {
25.            var response = xhReq.responseText;
26.            var fileError = 'ERRORMESSAGE';
27.            if (xhReq.responseText.substr(0, fileError.length) == fileError) {
28.                alert(xhReq.responseText.substr(fileError.length + 1, xhReq.responseText.length - fileError.length));
29.            }
30.            else {
31.                var jsonData = $.parseJSON(response);
32.                var numMatches = 0;
33.                var selectedItem = new Telerik.Web.UI.RadComboBoxItem();
34.                var firstDisplayName = "";
35. 
36.                for (var x = 0; x < jsonData.matches.length; x++) {
37.                    var match = jsonData.matches[x];
38. 
39.                    var comboItem = new Telerik.Web.UI.RadComboBoxItem();
40.                     
41.                    var displayName = match.fullName + " - " + match.id + " - " + match.rank;
42. 
43.                    if (x == 0)
44.                    {
45.                        firstDisplayName = displayName;
46.                    }
47. 
48.                    comboItem.set_value(match.id);
49.                    comboItem.set_text(displayName);
50. 
51.                    comboBox.get_items().add(comboItem);
52.                    numMatches++;
53.                    selectedItem == comboItem;
54.                }
55. 
56.                if (numMatches == 1)
57.                {                           
58.                    var item = comboBox.findItemByText(firstDisplayName);
59.                    if (item) {
60.                        item.select();
61.                    }
62.                }
63.                else
64.                {
65.                    comboBox.showDropDown();
66.                }
67. 
68.                document.getElementById('lblNumMatches').innerHTML = numMatches;
69. 
70.                comboBox.commitChanges();
71. 
72.            }
73.        }
74.        catch (ex) { alert("Error getting matching values - " + ex.message); return false; }
75.    }
76.}

Nencho
Telerik team
 answered on 16 Jun 2015
1 answer
184 views

Hi,

 I've removed the column borders of RadGrids with this:

.RadGrid_Bootstrap .rgRow td, .RadGrid_Bootstrap .rgEditRow td, .RadGrid_Bootstrap .rgFooter td
{
    border-left-style: none !important;
}

This works fine with other themes, but using Bootstrap, the left of the RadComboBox disappears.  See image "RadCombo2.PNG"

I can tell it is inheriting the grid style because if I change the above css to this:

.RadGrid_Bootstrap .rgRow td, .RadGrid_Bootstrap .rgEditRow td, .RadGrid_Bootstrap .rgFooter td
{
    border-left-style: dotted !important;
}

 

 

 

Then it looks like image "RadCombo1.PNG"

How do I keep the grid column lines hidden, but keep the RadCombo full border??

 

Thanks!

Magdalena
Telerik team
 answered on 16 Jun 2015
1 answer
73 views

I am working on increasing the performance of one of our web applications. I have implemented the RadScriptManager and RadStyleSheet Manager into the master pages as well as adding the 2 "add key" lines into the appsetting of the web.config. I also added in the RadCompression to help decrease the weight of files being sent over. I have tried running it with the CDN but it was not loading the pages correctly, so I have disabled the CDN. Running my page on Yslow I have seen a significant drop in the HTTP requests which was a goal, but I have also seen a massive increase in DOM elements. My users are using IE which is not handling the abundance of DOM elements. Can someone explain what might be happening? Is it because I am no longer using the CDN or are there more things I should be adding into my application files?

 

Thanks in advance for any help!

Dimitar Terziev
Telerik team
 answered on 16 Jun 2015
1 answer
103 views

Hi

 What is the easiest way to display data from a MySQL table in a RadGrid?

 How do I connect the grid to the database?

 I need to be able to edit the data too.

 Regards.

Kostadin
Telerik team
 answered on 16 Jun 2015
1 answer
92 views

I have a radgrid with an export button which I was able to exclude from using ajax via ajaxmanager. 
However I now require a prompt to the user to choose an option which affects the data that will be exported.
I use a custom rad prompt template to get a dropdownlist option and use a callback function in javascript which makes
an ajax request passing the parameter containing the dropdownlist option selected and then call my export function which no longer
works. Is there a good workaround so my export will still work after a prompt to the user?

 Thanks for the help.

 

protected void rg_ClientCalculators_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "ExportCalculator")
        {
            ViewState["CalculatorID"] = int.Parse(e.CommandArgument.ToString());
            RadWindowManager1.RadPrompt("Show all line items?", "callbackFn", 300, 300, null, "Calculator Export", " ");     
        }
    }
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Yes")
            ExportCalculator(true);
        else if (e.Argument == "No")
            ExportCalculator(false);       
    }
 
 private void ExportCalculator(bool showAllLineItems)
    {
        Company UsersCompany = DAL.GetCompanyInfo(CurrentUser.UserID);
        var calculatorID = (int)ViewState["CalculatorID"];
        DataTable CalculatorClientInfo = DAL.ExportCalculatorClientInfo(calculatorID);
 
        ReportProcessor Processor = new ReportProcessor();
        InstanceReportSource ReportSource = new InstanceReportSource();
        ClientTrackerReports.CalculatorExport Report = new CalculatorExport();
        Report.ReportParameters["CalculatorID"].Value = calculatorID;
        Report.ReportParameters["CompanyName"].Value = UsersCompany.CompanyName;
        Report.ReportParameters["ClientName"].Value = CalculatorClientInfo.Rows[0]["ClientName"];
        Report.ReportParameters["AnotherVendor"].Value = CalculatorClientInfo.Rows[0]["AnotherVendor"];
        Report.ReportParameters["DateOfStatementProvided"].Value = CalculatorClientInfo.Rows[0]["DateOfStatementProvided"];
        Report.ReportParameters["ShowAllLineItems"].Value = showAllLineItems;
        ReportSource.ReportDocument = Report;
        ViewState.Remove("CalculatorID");
 
        Hashtable DeviceInfo = new Hashtable();
        RenderingResult Result = Processor.RenderReport("PDF", ReportSource, DeviceInfo);
 
        string FileName = CalculatorClientInfo.Rows[0]["ClientName"].ToString() + "-Pricing." + Result.Extension;
 
        Response.Clear();
        Response.ContentType = Result.MimeType;
        Response.Cache.SetCacheability(HttpCacheability.Private);
        Response.Expires = -1;
        Response.Buffer = true;
 
        Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", FileName));
        Response.BinaryWrite(Result.DocumentBytes);
        Response.End();
 
    }

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function callbackFn(arg) {
                    if (arg) {
                        $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(arg);
                    }
 
                }
            </script>
        </telerik:RadCodeBlock>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
         <PromptTemplate>
                <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                    <script type="text/javascript">
                        function closePrompt(winid) {
                            var select = document.getElementById('select' + winid);
                            var selectedValue = select.options[select.selectedIndex].value;
 
                            var confirmWnd = $find(winid);
                            confirmWnd.close(selectedValue);
 
                        }
                    </script>
                </telerik:RadCodeBlock>
                <div class="windowpopup radprompt">
                    <div class="dialogtext">
                        {1}
                    </div>
                    <div>
                        <select id="select{0}">
                            <option value="Yes">Yes</option>
                            <option value="No">No</option>
                        </select>
                    </div>
                    <div>
                        <input type="button" onclick="closePrompt('{0}');" value="OK" />
                        <input type="button" onclick="$find('{0}').close();" value="Cancel" />
                    </div>
                </div>
                </div>
            </PromptTemplate>
    </telerik:RadWindowManager>

Marin Bratanov
Telerik team
 answered on 16 Jun 2015
0 answers
67 views

Hello,

Does anyone can help me with a simple example for the data validation inside radwindow as modal dialog.

Thank you.

Ahmed
Top achievements
Rank 1
 asked on 16 Jun 2015
1 answer
134 views

I am looking for auto resume upload functionality for dropped internet connection. Is this feature implemented in latest version of telerik controls?

 Ref: http://www.telerik.com/forums/lost-connection-during-upload

 

 

Plamen
Telerik team
 answered on 16 Jun 2015
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?