Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
84 views
During a DataBind, I'd like to access an earlier row to do conditional formatting.  I need help completing the following code:

protected void RadGridX_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        if (item["Name"].Text == "RowIWant")
        {
            foreach(string colName in colNames)
            {
                //get this value
                int thisValue = Convert.ToInt32(item[colname].Text);

                // get the value from the RowToCompare
                int earlierValue = ???

            }
        }
    }
}
Scott
Top achievements
Rank 1
 answered on 27 Jun 2014
8 answers
371 views
I have a Radgrid with a text box template column:
templateColumn = new GridTemplateColumn();
templateColumnName = "BAN";
this._RadGrid1.MasterTableView.Columns.Add(templateColumn);
templateColumn.ItemTemplate = new TextBoxTemplate(templateColumnName);
templateColumn.HeaderText = templateColumnName;
templateColumn.DataField = this._PriceDealProductBanTable.BillingAccountNumberColumn.ColumnName;
templateColumn.AllowFiltering = false;
The TextBoxTemplateColumn is as follows:
public class TextBoxTemplate : ITemplate
    {
        protected RadTextBox _textBox;      
        string _columnName;
        public TextBoxTemplate(string columnName)
        {
            this._columnName = columnName;
        }
        public void InstantiateIn(System.Web.UI.Control container)
        {
            
            this._textBox = new RadTextBox();
            this._textBox.ID = this._columnName;           
            container.Controls.Add(this._textBox);           
        }      
}
templateColumn.DataField = this._PriceDealProductBanTable.BillingAccountNumberColumn.ColumnName; doesnt do the trick of binding the textbox to a column. How  can I achieve it? I want the current values to be displayed on the text box.
Jayesh Goyani
Top achievements
Rank 2
 answered on 27 Jun 2014
4 answers
236 views
We would like our application to work the same in all the different browsers. The RadEditor behaves differently in different browsers when pasting. How can we make the RadEditor's pastes behave the same in IE8,Firefox, Chrome and Safari?

1 - We are using the "Paste From Word,Strip Font" and the "Paste Plain Text" buttons on the RadEditor menu bar. And we would like ONLY those paste options to be available to our users. In IE, how do we stop the RadEditor's RightClick context menu from showing all of the other paste options? How do we make it only show the "Paste From Word,Strip Font" and "Paste Plain Text" paste options? or show only "Paste", "Paste From Word,Strip Font" and the "Paste Plain Text".

2- Is there a way to control the RightClick context menu that appears in IE? How can we make that context menu appear in Firefox, Safari and Chrome? Also how do we make that context menu Not appear in IE?

3 - Is there a way to prevent the paste dialog from opening in Firefox, Chrome and Safari? Or, is there a way to make the paste dialog Open in IE? We would like the paste action to be consistent. If there is a way to do both, that would be great to know.

4 - We use the xml tools file to define what buttons will appear on the RadEditor tool bar. Is there a way in the code behind to change which buttons appear on the RadEditor tool bar?
 
btw, we are using C#.
Ianko
Telerik team
 answered on 27 Jun 2014
4 answers
187 views
Hi Support,

                   We liked your implementation of Scheduler control, It
has some really cool features. we are planning to use it in one of our
apps, so giving it a try with your most recent Control trials.

We are using the Scheduler with Sql Database.
The Table structure we followed was taken from here

Now When i create the appointment without Recurrence all works fine.
When we try to create appointment with recurrence the appointments are
not getting displayed the first time. As i click on any of the
links/buttons provided

The datasource we used for binding is generic List of  business object called Appointment in our business layer.



