Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
212 views
I am trying to do a simple recursion of folders based upon this folder structure:
Folder ID
Folder Name
Folder Parent

for example root folder has an id of 0 and parent is -1 identifying it as the root folder
Subsequent folders relate back to thier parent id.

Here is the code I got:
'Format Code Block'

 

Public Sub getparentfolders(ByVal parentid As String, ByVal name As String, ByVal rootnode As RadTreeNode)

 

DBConn =

New SqlConnection(ConfigurationManager.ConnectionStrings("db").ToString)

 

 

Dim roottable As New DataTable

 

 

Dim rootrow As DataRow

 

roottable = FolderAPI.GetAllFoldersByParent(parentid, DBConn)

 

Dim subtable As New DataTable

 

 

For Each rootrow In roottable.Rows

 

 

Dim ParentNode As New RadTreeNode

 

ParentNode.Text = rootrow(1).ToString

ParentNode.Value = rootrow(0).ToString

 

'Do I have sub folders

 

subtable = FolderAPI.GetAllFoldersByParent(rootrow(0).ToString, DBConn)

 

If subtable.Rows.Count = 0 Then

 

rootnode.Nodes.Add(ParentNode)

 

Else

 

name = rootrow(1).ToString

getchildfolder(rootrow(0).ToString, name, ParentNode, rootnode, childnode)

 

End If

 

 

Next

 

FolderList.Nodes.Add(rootnode)

 

End Sub

 

 

Public Sub getchildfolder(ByVal parentid As String, ByVal name As String, ByVal ParentNode As RadTreeNode, ByVal rootnode As RadTreeNode, ByVal Childnode As RadTreeNode)

 

 

If Childnode.Text = "" Then Childnode = ParentNode

 

DBConn =

New SqlConnection(ConfigurationManager.ConnectionStrings("db").ToString)

 

 

Dim roottable As New DataTable

 

 

Dim rootrow As DataRow

 

roottable = FolderAPI.GetAllFoldersByParent(parentid, DBConn)

 

If roottable.Rows.Count < 1 Then

 

 

Try

 

rootnode.Nodes.Add(ParentNode)

 

Catch ex As Exception

 

 

Dim parentnode2 As New RadTreeNode

 

parentnode2.Text = name

parentnode2.Value = parentid

 

Dim rootnode2 As New RadTreeNode

 

rootnode2.Text =

"Home"

 

rootnode2.Value = 0

rootnode = rootnode2

rootnode.Nodes.Add(parentnode2)

 

End Try

 

 

End If

 

 

Dim newchild As New RadTreeNode

 

 

For Each rootrow In roottable.Rows

 

 

'Do I have more folders

 

name = rootrow(1).ToString

newchild.Text = name

newchild.Value = parentid

Childnode.Nodes.Add(newchild)

 

'getparentfolders(parentid, name, ParentNode)

 

getchildfolder(rootrow(0).ToString, name, ParentNode, rootnode, newchild)

 

Next

 

 

End Sub

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

Dim rootnode As New RadTreeNode

 

rootnode.Value = -1

rootnode.Text =

"Root"

 

getparentfolders(

"0", "Root", rootnode)

 


Here is where it gets annoying, Works fine except for folders with two sub folders.
Then I get this:

Specified argument was out of the range of valid values.
Parameter name: index

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index

Source Error:

Line 36:             End If
Line 37:         Next
Line 38: FolderList.Nodes.Add(rootnode)

In debugging you can see the parent folder all of a sudden has an index of 2. WTF?
Yana
Telerik team
 answered on 29 Oct 2009
1 answer
160 views
Running into a few issues here.  The functionality we want this application to have is quite simple.  We have a "notes" control with a RadAjaxPanel that consists of a RadTextBox and also a RadPanelBar within another RadAjaxPanel. Notes that are already in the database will populate into their own RadPanelbar items when the page is loaded.  The user enters some text into the RadTextBox and clicks "save."  For some strange reason, once the save button is clicked - the RadPanelBar disappears and is not shown again unless the whole control is closed and reopened.  Another strange issue is that every now and then, the text will not save if it is entered and the save button is clicked too quickly.




