Telerik Forums
UI for ASP.NET AJAX Forum
10 answers
409 views
Thanks
An
Top achievements
Rank 1
 answered on 16 Jun 2015
1 answer
297 views

Hi,

I have a RadGrid on my web page in which I am implementing only "Add records" functionality.
When I try to click on "Add" button, nothing happens (it do not show panel to add records in it)

Please reply what mistake I am doing in my code.

Below is the .aspx (say "Default.aspx" page) code:

<telerik:RadMultiPage ID="RadMultiPage4" runat="server" SelectedIndex="0" Width="100%">
                                                                            <telerik:RadPageView ID="RadPageView3" runat="server" Width="100%">
                                                                                <telerik:RadAjaxPanel ID="RadAjaxPanel3" runat="server">
                                                                                            
                                                                                     <asp:label ID="Label2" runat="server" style="display: none;"/>
                                                                               
          <telerik:RadGrid ID="RGGSTChat" runat="server"  AutoGenerateColumns="false"
              ShowStatusBar="true" EnableEmbeddedSkins="true" Skin="Outlook"
              OnNeedDataSource= "rggstChat_NeedDataSource" OnInsertCommand="RGGSTChat_InsertCommand">
 
          <mastertableview commanditemdisplay="Top" autogeneratecolumns="false" datakeynames="ChatID"
            insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True">
                    <CommandItemSettings AddNewRecordText="New" />
                                    <Columns>
                                         
                                        <telerik:GridBoundColumn DataField="ChatID" HeaderText="Id"
                                            UniqueName="ChatID" SortExpression="ChatID" Visible="false">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatTo" HeaderText="To"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatCc" HeaderText="Cc"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
                                         
                                        <telerik:GridBoundColumn DataField="ChatSubject" HeaderText="Subject"
                                            UniqueName="ChatSubject" SortExpression="ChatSubject">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatContent" HeaderText="Content"
                                            UniqueName="ChatContent" SortExpression="ChatContent">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>                                     
                                         
                                    </Columns>
                                    <EditFormSettings>
                                        <EditColumn ButtonType="ImageButton" />
                                    </EditFormSettings>
                                    <PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" />
                   </mastertableview>
            </telerik:RadGrid>
 
 
                                                                                </telerik:RadAjaxPanel>
                                                                            </telerik:RadPageView>
                                                                        </telerik:RadMultiPage>

C# code:

protected void rggstChat_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        Label GUID = fvIPRForm.FindControl("TempGUID") as Label; // RequestID
        RadGrid RGGSTChat = fvIPRForm.FindControl("RGGSTChat") as RadGrid;
        if (!string.IsNullOrEmpty(Request.QueryString["RequestID"]))
        {
            GUID.Text = Request.QueryString["RequestID"];
        }
 
        if (string.IsNullOrEmpty(GUID.Text))
        {
            GUID.Text = Session["GUID"].ToString();
        }
 
        DataTable dt = IPRRequest.SelectChatData(new Guid(GUID.Text));
        RGGSTChat.DataSource = dt;
 
        Response.Write("Page_Load Error. Reason: " + GUID.Text);
    }

protected void RGGSTChat_InsertCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem item = e.Item as GridEditableItem;
 
        Label requestID = fvIPRForm.FindControl("TempGUID") as Label;
 
        string chat_to = (item["lblTo"].Controls[1] as Label).Text;
        string chat_cc = (item["lblCc"].Controls[2] as Label).Text;
        string chat_subj = (item["lblSubject"].Controls[3] as Label).Text;
        string chat_Content = (item["lblContent"].Controls[4] as Label).Text;
        string loginUser = AD_Guard.Checker(Session["LoginUser"].ToString()) + "";
 
        IPRRequest.InsertChatData(new Guid(requestID.Text), chat_to, chat_cc, chat_subj, chat_Content, loginUser);  
    }

This is the .dll (say "abc.cs" page) code, this .dll is used for DB connection:

