Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
103 views
Hi,

I'm trying to implement sorting on a custom field, could someone provide me with an example

Code as below, would want to implement sorting on

 

<telerik:RadGrid ID="rgContactsResult" runat="server" Width="99%" AllowPaging="True" AllowSorting="true"

 

GridLines="None" PageSize="10" AllowFilteringByColumn="True" AutoGenerateColumns="false">

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" Wrap="false"></PagerStyle>

<GroupingSettings CaseSensitive="false" />

 <ClientSettings EnablePostBackOnRowClick="true">

 <Selecting AllowRowSelect="true" />

 <KeyboardNavigationSettings AllowSubmitOnEnter="true" />

 </ClientSettings>

 <MasterTableView CommandItemDisplay="None">

 <Columns>

 <telerik:GridBoundColumn HeaderText="Our Ref" UniqueName="contactID" DataField="contactID" AllowFiltering="false" >

  <telerik:GridTemplateColumn HeaderText="ContactJob" UniqueName="ContactJob" AllowFiltering="false">
<ItemTemplate>

 <%# ContactJob(DataBinder.Eval(Container.DataItem, "ContactID"))%>

 </ItemTemplate>

 </telerik:GridTemplateColumn>

 </Columns>

 </MasterTableView>

</telerik:RadGrid>

Thanks

 

Princy
Top achievements
Rank 2
 answered on 13 Feb 2012