<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Notes.ascx.cs" Inherits="Notes" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<html> 
<head> 
    <style type="text/css"
        body 
        { 
            background-color: #d3d3d3; 
        } 
        img 
        { 
            border: none; 
        } 
        .notesblock 
        { 
            width: 99%; 
            margin: 0 0 0 0; 
        } 
        .noteslist 
        { 
            color: #8a8c8f; 
            list-style-type: none; 
            padding: 0px 1px; 
            font-family: "Lucida Grande" , "Segoe UI" , "Bitstream Vera Sans" , Tahoma, Verdana, Arial,sans-serif; 
            font-size: 10px; 
            line-height: 160%; 
        } 
        #saveButton 
        { 
            position: absolute; 
            top: 280px; 
            right: 75px; 
        } 
        #cancelButton 
        { 
            position: absolute; 
            top: 280px; 
            right: 12px; 
        } 
        #expandButton 
        { 
            position: absolute; 
            top: 20px; 
            right: 5px; 
        } 
 
    </style> 
 
    <script type="text/javascript"
        function clearText(field) { 
 
            var selectString = "Click to Enter New Note"
 
            if (field.defaultValue == selectString) field.value = ''
 
            //        if (field.defaultValue == selectString) field.value = ''
            //        else if (field.value == '') fieldfield.value = field.defaultValue;     
        } 
 
 
        function resizeTB() { 
            var tb = $find("<%= txtUserNote.ClientID %>"); 
//            tb._originalTextBoxCssText = "width:99%;height:35px;"
//            tb.updateCssClass(); 
 
            return false; 
        } 
 
 
        function ButtonClick(sender, e) { 
            var radTextBox = sender
            radTextBox.raisePostBackEvent(); 
        } 
 
    </script> 
 
</head> 
<body bgcolor="#F4F4F4" runat="server" id="MainBody"
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%"
        <asp:Literal ID="notesHeader" runat="server"
        </asp:Literal> 
        <telerik:RadTextBox ID="txtUserNote" runat="server" TextMode="MultiLine" Width="99%" 
            Height="15px" Visible="False" EmptyMessage="Click to Enter New Note" Font-Size="10px" 
            AutoPostBack="true"
        </telerik:RadTextBox> 
        <div id="expandButton"
            <asp:ImageButton runat="server" ID="expandTbButton" ImageUrl="images/expand.gif" 
                OnClientClick="return resizeTB()" /> 
        </div> 
        <div id="saveButton"
            <asp:Button ID="SaveButton" Height="20px" Font-Size="10px" runat="server" Text="Save" 
                Visible="False" OnClick="SaveButton_Click" /> 
        </div> 
        <div id="cancelButton"
            <asp:Button ID="CancelButton" Height="20px" Font-Size="10px" runat="server" Text="Cancel" 
                OnClick="CancelButton_Click" Visible="False" /> 
        </div> 
    </telerik:RadAjaxPanel> 
    <div id="allnotes"
        <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" Width="562px" Style="background-color: #d3d3d3;"
            <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Style="background-color: #d3d3d3;" 
                EnableEmbeddedSkins="false" Skin="Custom" Height="200px" Width="562px" ExpandMode="FullExpandedItem"
            </telerik:RadPanelBar> 
        </telerik:RadAjaxPanel> 
    </div> 