public static DataTable SelectChatData(Guid requestID)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestId", requestID}
                //{"@ChatID", null},
                //{"@ChatTo", chatTo},
                //{"@ChatCc", chatCC},
                //{"@ChatSubject", chatSubj},
                //{"@ChatContent", chatMsg}
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "Invoice.usp_tbl_Request_Chat_Select", input);           
            return dt;
        }
    
        public static DataTable InsertChatData(Guid requestID, string chat_to, string chat_cc, string chat_subj,
            string chat_Content, string loginUser)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestID", requestID},
                {"@ChatTo", chat_to},
                {"@ChatCc", chat_cc},
                {"@ChatSubject", chat_subj},
                {"@ChatContent", chat_Content},
                {"@CreatedBy", loginUser},
                {"@CreatedDate", DateTime.Now.ToString()}
                 
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "[Invoice].[usp_tbl_Request_Chat_Insert]", input);
            return dt;
        }

 

Konstantin Dikov
Telerik team
 answered on 16 Jun 2015
4 answers
131 views

Hi there,

 The RadcomboBox OnSelectedIndexChanged  event fired unexpected after I refresh page in firefox, however, it is working fine in IE and Chrome. Here is my code and scenario. Please help. Thank you very much.

1 Use firefox to open the page

2 Select value from the first ComboBox

3 Select value from the second ComboBox

4 Refresh Page

5 Click the "Explore" button on the page, the OnSelectedIndexChanged  event of the first RadComboBox got fired in Firefox (working fine in IE and Chrome).

 

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="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>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadFormDecorator ID="FormDecorator1" runat="server"  />
    <div class="qsf-demo-canvas">
        <div class="continents">
            <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="186px"
                AutoPostBack="true"  Filter="Contains" datatextfield="Name" datavaluefield="ID"
                OnDataBound="ddlBox1_DataBound" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
            </telerik:RadComboBox>
        </div>
        <div class="countries">
            <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="186px"
                AutoPostBack="true"  Filter="Contains" datatextfield="Name" datavaluefield="ID"
                OnDataBound="ddlBox2_DataBound" OnSelectedIndexChanged="RadComboBox2_SelectedIndexChanged">
            </telerik:RadComboBox>
        </div>
        <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0" AllowSorting="true"
            GridLines="None" Width="800px">
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID">
                <Columns>
                   
                    <telerik:GridBoundColumn DataField="ID" DataType="System.String"
                        HeaderText="StateID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="Name" DataType="System.String"
                       HeaderText="Name" SortExpression="Name" UniqueName="Name">
                    </telerik:GridDateTimeColumn>
                </Columns>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
        </telerik:RadGrid>
            </div>
        <p class="buttons">
            <asp:Button ID="Button1" runat="server" Text="Explore" OnClick="Button1_Click" />
        </p>
        <div class="result">
            <asp:Label runat="server" ID="Literal1" />
        </div>
    </div>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox2" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadComboBox2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    </form>
</body>
</html>
 