I am pasting the markup from our implementation below

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"><br>                        <AjaxSettings><br>                            <telerik:AjaxSetting AjaxControlID="RadAppointments"><br>                                <UpdatedControls><br>                                    <telerik:AjaxUpdatedControl ControlID="RadAppointments" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl><br>                                    <telerik:AjaxUpdatedControl ControlID="timer1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl><br>                                </UpdatedControls><br>                            </telerik:AjaxSetting><br>                        </AjaxSettings><br>                    </telerik:RadAjaxManager><br>                    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"><br>                    </telerik:RadAjaxLoadingPanel><br>                    <telerik:RadScheduler ID="RadAppointments" Visible="true" runat="server" OverflowBehavior="Expand" Height="100%" DayStartTime="07:00:00" DayEndTime="19:00:00" RenderMode="Auto" EnableAdvancedForm="true"<br>                        OnClientFormCreated="OnClientFormCreated" OnAppointmentInsert="RadAppointments_AppointmentInsert" OnAppointmentUpdate="RadAppointments_AppointmentUpdate" EnableDescriptionField="true" OnAppointmentDelete="RadAppointments_AppointmentDelete"<br>                        AdvancedForm-EnableResourceEditing="true" CustomAttributeNames="CustomerName" StartInsertingInAdvancedForm="true" StartEditingInAdvancedForm="true" ShowFullTime="true"<br>                        EnableTheming="false" OnFormCreated="RadAppointments_FormCreated" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"><br><br>                        <AdvancedForm Modal="true" EnableCustomAttributeEditing="false" EnableResourceEditing="true"></AdvancedForm><br><br>                        <ResourceTypes><br>                            <telerik:ResourceType KeyField="Type" Name="Type" TextField="Type" ForeignKeyField="Type" DataSourceID="odsTypes"></telerik:ResourceType><br>                            <telerik:ResourceType KeyField="CustomerName" Name="CustomerName" ForeignKeyField="CustomerName" TextField="CustomerName" DataSourceID="odsCustomers"></telerik:ResourceType><br>                        </ResourceTypes><br>                        <AppointmentTemplate><br>                            <div style="font-style: italic; width: 100%"><br>                                Subiect:<br>                            <%# Eval("Subject") %><br>                            </div><br>                            <div style="font-style: italic; width: 100%;"><br>                                Type:<br>                            <%# Eval("Type.Text")%><br>                            </div><br>                            <div style="font-style: italic; width: 100%;"><br>                                Buyer Name:<br>                            <a href="customerlist.aspx" title="View Details"><%# Eval("CustomerName")%><img style="padding-left: 3px;" src="Images/eye.png" alt="view details" /></a><br>                            </div><br>                        </AppointmentTemplate><br>                        <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings><br>                        <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings><br>                    </telerik:RadScheduler><br><br>                    <asp:ObjectDataSource ID="odsCustomers" runat="server" SelectMethod="GetCustomerlist" TypeName="SqlHelper"></asp:ObjectDataSource><br>                    <asp:ObjectDataSource ID="odsTypes" runat="server" SelectMethod="getAppointmentType" TypeName="SqlHelper"></asp:ObjectDataSource><br><br><%--End Of markup %-->

The Codebehind where the scheduler gets binded looks like below

 
protected override void OnInit(EventArgs e)
        {
            if (!IsPostBack)
            {
                InitializeAppointments();
}
}

The code to insert and edit appointments are in the following handlers

