Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
131 views
I am new to the Treeview so please be patient. I have a RadTreeView on my aspx page. The following information is from the Telerik.Web.UI. Version: 2009.3.1314.20, RunTime Version: v2.0.50727

During the Page_Load function where ! Page.IsPostBack I load my treeview using the Enumerable logic with a NodeDataBound customization. These 2 processes set up my treeview with a parent/child relationship along with setting up attributes and the correct contextmenus. Later down in the code I have the following code to see if the user passed in a value to have auto-selected on the treeview.

If

 

 

Request("eid") <> "" Then

 

    Dim nodeSelected As RadTreeNode = rtvEventList.FindNodeByValue(Request("eid"))

    nodeSelected.Selected =

 

True

 

 

 

    Dim js As String = "ScrollToSelectedNode();"

 

 

 

    RadScriptManager.RegisterStartupScript(Page, Page.[GetType](), "nodeSelection", js, True)

 

 

 

 

End If
The node is selected and page is filled out correctly. The function ScrollToSelectedNode() is called.

 

 

 

 

function ScrollToSelectedNode()

 

 

{

 

 

 

 

 

 

    var treeviewInstance = <%=rtvEventList.ClientID %>;

 

 

 

 

 

    var selectedNode = treeviewInstance.SelectedNode;

 

 

 

 

 

    if (selectedNode != null)

 

 

    {

 

        window.setTimeout(

 

 

function() { selectedNode.ScrollIntoView(); }, 200);

 

 

    }

 

}

 

 

 

 

It seems that the treeviewInstance has as object, but I keep getting errors that the SelectedNode of the treeviewInstance is null. So the page will not scroll the treeview to the correct node. What am I doing wrong?


Nikolay Tsenkov
Telerik team
 answered on 21 Jun 2011
1 answer
911 views
Is there a way to convert the CSV file returned by ExportToCSV to ANSI-based csv file instead of a UTF8-based csv file?

I tried wiring to the Grid Exporting event but thats not working because the encoding is hardwired to the response.binarywrite call which is called after the GridExporting event. Any ideas?

It would be awesome if telerik allows customization for the export encoding to ASCII, ANSI, or UTF8. Maybe a property to set the encoding.

protected void grdTransaction_GridExporting(object sender, GridExportingArgs e)
{
    byte[] byteArray = Encoding.UTF8.GetBytes( e.ExportOutput);
    byte[] asciiArray = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteArray);
    e.ExportOutput = Encoding.ASCII.GetString(asciiArray);       
}
Daniel
Telerik team
 answered on 21 Jun 2011
1 answer
59 views
Hi, we are using grid.PagerStyle.PagerTextFormat on server side to add custom text and image to pager text. Now we have a case where we are binding the grid on client side (web service) . On different conditions we want to append text to the end of ({4} | Displaying page {0} of {1}, Number of items {2} to {3} of {5}) like: "{4} | Displaying page {0} of {1}, Number of items {2} to {3} of {5} (total results "n")". What approach shoould we have on customising pager text on client? Thanks
Daniel
Telerik team
 answered on 21 Jun 2011
3 answers
124 views

Hello.

I have built a very simple web page (Default.aspx) with the RadScheduler component:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
  
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
  
<!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>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadScheduler ID="RadScheduler1" runat="server">
            <WebServiceSettings Path="/App_Code/Service1.svc" ResourcePopulationMode="ServerSide" />
        </telerik:RadScheduler>
    </div>
    </form>
</body>
</html>

and I have tried to integrate it with an AJAX-enabled web service (Service1.svc.cs):
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Data.Common;
using Telerik.Web.UI;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Configuration;
  