</body> 
</html> 
 
 
 
 
    public partial class Notes : System.Web.UI.UserControl, IPostBackDataHandler 
    { 
        #region variables 
        private string noteText = string.Empty; 
        private string userNote = string.Empty; 
        private string sessionNoteKey = "4"
        private string modeKey = "5"
        private string tempNoteTextKey = "6"
        public static string invoiceNotesObjectKey = "7"
        #endregion 
 
        #region Page event handlers 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            Notes notes = (Notes)Session[invoiceNotesObjectKey]; 
 
            LoadNoteHistory(notes); 
 
            if (notes == null) 
            { 
                notes = new Notes(); 
            } 
 
            txtUserNote.Visible = true
            CancelButton.Visible = true
            SaveButton.Visible = true
 
        } 
        #endregion 
 
        #region enumerations 
        private enum Mode 
        { 
            Delete = 0
            Edit, 
            New 
        } 
        #endregion 
 
        #region properties 
        public string NoteText 
        { 
            get { return noteText; } 
            set { noteText = value; } 
        } 
 
        public string UserNote 
        { 
            get { return userNote; } 
            set { userNote = value; } 
        } 
        #endregion 
 
        #region public methods 
        public void AddNote(Invoice invoice) 
        { 
            Notes notes = ((Notes)Session[this.sessionNoteKey]); 
            Note note = notes[notes.Count - 1]; 
            note.DateTime = System.DateTime.Now; 
            note.DocId = invoice.ID; 
            note.Username = invoice.Username; 
            note.Save = true
            invoice.Notes.Add(note); 
        } 
 
 
        public bool LoadNoteHistory(Notes notes) 
        { 
            StringBuilder stringBuilder; 
            int counter = 1
 
            Session[this.sessionNoteKey] = notes; 
 
            XmlDocument xmlDoc = new XmlDocument(); 
            XmlElement notesBlock = xmlDoc.CreateElement("div"); 
            notesBlock.SetAttribute("class", "notesblock"); 
            xmlDoc.AppendChild(notesBlock); 
 
 
            stringBuilder = new StringBuilder("<div class=\"notesblock\">"); 
 
            stringBuilder.Append("<ol class=\"noteslist\">"); 
 
            stringBuilder.Append("<li>"); 
 
            notesHeader.Text = stringBuilder.ToString(); 
 
            xmlDoc = new XmlDocument(); 
            notesBlock = xmlDoc.CreateElement("div"); 
            notesBlock.SetAttribute("class", "notesblock"); 
            xmlDoc.AppendChild(notesBlock); 
 
 
            RadPanelBar1.Items.Clear(); 
 
            for (int i = 0; i < notes.Count; i++) 
            { 
                String userName = notes[i].Username; 
                String pendingStatus = " - Pending "
                String dateTime = notes[i].DateTime.ToShortDateString(); 
                String noteText = notes[i].Text.ToString(); 
                String newNote; 
 
                if (notes[i].Save == true) 
                { 
                    Session[tempNoteTextKey] = txtUserNote.Text; 
                    newNote = userName + pendingStatus + dateTime + " " + noteText; 
                     
                    txtUserNote.Text = notes[i].Text; 
                } 
 
                else 
                { 
                    CreateRPI(userName, dateTime, noteText); 
                } 
 
                counter++; 
            } 
 
 
            if (this.noteText.Length != 0) 
            { 
                return true; 
            } 
 
            return false; 
        } 
        #endregion 
 
        #region protected methods 
 
        protected void CancelButton_Click(object sender, EventArgs e) 
        { 
            txtUserNote.Text = string.Empty; 
            txtUserNote.Visible = false
            CancelButton.Visible = false
            SaveButton.Visible = false
        } 
 
 
        protected void SaveButton_Click(object sender, EventArgs e) 
        { 
            Note note; 
            CIS.Common.Business.Objects.InvoiceRouter.Notes notes; 
            bool isThereANewNote; 
 
            if (txtUserNote.Text.Length != 0) 
            { 
                notes = (Notes)Session[this.sessionNoteKey]; 
 
                isThereANewNote = false
 
                foreach(Note n in notes) { 
                    if (n.Save) 
                    { 
                        isThereANewNote = true
                        break; 
                    } 
                } 
 
                if (!isThereANewNote) 
                { 
                    note = new Note(); 
                    note.DateTime = System.DateTime.Now; 
                    if (Session[tempNoteTextKey] == null) 
                    { 
                        note.Text = txtUserNote.Text; 
                    } 
                    else 
                    { 
                        note.Text = Session[tempNoteTextKey].ToString(); 
                    } 
 
                    txtUserNote.Text = note.Text; 
                    note.Username = (Session[Key]).UserName.ToUpper(); 
                    note.Save = true
                    notes.Add(note); 
                } 
                else 
                { 
                    note = notes[notes.Count - 1]; 
                    note.DateTime = System.DateTime.Now; 
                    if (Session[tempNoteTextKey] == null) 
                    { 
                        note.Text = txtUserNote.Text; 
                    } 
                    else 
                    { 
                        note.Text = Session[tempNoteTextKey].ToString(); 
                    } 
 
                    txtUserNote.Text = note.Text; 
                     
                    note.Save = true;                     
                } 
                 
                LoadNoteHistory(notes); 
                 
            } 
            txtUserNote.Visible = true
            CancelButton.Visible = true
            SaveButton.Visible = true
        } 
 
        protected void txtUserNote_TextChanged(object sender, EventArgs e) 
        { 
            this.userNote = txtUserNote.Text; 
        } 
        #endregion 
 
        #region event handlers 
 
 
 
        #endregion 
 
        #region IPostBackDataHandler Members 
 
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) 
        { 
            return true; 
        } 
 
        public void RaisePostDataChangedEvent() 
        { 
            //Not Implemented 
        } 
 
        #endregion 
 
        #region RadPanelItem Creation 
 
 
        RadPanelItem CreateRPI(String panelItemName1, String panelItemName2, String panelItems1) 
        { 
            RadPanelItem rpi = new RadPanelItem(); 
            rpi.Text = panelItemName1 + " " + panelItemName2; 
            rpi.Font.Size = 8
            RadPanelItem rpItem = new RadPanelItem(); 
            rpItem.Text = panelItems1
            rpItem.Font.Size = 8
            rpi.Items.Add(rpItem); 
            RadPanelBar1.Items.Add(rpi); 
            return rpi; 
        } 
 
        RadPanelItem CreateNewNote(String panelItemName1, String pendingItem, String panelItemName2, String panelItems1) 
        { 
            RadPanelItem rpi = new RadPanelItem(); 
            rpi.Text = panelItemName1 + pendingItem + panelItemName2; 
            rpi.Font.Size = 8
            RadPanelItem rpItem = new RadPanelItem(); 
            rpItem.Text = panelItems1
            rpItem.Font.Size = 8
            rpi.Items.Add(rpItem); 
            RadPanelBar1.Items.Add(rpi); 
            return rpi; 
        } 
         
 
 
        #endregion 
    } 
 
 
 