Code behind file:

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Collections.Generic;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    public class State
    {
        public String ID { get; set; }
        public String Name { get; set; }     
    }
 
    public class City
    {
        public String ID { get; set; }
        public String Name { get; set; }
        public String StateID { get; set; }
    }
 
    public List<State> GetStateList()
    {
        List<State> _list = new List<State>();
 
        State d1 = new State();
        d1.Name = "AB";
        d1.ID = "1";
 
        State d2 = new State();
        d2.Name = "BC";
        d2.ID = "2";
 
        State d3 = new State();
        d3.Name = "ON";
        d3.ID = "3";
 
        _list.Add(d1);
        _list.Add(d2);
        _list.Add(d3);
 
        return _list;
    }
 
    public List<City> GetCityList(String _stateID)
    {
        List<City> _list = new List<City>();
        List<City> _newList = new List<City>();
 
        City c1 = new City();
        c1.Name = "Calgary";
        c1.ID = "1";
        c1.StateID = "1";
 
        City c2 = new City();
        c2.Name = "Edmonton";
        c2.ID = "2";
        c2.StateID = "1";
 
        City c3 = new City();
        c3.Name = "Vancouver";
        c3.ID = "3";
        c3.StateID = "2";
 
        City c4 = new City();
        c4.Name = "Victoria";
        c4.ID = "4";
        c4.StateID = "2";
 
        City c5 = new City();
        c5.Name = "Toronto";
        c5.ID = "5";
        c5.StateID = "3";
 
 
        City c6 = new City();
        c6.Name = "Ottawa";
        c6.ID = "6";
        c6.StateID = "3";
 
        _list.Add(c1);
        _list.Add(c2);
        _list.Add(c3);
        _list.Add(c4);
        _list.Add(c5);
        _list.Add(c6);
 
        var _result = _list.Where(t => t.StateID == _stateID);
 
        foreach (var _item in _result)
        {
            City d = new City();
            d.ID = _item.ID;
            d.StateID = _item.StateID;
            d.Name = _item.Name;
            _newList.Add(d);
        }
 
        return _newList;
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            LoadBox1();
    }
 
    protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (e.Value != String.Empty)
        {
            LoadBox2(e.Value);
            List<State> _test = new List<State>();
            RadGrid1.DataSource = _test;
            RadGrid1.DataBind();
        }
    }
 
    protected void RadComboBox2_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (e.Value != String.Empty)
        {
            LoadGrid();
        }
    }
 
    public void LoadGrid()
    {
        RadGrid1.DataSource = GetStateList();
        RadGrid1.DataBind();
    }
 
    protected void LoadBox1()
    {
        RadComboBox1.DataSource = GetStateList();
        RadComboBox1.DataBind();
    }
 
    protected void LoadBox2(string _stateID)
    {
        RadComboBox2.DataSource = GetCityList(_stateID);
        RadComboBox2.DataBind();
    }
 
    protected void ddlBox1_DataBound(object sender, EventArgs e)
    {
        var combo = (RadComboBox)sender;
        combo.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
 
        RadComboBox2.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
    }
 
    protected void ddlBox2_DataBound(object sender, EventArgs e)
    {
        var combo = (RadComboBox)sender;
        combo.Items.Insert(0, new RadComboBoxItem("Please Select", String.Empty));
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Literal1.Text = string.Empty;
    }
}

 


 

Ivan Danchev
Telerik team
 answered on 16 Jun 2015
1 answer
116 views

I have a radgrid associated to a ClientDataSource, inside the RadGrid there is a NestedViewTemplate but i can not make it work. If i change the ClientDataSource for a SqlDataSource it works perfectly:

<telerik:RadGrid 
ID="gvDetalleFactura" 
runat="server" 
AllowSorting="True" 
AutoGenerateColumns="False" 
DataSourceID="SqlDSFacturaDetalle" 
Width="917px" 
>
<ItemStyle CssClass="GridView-ItemStyle" />
<AlternatingItemStyle CssClass="GridView-ItemStyle" />
<HeaderStyle CssClass="GridView-HeaderStyle" />
<HierarchySettings CollapseTooltip="Ocultar Datos..." ExpandTooltip="Mostrar Datos..." />

<MasterTableView 
HierarchyLoadMode="Client"
>
       <ExpandCollapseColumn 
                                        Visible="true" 
                                        ButtonType="ImageButton"
                                        ExpandImageUrl="Images/expand_blue.ico"
                                        CollapseImageUrl="Images/collapse_blue.ico" 
                                        Display="true" 
                                    ></ExpandCollapseColumn>

<NestedViewTemplate>
<asp:Table ID="tblComentarios" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell Width="20%">
<asp:Label ID="lblComentariosSolicitante" runat="server" Text="Comentarios Solicitante:"></asp:Label>
</asp:TableCell>
<asp:TableCell Width="80%">
<telerik:RadTextBox ID="txtComentariosSolicitante" runat="server" 
InvalidStyleDuration="100" 
TextMode="MultiLine"
Width="700px"
>
<hoveredstyle bordercolor="DeepSkyBlue" />
<focusedstyle bordercolor="DeepSkyBlue" backcolor="AliceBlue" />
</telerik:RadTextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</NestedViewTemplate>

<Columns>
<telerik:GridTemplateColumn HeaderText="Posicion" SortExpression="Posicion" ColumnGroupName="DetalleFactura">
<ItemTemplate>
<asp:Label ID="lblPosicion" runat="server" Text='<%# Bind("Posicion") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Material" SortExpression="Material" ColumnGroupName="DetalleFactura" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50px">
<ItemStyle Width="50px" />
<ItemTemplate>
<asp:Label ID="lblMaterial" runat="server" Text='<%# Bind("CodigoCorto") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>