protected void RadAppointments_AppointmentInsert(object sender, Telerik.Web.UI.AppointmentInsertEventArgs e)
       {
           try
           {
               //if (RadAppointments.Appointments.GetAppointmentsInRange(e.Appointment.Start, e.Appointment.End).Count > 0)
               //{
               //    e.Cancel = true;
               //    ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose a different Time for Appointment!');", true);
               //}
               if (e.Appointment.Subject == String.Empty)
               {
                   e.Cancel = true;
               }
               if (e.Appointment.Resources.Count == 0)
               {
                   e.Cancel = true;
                   ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose appointment Type and Buyer Name!');", true);
               }
               if (e.Appointment.Resources.Count == 1)
               {
                   if (e.Appointment.Resources[0].Type != "Type")
                   {
                       e.Cancel = true;
                       ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose appointment Type!');", true);
                   }
                   else
                   {
                       e.Cancel = true;
                       ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose a Buyer Name!');", true);
                   }
               }
               Appointment objAppointment = new Appointment();
               objAppointment.Title = e.Appointment.Subject;
               objAppointment.Start = e.Appointment.Start.ToUniversalTime()  ;
               objAppointment.End = e.Appointment.End.ToUniversalTime();
               objAppointment.Type = e.Appointment.Resources[0].Key.ToString();
               objAppointment.ID_SalesRep = Convert.ToInt64(Session["UserID"]);
               string customer = e.Appointment.Resources[1].Text.ToString();
               int index = customer.IndexOf('-');
               Int64 Id = 0;
               if (index > 0)
               {
                   Id = Int64.Parse(customer.Substring(0, index));
                   //customer = customer; //.Substring(index, customer.Length);
               }
  
               objAppointment.ID_Customer = Id; // Convert.ToInt64(e.ModifiedAppointment.Resources[1].Key);
               objAppointment.CustomerName = customer;//e.ModifiedAppointment.Resources[1].Text.ToString();
               //objAppointment.ID_Customer = Convert.ToInt64(e.Appointment.Resources[1].Key);
               //objAppointment.CustomerName = e.Appointment.Resources[1].Text.ToString();
               objAppointment.Description = e.Appointment.Description;
               objAppointment.RecurrenceRule = e.Appointment.RecurrenceRule;
                 
               objAppointment.AddAppointment();
               InitializeAppointments();
  
           }
           catch (Exception ex)
           {
               e.Cancel = true;
               Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
           }
       }
  
       protected void RadAppointments_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
       {
           try
           {
               //if (RadAppointments.Appointments.GetAppointmentsInRange(e.ModifiedAppointment.Start, e.ModifiedAppointment.End).Count > 0)
               //{
               //    foreach (Telerik.Web.UI.Appointment a in RadAppointments.Appointments.GetAppointmentsInRange(e.ModifiedAppointment.Start, e.ModifiedAppointment.End))
               //    {
               //        if (a.ID != e.Appointment.ID)
               //        {
               //            e.Cancel = true;
               //        }
               //    }
               //}
  
               if (e.ModifiedAppointment.Subject == String.Empty)
               {
                   e.Cancel = true;
               }
               if (e.ModifiedAppointment.Resources.Count == 0)
               {
                   e.Cancel = true;
                   ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose appointment Type and Buyer Name!');", true);
               }
               if (e.ModifiedAppointment.Resources.Count == 1)
               {
                   if (e.ModifiedAppointment.Resources[0].Type != "Type")
                   {
                       e.Cancel = true;
                       ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose appointment Type!');", true);
                   }
                   else
                   {
                       e.Cancel = true;
                       ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "alert('Please choose a Buyer Name!');", true);
                   }
               }
  
  
               Appointment objAppointment = Appointment.GetAppointment(Convert.ToInt64(e.ModifiedAppointment.ID));
               objAppointment.ID = objAppointment.ID;
               objAppointment.Title = e.ModifiedAppointment.Subject;
               objAppointment.Start = e.ModifiedAppointment.Start.ToUniversalTime();
               objAppointment.End = e.ModifiedAppointment.End.ToUniversalTime();
               objAppointment.ID_SalesRep = Convert.ToInt64(Session["UserID"]);
               string customer = e.ModifiedAppointment.Resources[1].Text.ToString();
               int index = customer.IndexOf('-');
               Int64 Id = 0;
               if (index > 0)
               {
                   Id = Int64.Parse(customer.Substring(0, index));
                   //customer = customer; //.Substring(index, customer.Length);
               }
  
               objAppointment.ID_Customer = Id; // Convert.ToInt64(e.ModifiedAppointment.Resources[1].Key);
               objAppointment.CustomerName = customer;//e.ModifiedAppointment.Resources[1].Text.ToString();
               objAppointment.Description = e.ModifiedAppointment.Description;
               objAppointment.UpdateAppointment();
               InitializeAppointments();
           }
           catch (Exception ex)
           {
               e.Cancel = true;
               Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
  
           }
       }


Please help us with this issue. we are looking forward to hear from you soon.







Regards,

Vikas Joshi