Yana
Telerik team
 answered on 29 Oct 2009
2 answers
137 views
Hi
   I need Javascript for showdrop visible=true when not showing dropdown

For ex
    var combo =$find("<%= ddlGC.ClientID %>");
If(combo.showdropdown==false){
combo.showdropdown;
}
But when i set like this its flickering.
pasam Anna
Top achievements
Rank 1
 answered on 29 Oct 2009
1 answer
83 views
hi,
is it possible to set panel bar items with images only?

thanks
puneet

Princy
Top achievements
Rank 2
 answered on 29 Oct 2009
1 answer
118 views
Hi

Please Help Me
I was Using Radcontext Menu To Display radwindow ....can u explain anyone of the solution For that
Shinu
Top achievements
Rank 2
 answered on 29 Oct 2009
1 answer
104 views
Hi,
I am setting Top and left properties of the ajax rad window in the following way

<radw:RadWindow runat="server" NavigateUrl="CandidateReportAdvancedOptions.aspx" ReloadOnShow="true" ID="RadWindow3" SkinsPath="~/RadControls/Window/Skins" Top="500"   Left="10000" Title="Candidate Report Advanced Options" Height="250px" Width="400px" Modal="True" VisibleStatusbar="False" Behavior="Close" ></radw:RadWindow>

and I am unable to see any change in the position of the rad window with or without the left and top properties.

Am I missing anything here.

Please suggest.

Thanks in Advance.
Vidyasagar