4 answers
154 views
For a long time now I've used a dependable Javascript function to preselect the text in a textbox.  However I discovered today that when a textbox resides in an AJAXifield RadWindow, a more complex approach has to be used.  Here's the code showing both approaches:

  function SetFocusAndSelectText(tbID) {<br>    var textBox = $get(tbID);<br><br>    // Standard approach<br>    textBox.focus();<br>    textBox.select();<br><br><br>    // Approach when the TextBox resides in an AJAXified RadWindow<br>    //    function f() {<br>    //      debugger <br>    //      if (textBox != null) {<br>    //        textBox.focus();<br>    //        textBox.select();<br>    //      }<br><br>    //      Sys.Application.remove_load(f);<br>    //    }<br><br>    //    Sys.Application.add_load(f);<br>  }

I'm wondering if there's a way to test for whether the textbox sits within a RadWindow?  If so, then I could just call one function and let it decide which approach to use.

Sincerely,

Robert W.
Robert
Top achievements
Rank 1
 answered on 12 Feb 2012
1 answer
184 views
Hi 

I'm working on "Add to Calendar" feature from my Sharepoint webpart (created using VS2010). If I want to include  multiple breakdown appointments  (For Ex, one for today between 9.00 a.m - 11 a.m & one for tomorrow between 3.00 p.m - 5.00 p.m), How do I do that?
The following code works for a single appointment. Its creating an additional calendar  if I have more that one appointment. 
Instead I should be able to update my existing calendar with the multiple appointments.

Could you please assist me how to do this?

Here is part of my code 

                //........
                EventSessions = from eventobj1
in context.EventSessions
   where eventobj1.Event.Id == eventid
   select eventobj1;
      foreach (EventSessionsItem session in EventSessions)
      {
         Appointment _appointment = new Appointment();
 
         editor.Content = session.Event.EventDetails;
         _appointment.Subject = session.Title;
         _appointment.Description = Server.HtmlDecode(editor.Text);
         _appointment.Start = session.DateOfSession.Value; 
         _appointment.End = dtStart.AddHours(session.SessionDuration.Value); 
                     sbICSFile.Append(RadScheduler.ExportToICalendar(_appointment));
      }
      WriteCalendar(sbICSFile.ToString());

       


private
void WriteCalendar(String data)
{
HttpResponse response = Page.Response;
response.Clear();
response.Buffer =
true;
response.ContentType =
"text/calendar";
response.ContentEncoding = Encoding.UTF8;
response.Charset =
"utf-8";
response.AddHeader(
"Content-Disposition", "attachment;filename=\"Calendar.ics\"");
response.Write(data);
response.End();
}

Cat Cheshire
Top achievements
Rank 1
 answered on 12 Feb 2012
1 answer
159 views

Hi there,

I have created a webpart include a RadTreeView in Sharepoint 2010. However, when I open the IE to see webpart , I see following  script error:

Message: 'RadTreeView1_NodeClicked' is undefined
Line: 1481
Char: 5
Code: 0
My Visual Webpart code(.ascx) is such as follow:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="HiTreeViewUserControl.ascx.cs" Inherits="TreeView.HiTreeView.HiTreeViewUserControl" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.3.1115.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
    Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.3.1115.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
    Namespace="Telerik.Web.Design" TagPrefix="telerik" %>
  
<telerik:RadTreeView ID="RadTreeView1" Runat="server" EnableEmbeddedScripts="true"
        OnClientNodeClicked="RadTreeView1_NodeClicked">
    <DataBindings>
              <telerik:RadTreeNodeBinding Expanded="True" />
    </DataBindings>
</telerik:RadTreeView>
  
<telerik:RadTextBox ID="Dscp" Runat="server" Height="100px" LabelWidth="" 
    Text="Comment" TextMode="MultiLine" Width="325px">
</telerik:RadTextBox>
<p>
     </p>
<telerik:RadButton ID="btnUpdate" runat="server" onclick="btnUpdate_Click" 
    Text="Update">
</telerik:RadButton>

The Code Behind is such as follow:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Telerik.Web.UI;
using System.Data;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
  
  
namespace TreeView.HiTreeView
{
    public partial class HiTreeViewUserControl : UserControl
    {
        static int selectedItem;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                   BindToDataSet(RadTreeView1);
            }
              
        }
        private static void BindToDataSet(RadTreeView treeView)
        {
            try
            {
                DataSet dataSet = new DataSet();
  
                dataSet.Tables.Add("Table");
                dataSet.Tables[0].Columns.Add("ID", typeof(int));
                dataSet.Tables[0].Columns.Add("ParentID", typeof(int));
                dataSet.Tables[0].Columns.Add("Text", typeof(string));
  
                SPSite spSite = new SPSite(SPContext.Current.Web.Url);
                SPWeb spWeb = spSite.OpenWeb();
  
                SPList peopleList = spWeb.Lists["People"];
  
                foreach (SPListItem people in peopleList.Items)
                {
                    DataRow row = dataSet.Tables[0].NewRow();
                    row["ID"] = people["ID"];
                    row["Text"] = people["Name"];
                    if (people["Manager"] != null)
                    {
                        int intIndex = Convert.ToInt32(people["Manager"].ToString().IndexOf(';'));
                        row["ParentID"] = Convert.ToInt32(people["Manager"].ToString().Substring(0, intIndex));
                    }
                    dataSet.Tables[0].Rows.Add(row);
                }
                treeView.DataTextField = "Text";
                treeView.DataFieldID = "ID";
                treeView.DataFieldParentID = "ParentID";
  
                treeView.DataSource = new HierarchicalDataSet(dataSet, "ID", "ParentID");
                treeView.DataBind();
            }
            catch(Exception ex)
            {
            }
        }
  
        protected void RadTreeView1_NodeClicked(object sender, EventArgs e)
        {
            SPSite spSite = new SPSite(SPContext.Current.Web.Url);
            SPWeb spWeb = spSite.OpenWeb();
  
            SPList peopleList = spWeb.Lists["People"];
            foreach (SPListItem people in peopleList.Items)
            {
                if (people["Name"] != null)
                {
                    if (RadTreeView1.SelectedNode.Text.ToString() == people["Name"].ToString())
                    {
                        if (people["Comment"] != null)
                        {
                            Dscp.Text = people["Comment"].ToString();
                        }
                        else
                        {
                            Dscp.Text = "";
                        }
                    }
                }
            }
            selectedItem = Convert.ToInt32(RadTreeView1.SelectedNode.Value.ToString());
  
        
  
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            SPSite spSite = new SPSite(SPContext.Current.Web.Url);
            SPWeb spWeb = spSite.OpenWeb();
            SPListItem itemUpdate = spWeb.Lists["People"].Items[selectedItem];
  
            itemUpdate["Comment"] = Dscp.Text;
            itemUpdate.Update(); 
  
        }
              
  }
}

 my email address: kassaiefarshad@yahoo.com


Kalina
Telerik team
 answered on 12 Feb 2012
2 answers
209 views

Dears;

am having an issue on the combobox checkbox property;

the control syntax is:

<rad:RadComboBox ID="lstCustomrs" runat="server" Width="300px" CheckBoxes="true"
 
 EnableCheckAllItemsCheckBox="true" Localization-AllItemsCheckedString="All Customers"
EmptyMessage="Select Customer">
 
</rad:RadComboBox>

All Items are checked by default:

Private Sub lstCustomers_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles lstCustoemrss.ItemDataBound
 
    e.Item.Checked = True
 
End Sub

The Scenario is:

  1. when i enter my page all items are checked by default
  2. then when i uncheck "check all" check box then choose a single item.
  3. then i go out of the control
  4. then i check anther checkbox item the checkbox items text still show the last single item that i have choosed.

Can you please advise



Amjad
Top achievements
Rank 1
 answered on 11 Feb 2012
2 answers
265 views
Hello All,

I am loading HTML content (some template) into rad editor and it is loading fine.I am happy.But If I did any modifications in it there I am facing problem.

 Problem is , I want to save the content of the rad editor after editing the template,what ever I am loading.But When I tried to check.The Content is empty.

I am using " RadEditor.Content".Why it is happening.The content is still there na.Please help me.It is high priority for me.