Beyondkey pvt. Ltd.

India

Chris
Top achievements
Rank 1
 answered on 27 Jun 2014
4 answers
172 views
Is there a way that i can trigger the popup by user click on input field (textbox)?  Thank you.
Joseph
Top achievements
Rank 1
 answered on 27 Jun 2014
4 answers
124 views
Hi, im trying to get access to the value from the data that is feed by a webservice. The data is displayed well, but I want that when the page load, the first item must be selected in some case, so I need to feed the selected value for this, but I don't have it. So my problem is that I can't access the radcombobox.items from anywhere.

01.<telerik:RadScriptBlock runat="server">
02.  <script type="text/javascript">
03.    function onClientSelectedIndexChangingAddress(sender, eventArgs)
04.    {
05.      if (!eventArgs.get_item() || eventArgs.get_item().get_value() == "")
06.      {
07.        eventArgs.set_cancel(true);
08.      }
09.    }
10. 
11.    function onClientSelectedIndexChangedAddress(sender, eventArgs)
12.    {
13.      var idTxtLastSelectedItem = sender.get_id();
14.      idTxtLastSelectedItem = idTxtLastSelectedItem.substring(0, idTxtLastSelectedItem.indexOf("oucAddressDropDownExtended") + 26) + "_txtLastSelectedItem";
15.      document.getElementById(idTxtLastSelectedItem).value = sender.get_text();
16.      sender.clearItems();
17.    }
18. 
19.    function onClientItemsRequestingAddress(sender, eventArgs) {
20.      var idTxtLastSelectedItem = sender.get_id();
21.      idTxtLastSelectedItem = idTxtLastSelectedItem.substring(0, idTxtLastSelectedItem.indexOf("oucAddressDropDownExtended") + 26) + "_txtLastSelectedItem";
22. 
23.      var txtUserGroupID = document.getElementById("<%= txtUserGroupID.ClientID %>");
24.      var txtUserID = document.getElementById("<%= txtUserID.ClientID %>");
25.      var txtTermChooseAnAddress = document.getElementById("<%= txtTermChooseAnAddress.ClientID %>");
26.      var txtTermAddressNoMatch = document.getElementById("<%= txtTermAddressNoMatch.ClientID %>");
27.      var txtTermAddressResults = document.getElementById("<%= txtTermAddressResults.ClientID %>");
28.      var txtHidePartnerPrincipalAddress = document.getElementById("<%= txtHidePartnerPrincipalAddress.ClientID %>");
29. 
30. 
31.      var lastItemRequested = document.getElementById(idTxtLastSelectedItem).value;
32.      if (lastItemRequested == sender.get_text()) {
33.        eventArgs._context.Text = "";
34.      }
35. 
36.      if (txtUserGroupID.value != "") {
37.        eventArgs.get_context()["UserGroupID"] = txtUserGroupID.value;
38.      }
39. 
40.      if (txtUserID.value != "") {
41.        eventArgs.get_context()["UserID"] = txtUserID.value;
42.      }
43. 
44.      eventArgs.get_context()["TermChooseAnAddress"] = txtTermChooseAnAddress.value;
45.      eventArgs.get_context()["TermAddressNoMatch"] = txtTermAddressNoMatch.value;
46.      eventArgs.get_context()["TermAddressResults"] = txtTermAddressResults.value;
47.      eventArgs.get_context()["HidePartnerPrincipalAddress"] = txtHidePartnerPrincipalAddress.value;
48.    }
49.    
50.  </script>
51.</telerik:RadScriptBlock>



1.<telerik:RadComboBox ID="lstShippingAddress" runat="server" EnableEmbeddedSkins="false" Skin="eCom" MaxHeight="250px" EnableLoadOnDemand="True" EnableVirtualScrolling="True" ShowMoreResultsBox="True" AllowCustomText="true" DropDownWidth="500px" OnClientItemsRequesting="onClientItemsRequestingAddress" OnClientSelectedIndexChanging="onClientSelectedIndexChangingAddress" OnClientSelectedIndexChanged="onClientSelectedIndexChangedAddress" >
2.  <WebServiceSettings Method="GetAddresses" Path="/EcomUtilsWS.asmx" />
3.</telerik:RadComboBox>
Maxim
Top achievements
Rank 1
 answered on 27 Jun 2014