Georgi Tunev
Telerik team
 answered on 29 Oct 2009
4 answers
192 views
I have a simple RadGrid bound to a business object. When I Add or Edit with the Automatic PopUp, I can not get the new / updated value from the PopUp window.

The Grid is setup with the following:
        <telerik:RadGrid ID="LocationGrid" runat="server" Skin="Web20" OnDeleteCommand="OnLocationDelete" 
            OnInsertCommand="OnLocationInsert" OnItemDeleted="OnLocationItemDeleted" OnItemInserted="OnLocationItemInserted" 
            OnItemUpdated="OnLocationItemUpdated" OnNeedDataSource="OnNeedDataSource"  
            OnUpdateCommand="OnLocationUpdate" ShowStatusBar="True"  
            AutoGenerateColumns="False" GridLines="None" onitemcommand="OnItemCommand"
            <PagerStyle Mode="NextPrevAndNumeric" /> 
            <MasterTableView EditMode="PopUp" CommandItemDisplay="Top"
                <Columns> 
                    <telerik:GridBoundColumn DataField="ID" UniqueName="colID" Visible="false" DataType="System.Int32"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Description" UniqueName="colDescription" HeaderText="Description"
                    </telerik:GridBoundColumn> 
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="colDelete" HeaderText="Delete"
                    </telerik:GridButtonColumn> 
                    <telerik:GridButtonColumn CommandName="Edit" Text="Edit" UniqueName="colEdit" HeaderText="Edit"
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings CaptionFormatString="Edit Location" /> 
            </MasterTableView> 
        </telerik:RadGrid> 
 

I am binding to a simple business object with the following code:
        private List<Location> LocationList  
        { 
            get 
            { 
                return Session["LocationList"as List<Location>; 
            } 
            set 
            { 
                Session["LocationList"] = value; 
            } 
        } 
 
        private void BuildInitialList() 
        { 
            LocationList = new List<Location> 
                { 
                    new Location() {ID = 1, Description = "Some Location"}, 
                    new Location() {ID = 2, Description = "Some Other Location"}, 
                }; 
        } 
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
                BuildInitialList(); 
            LocationGrid.DataSource = LocationList; 
            LocationGrid.DataBind(); 
        } 
 

When I click on Edit for one of the values, I am able to change the existing value for the description, but both methods for retrieving the new value in the code below return the old value:
protected void OnLocationUpdate(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    GridEditableItem item = e.Item as GridEditableItem; 
     
    // Description is the old value 
    string Description = (item["colDescription"].Controls[0] as TextBox).Text; 
 
    // values["Description"] is the old value 
    Dictionary<stringstring> values = new Dictionary<stringstring>(); 
    item.ExtractValues(values); 
 

Any ideas?






Akber Ali
Top achievements
Rank 1
 answered on 29 Oct 2009
2 answers
110 views
I need to simulate a new appointment insert by clicking on a button that is outside of RadScheduler control?

I have advanced Insert/Edit templete. Tried  showInsertFormAt, but for some reasons id did not display Advanced insert form.

Thank you!
Andrei Palvinski
Top achievements
Rank 1
 answered on 29 Oct 2009
2 answers
78 views
Hi

Status or title bar of an open window only shows when the window is minimized.
Is this really implemented this way unlike the older versions or is there a way to achieve the same by tweaking properties and workarounds?

Please help.

Thanks

Mark
mac-mac
Top achievements
Rank 1
 answered on 29 Oct 2009
3 answers
133 views
In general I am frustrated with the documentation and exmples for Telerik Rad Control especially the grid.  Most examples are too trivial and explore only basic stuff but when the detail comes, I may be spending hours on trying to find the right way to solve the issue.
 That is very unproductive.

Anyway, right now I am trying to solve a simple thing.  I am using "InPlace" editing in the grid and a simple GridBoundColumn.  When switched to the edit mode, the edit box size is much smaller the the width of my column.  How do I control this in ASPX file?

 

Hugo Furth
Top achievements
Rank 1
 answered on 28 Oct 2009
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?