Thanks.

Rama.M




























Rama
Top achievements
Rank 1
 answered on 11 Feb 2012
1 answer
262 views
I get this error because I am using a user control that is inside a page that doesn't have RadAjaxManager.
How do I check if RadAjaxManager exists on the parent page before getting the error? Some parent pages do have
RadAjaxManager, some others don't.

And if it doesn't exist,  I do not want to make a request.

Thanks in advance.


Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 69:         function refreshScreen(action) {
Line 70: 
Line 71:             $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest(action);
Line 72: 
Line 73:         }   
Simone
Top achievements
Rank 1
 answered on 10 Feb 2012
8 answers
204 views
Can someone help me determine what is the problem with my code below? Its not expanding.  From reading the following articles, it should.  I think it may have something to do with my databinding....


http://www.telerik.com/help/aspnet/panelbar/panelbar_itemdoesnotcollapseexpand.html
http://www.telerik.com/help/aspnet-ajax/panelbar-troubleshooting-root-items-collapse.html

ASPX:

 

 

<telerik:RadPanelBar ID="pbCategory" runat="server">

 

 

 

<Items>

 

 

 

<telerik:RadPanelItem runat="server" Text="Root RadPanelItem1">

 

 

 

<Items>

 

 

 

<telerik:RadPanelItem>

 

 

 

<ItemTemplate>

 

 

 

<table style="width:90%; margin:5px 10px 5px 10px">

 

 

 

<tr style="width:90%">

 

 

 

<td colspan="2" style="width:85%; text-align:left; border:1px solid black"><asp:Label id="lblDetails" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Details") %>' /></td>

 

 

 

<td style="width:5%; text-align:right"><asp:ImageButton ID="btnEdit" runat="server" src="../images/ico_Edit.gif"/></td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td style="width:45%; text-align:left">Added By:<asp:Label id="lblAddedBy" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AddedBy") %> ' /></td>

 

 

 

<td style="width:45%; text-align:right">Last Updated By:<asp:Label id="lblUpdatedBy" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "UpdatedBy") %>' /></td>

 

 

 

<td>&nbsp;</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</ItemTemplate>

 

 

 

</telerik:RadPanelItem>

 

 

 

</Items>

 

 

 

</telerik:RadPanelItem>

 

 

 

</Items>

 

 

 

</telerik:RadPanelBar>

CS:

 

pbCategory.DataSource = ds;

pbCategory.DataTextField =

 

"LongName";

 

pbCategory.DataValueField =

 

"CategoryCode";

 

 

 

pbCategory.DataFieldParentID = "Id";

 

pbCategory.DataBind();

Michael
Top achievements
Rank 1
 answered on 10 Feb 2012
2 answers
123 views
Hi,

I have a RadTabStrip in which I allow the user to dynamically add tabs, which then make a call for the appropriate user control to populate the newly added tab.  

One of the requirements is that the user can add the same tab/control multiple times.

This works good and the control is added as many times as needed.

The problem arrives when databinding.  

Lets say the user adds 3 tabs, each containing the same user control, which contains a grid.  Then, on the third tab, the user performs a search/databind on that third grid.  The problem is that the first tab grid is the one updated/data bound, no matter what tab the search was performed on.  Nothing happens on the third grid.  

The user control consists of a textbox and grid, bound to an entity datasource.

How do I correlate the appropriate grid to the textbox text, which is the WHERE parameter for the entity datasource.

Thanks!  If this is unclear or you need more information, please let me know.
This is using ASP.NET 4 and the latest version of the Telerik controls, downloaded from telerik.com last week.
Kevin
Kevin
Top achievements
Rank 1
 answered on 10 Feb 2012
3 answers
141 views
I am prototyping a new project where users will navigate a dynamically generated list of hierarchically nested assets (bound to a RadTreeView). I want the users to be able to drill down into the tree to the actual asset item in the list. On clicking the asset item:

1. I want to reload the page using the ID VALUE (not the text displayed) of the item clicked. This will load all sorts of unique info for that item. I was going to simply use querystring variables so the users can bookmark their searches. I'd like to grab the selected ID, put it in querystring, and reload the page. What's the best practice for having an ID VALUE attached to a node (in XML)? What is the best way to access it in C#?

2. I also want to persist on refresh what the user clicked, so it the selected item is active (because navigating thousands of items all over again isn't acceptable). We're dealing with a nationwide list of assets.

3. I DON'T want anything to cause a postback except the final child element in the hierarchy. How do I control what causes postback and what doesn't in a dynamically generated RadTreeView list of items?

Please provide sample code if you can. NOTE: For the prototype, I've already connected to an XML file using the .LoadContentFile() method. I'm using dummy data to get started.

Thanks much for your assistance!
A
Alex
Top achievements
Rank 1
 answered on 10 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?