namespace WebApplication1
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
  
    public class Service1
    {
        private WebServiceAppointmentController _controller;
        private MyProvider _provider;
  
        private MyProvider Provider
        {
            get
            {
                if (_provider == null)
                {
                    var connString = ConfigurationManager.ConnectionStrings["BossDB"].ConnectionString;
                    var factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
                    _provider = new MyProvider() { ConnectionString = connString, DbFactory = factory, PersistChanges = true };
                }
                return _provider;
            }
        }
  
        private WebServiceAppointmentController Controller
        {
            get
            {
                if (_controller == null)
                {
                    _controller = new WebServiceAppointmentController(Provider);
                }
                return _controller;
            }
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> GetAppointments(SchedulerInfo schedulerInfo)
        {
            return Controller.GetAppointments(schedulerInfo);
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> InsertAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData)
        {
            return Controller.InsertAppointment(schedulerInfo, appointmentData);
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> UpdateAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData)
        {
            return Controller.UpdateAppointment(schedulerInfo, appointmentData);
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> DeleteAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData,
                                                               bool deleteSeries)
        {
            return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries);
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> CreateRecurrenceException(SchedulerInfo schedulerInfo, AppointmentData recurrenceExceptionData)
        {
            return Controller.CreateRecurrenceException(schedulerInfo, recurrenceExceptionData);
        }
  
        [OperationContract]
        public IEnumerable<AppointmentData> RemoveRecurrenceExceptions(SchedulerInfo schedulerInfo, AppointmentData masterAppointmentData)
        {
            return Controller.RemoveRecurrenceExceptions(schedulerInfo, masterAppointmentData);
        }
  
    }
}

The web service references the data provider implemented in MyProvider.cs:
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;
using System.Transactions;
using Telerik.Web.UI;
  
public class MyProvider : DbSchedulerProviderBase
{
    private SqlConnection m_connection;
    private SqlCommand m_cmdReservationListSelect;
  
    public MyProvider()
    {
        m_connection = new SqlConnection(ConfigurationManager.ConnectionStrings["BossDB"].ConnectionString);
        m_cmdReservationListSelect = new SqlCommand("procReservationListSelect");
        m_cmdReservationListSelect.CommandType = System.Data.CommandType.StoredProcedure;
        m_cmdReservationListSelect.Connection = m_connection;
        m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ClubId", System.Data.SqlDbType.SmallInt));
        m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ResourceType", System.Data.SqlDbType.Char, 15));
        m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ReservationDate", System.Data.SqlDbType.Char, 10));
        m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ReservationType", System.Data.SqlDbType.Char, 1));
        m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@MembershipNbr", System.Data.SqlDbType.Char, 10));
    }
  
    public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo)
    {
        Int16 clubId = 201;
        String resourceType = "PERS TRAINING";
        String reservationDate = "04/01/2011";
        String reservationType = "L";
        String membershipNbr = "";
        List<Appointment> appointments = new List<Appointment>();
  
        using (TransactionScope scope = new TransactionScope())
        {
            m_cmdReservationListSelect.Parameters["@ClubId"].Value = clubId;
            m_cmdReservationListSelect.Parameters["@ResourceType"].Value = resourceType;
            m_cmdReservationListSelect.Parameters["@ReservationDate"].Value = reservationDate;
            m_cmdReservationListSelect.Parameters["@ReservationType"].Value = reservationType;
            m_cmdReservationListSelect.Parameters["@MembershipNbr"].Value = membershipNbr;
  
            m_connection.Open();
  
            using (SqlDataReader reader = m_cmdReservationListSelect.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    int resource = reader.GetOrdinal("resource");
                    int reservation = reader.GetOrdinal("reservation");
                    int qoh = reader.GetOrdinal("qoh");
                    int limit = reader.GetOrdinal("limit");
                    int start_time = reader.GetOrdinal("start_time");
                    int res_units = reader.GetOrdinal("res_units");
                    int invtr_desc = reader.GetOrdinal("invtr_desc");
                    int trainer_cust_code = reader.GetOrdinal("trainer_cust_code");
                    int remaining_sessions = reader.GetOrdinal("remaining_sessions");
                    int recurring = reader.GetOrdinal("recurring");
  
                    while (reader.Read())
                    {
                        Appointment apt = new Appointment();
                        apt.ID = (!reader.IsDBNull(reservation) ? reader.GetInt32(reservation) : 0);
                        apt.Subject = (!reader.IsDBNull(invtr_desc) ? reader.GetString(invtr_desc) : "");
                        apt.Start = Convert.ToDateTime("04/01/2011 " + reader.GetString(start_time));
                        apt.End = Convert.ToDateTime("04/01/2011 " + reader.GetString(start_time)).AddHours(reader.GetInt16(res_units));
                        apt.RecurrenceRule = "";
                        apt.RecurrenceParentID = null;
                        appointments.Add(apt);
                    }
                }
            }
            m_connection.Close();
            scope.Complete();
            return appointments;
        }
    }
  
    public override void Insert(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert)
    {
        if (!PersistChanges)
        {
            return;
        }
    }
  
    public override void Update(ISchedulerInfo shedulerInfo, Appointment appointmentToUpdate)
    {
        if (!PersistChanges)
        {
            return;
        }
    }
  
    public override void Delete(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete)
    {
        if (!PersistChanges)
        {
            return;
        }
    }
  
}