<ColumnGroups>
<telerik:GridColumnGroup HeaderText="Detalle Factura" Name="DetalleFactura" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true" ></telerik:GridColumnGroup>
</ColumnGroups>
</MasterTableView>
</telerik:RadGrid>



<asp:SqlDataSource 
ID="SqlDSFacturaDetalle"
runat="server"
ConnectionString="<%$ ConnectionStrings:SAIS %>"
SelectCommand="[SNCGetFacturaDetalle]"
SelectCommandType="StoredProcedure"
>
<SelectParameters>
<asp:Parameter Name="vFactura" Type="Int32" DefaultValue="920999251" />
</SelectParameters>
</asp:SqlDataSource>

 

 Last code works perfectly, but if change for ClientDataSource after:

                   var resultFacturaDetalle = GetSynchronousJSONResponse('Service1.asmx/GetFacturaDetalle', '{"Factura": "' + Factura + '"}');
                   var masterTable = $find(rgFacturaDetallesID).get_masterTableView();
                   masterTable.set_dataSource(eval('(' + resultFacturaDetalle + ').d'));
                   masterTable.dataBind();

 

NestedViewTemplate does not show at all.

Konstantin Dikov
Telerik team
 answered on 16 Jun 2015
1 answer
444 views
how to save Radhtmlchart  as image 
Marin Bratanov
Telerik team
 answered on 16 Jun 2015
7 answers
740 views

Hello,

I have a tabstrip that is created dynamically.  There can be several tabs with child tabs in the tabstrip.  When the user clicks on a specific tab a web user control is loaded into the selected tab.  Inside one of these user controls I have a radgrid that has a grid template column with a radbutton.  When the user clicks on this button I want to select a different tab and load its content based on the tab value (the tab value contains the location of the web user control that will be loaded into the tab).

I tried to do this from server-side code, but I was not able to get that to work.  So, now I'm trying to get it to work using client-side code.  The following javascript code almost works.  It does select the tab I want to select, but it will not load the contents of the tab even though the click event is being called.

Here's my tabstrip HTML that is located inside content placeholder of a master page:

<asp:Content ID="tabContent" ContentPlaceHolderID="cphTabStrip" runat="server">
    <telerik:RadTabStrip ID="rtabstripTabs" runat="server" OnTabClick="rtabstripTabs_TabClick" ShowBaseLine="true" OnClientTabSelected="OnClientTabSelected"
        EnableEmbeddedSkins="false" AutoPostBack="False" MultiPageID="rpageviewUserControl">
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="rmpTabStrip" runat="server" SelectedIndex="0">
    </telerik:RadMultiPage>
 
    <telerik:RadScriptBlock ID="rsbTabs" runat="server">
        <script type="text/javascript">
            function GetTabStrip() {
                var tabstrip = $find("<%= rtabstripTabs.ClientID %>");
 
                if (tabstrip) {
                    var tab = tabstrip.findTabByValue("Modules/EspsMT/Inventory/wucInventoryAddEditFilters.ascx");
                    tab.click();
                }
            }
        </script>
    </telerik:RadScriptBlock>
</asp:Content>

 Here's the code in the web user control that triggers the GetTabStrip() function:

                <telerik:GridTemplateColumn UniqueName="Test" Resizable="false">
                    <ItemTemplate>
                        <telerik:RadButton ID="btnTest" runat="server" OnClientClicked="btnTest_Clicked" Text="View Pending" ></telerik:RadButton>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
 
<telerik:RadScriptBlock ID="rsbInventoryPending" runat="server">
    <script type="text/javascript">
        function btnTest_Clicked(sender, args) {
            window.parent.GetTabStrip();
            return false;
        }
    </script>
</telerik:RadScriptBlock>

I tried using __PostBack() to trigger a postback.  This does load the content; however, it loads the web user control twice and causes a page flash.

Can anyone help me figure out how to do this the proper way?  I'd much rather do this on the server side because then I can set session variables that can be used by the second web user control content.

 Thanks.

Aneliya Petkova
Telerik team
 answered on 16 Jun 2015
1 answer
79 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
187 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
225 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?