1 answer
61 views
Hi boss,
Treelist with Repeater control inside the template column of treelist, I want to export to Excel or pdf  but the repeater control is not showing the export file.
Any solution for that, I will be very thankfull to you.

Thankx

Gul Ahmad
Sr. Software Engineer

Kostadin
Telerik team
 answered on 27 Jun 2014
14 answers
328 views
switched to 2010.1.706.35

1. When I export, this column has empty results.

2. Is there a way to suppress exporting of certain columns?  
Answer:  RadGrid1.Columns(Col.Status).Visible= False

                    <telerik:GridTemplateColumn HeaderStyle-Width="100px" UniqueName="Status" HeaderText="Status" DataField="Status" SortExpression="Status"
                        <ItemTemplate>  
                            <asp:Label ID="lblStatus" runat="server" Text='<%# Bind("Status") %>'></asp:Label>  
                        </ItemTemplate> 
                        <FilterTemplate> 
                            <telerik:RadComboBox runat="server" ID="StatusFilter" Width="90px" Skin="Simple"  
                                DataSource='<%# (New string() {"", "Active", "Completed", "Error"}) %>' 
                                CollapseAnimation-Type="None" ExpandAnimation-Type="None" 
                                SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Status").CurrentFilterValue %>' 
                                OnClientSelectedIndexChanged="StatusIndexChanged" >                  
                            </telerik:RadComboBox> 
                             
                            <telerik:RadScriptBlock ID="StatusScriptBlock" runat="server"
                                <script type="text/javascript"
                                    function StatusIndexChanged(sender, args) { 
                                        var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>"); 
                                        tableView.filter("Status", args.get_item().get_value(), "EqualTo"); 
                                    } 
                                </script> 
                            </telerik:RadScriptBlock>                            
                        </FilterTemplate>                                            
                    </telerik:GridTemplateColumn>    

Kostadin
Telerik team
 answered on 27 Jun 2014
1 answer
72 views
Hi,

In a special scenario, we're using a RadEditor to let the user enter a subject line for sending online emails. We use the editor here because we need the editor toolbar (with some custom made tools) to allow the user to insert some special 'tokens' in that subject line.

Because obviously we only want one line of text in this scenario, and we want to visually discourage the user to enter more than one line, we use the RadEditor with a height set to only 50px (height="50")

This small editor displays fine on eg. computers and Android-tablets, but the Apple iPad displays only a very tiny editor. So tiny in fact, that it is impossible to put a cursor in it to start typing.

Any ideas how to solve this?
Ianko
Telerik team
 answered on 27 Jun 2014
2 answers
115 views
The goal is to take an already finished rad bar chart and change the labels along the x axis to French.  My first thought was to try this:

  private void ProcessXAxis(ChartXAxis xAxis)
        {
            if (xAxis == null || xAxis.Items == null) return;

            foreach (AxisItem item in xAxis.Items)
            {
                var replacementPhrase = GetFilteredReplacementPhrase(item.LabelText);
                if (string.IsNullOrEmpty(replacementPhrase) || string.IsNullOrWhiteSpace(replacementPhrase)) continue;
                item.LabelText = replacementPhrase;
            }
        }

Trouble is, for this particular chart, there are no items in the collection.  Where the chart gets its labels, other than obviously from the data row column names, is beyond me.  Apparently I don't understand the ChartXAxis Item collection enough and assumed incorrectly it represented each data row. It doesn't.

So, this leaves me with the question - how do I find the correct class containing the textblock that is obviously being generated in HTML as a "Text" element under the <g> element?  Please understand that all I have to work with at the point I am doing this processing is an already created chart.  I have no access to the data source and can only use the class trees available from Telerik.

KT
Kerry
Top achievements
Rank 1
 answered on 27 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?