When I build the project in Visual Studio 2008, no errors are reported.
However, at runtime, the following error is displayed:
Server Error in '/' Application.
--------------------------------------------------------------------------------
  
Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
  
Compiler Error Message: CS0234: The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)
  
Source Error:
  
Line 4:  using System.Data.SqlClient;
Line 5:  using System.Configuration;
Line 6:  using System.Transactions;
Line 7:  using Telerik.Web.UI;
Line 8:

Line 6 is highlighted, indicating an error in statement "using System.Transactions;".

In order to compile file MyProvider.cs, System.Transactions needs to be referenced not only in the source code, but also as part of the project, under "References".

Is there another place where System.Transactions need to be referenced?

I would appreciate whether someone could assist me in solving this problem.
Thank you in advance.

Paulo

Veronica
Telerik team
 answered on 21 Jun 2011
2 answers
180 views
I'm playing with the chart at the moment and wondered if anyone knows how to set the maximum Y axis value?

For instance, I have a datasourse where the highest value woul be, say for arguments sake, 3. When the chart displays, the top of the chart's value is set to 3. How can I set this to another figure, say 10, even though data doesn't go up this high?

Thanks.
Peshito
Telerik team
 answered on 21 Jun 2011
1 answer
69 views
hi,
good evening all,
when Rad filter is used by default
AND, OR,NOT AND,NOT OR  these four operator are shown in Main root context menu.
so if  "AND" to be Shown "ADD", by which property it can be shown.



please response soon.


thanks.
Princy
Top achievements
Rank 2
 answered on 21 Jun 2011
1 answer
76 views
Hi
I want to do server side dragdrop on treeview but nodedrop event does not fire, please help me.

Shinu
Top achievements
Rank 2
 answered on 21 Jun 2011
3 answers
61 views
If I set AutoPostbackOnFilter="true" and CurrentFilterFunction="StartsWith", then when a user enters some text and hits enter, the grid will be filtered properly. However, I have noticed, if the user enters text, and then decided to use the filter menu, sometimes the grid filters AS SOON AS they click on the filter icon, as opposed to when they select a menu item. Its almost as if clicking on the filter menu icon causes the grid to filter. This does not occur if AutoPostbackOnFilter="False".

I believe this only happens after the user selects a filter function other than "Starts With".. So, the user selects something other, like "Contains", everything work fine. Then they click on the filter menu icon (the filter funciton "Contains" is now different that what is specified in the Grid declaration "CurrentFilterFunction='StartsWith"), and the filter occurs immediately before they even have a chance to selct an option.

Any idea what's going on.
Tsvetoslav
Telerik team
 answered on 21 Jun 2011
4 answers
332 views
I am taking a existing chart that was done previously in Dundas chart control and migrating it to the Telerik chart control. So far I can easily replicate the data area display, but I am having trouble with the labels and gridlines on the x-axis. Basically I need to take a start and end date and always display the grid with 8 total gridlines (9 if you include the Y axis) based on hours. So for example in the attached files I have one with a start date of 2/23/2011 and end date of 3/1/2011. I need that range basically as best as possible divided by 8. This needs to happen even if dealing with just a single day as seen in the attached file for just 2/23/2011. With my old Dundas code I did this by taking the total hour difference between the dates, loop adding an hour to the value until it was divisble by 8 evenly and then setting the X axis to that as the intervale and telling the grid its X axis was an intervaltype of hours. Here is the code.

//Take the start and end dates and set them for the start and end X axis
this.Chart1.ChartAreas[0].AxisX.Minimum = initialDate.ToOADate();
this.Chart1.ChartAreas[0].AxisX.Maximum = completeDate.ToOADate();
//Get the total hours between start and end
double totalSeriesHours = completeDate.Subtract(initialDate).TotalHours;
//We will be showing 8 grid lines on the X axis so keep adding an hour until we can divide evenly by 8
if (totalSeriesHours > 0)
{
    // How many hours per label?
    while ((totalSeriesHours % 8.0) != 0)
    {
        totalSeriesHours++;
    }
    totalSeriesHours /= 8;
}
//Set the X axis lines, labels and tick marks.
this.Chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Hours;
this.Chart1.ChartAreas[0].AxisX.MajorGrid.Interval = totalSeriesHours;
this.Chart1.ChartAreas[0].AxisX.LabelStyle.IntervalType = DateTimeIntervalType.Hours;
this.Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = totalSeriesHours;
this.Chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = totalSeriesHours;
this.Chart1.ChartAreas[0].AxisX.MajorTickMark.IntervalType = DateTimeIntervalType.Hours;

Now I realize that the Telerik chart works differently so I have tried many things to replicate the same process in its workings. I set the Label step to 8. I set ranges, etc. No matter what I do I cannot get it to display 8 grid lines. I just get labels for the start and end dates. I tried code like below to no avail. I am think I am missing something in my understanding on how the labels and grid lines work. Side note. I need the labels to be on the grid lines. Thanks in advance.

double minDateValue = initialDate.ToOADate();
double maxDateValue = completeDate.ToOADate();
double totalSeriesHours = maxDateValue - minDateValue;
//We will be showing 8 grid lines on the X axis so keep adding an hour until we can divide evenly by 8
if (totalSeriesHours > 0)
{
    // How many hours per label?
    while ((totalSeriesHours % 8.0) != 0)
    {
        totalSeriesHours++;
    }
    totalSeriesHours /= 8;
}
//Take the start and end dates and set them for the start and end X axis
this.Chart1.PlotArea.XAxis.IsZeroBased = false;
this.Chart1.PlotArea.XAxis.AutoScale = false;
this.Chart1.PlotArea.XAxis.AddRange(minDateValue, maxDateValue, totalSeriesHours);



Ves
Telerik team
 answered on 21 Jun 2011
1 answer
268 views

I have a databound ComboBox that the application user needs to be able to 'check'.  What need to do is to show the user which entries have already been 'checked', that is I need to be able to programmatically set the checked property of the items in the combobox.  I can id the items to be checked, I just need the code to actually "check" the item.

Here is my code so far:

If item.IsInEditMode Then

Dim indx As Integer = ctlUserCombo.FindItemIndexByText("Test, Sabo")

Dim cmbo As RadComboBox = CType(item.FindControl("ctlUserCombo"), RadComboBox)

Dim cbox As RadComboBoxItem = CType(cmbo.Items(indx), RadComboBoxItem)

cmbo.Items(indx).Enabled = False

So I am able to change the Enabled property to False...what I need to be able to do is set the combobox to "Checked".  However the RadComboBoxItem does not have a 'checked' property.  Anyone know how to get the combo box to show checked = true for individual items in the combobox? 

Thanks.

Princy
Top achievements
Rank 2
 answered on 21 Jun 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?