Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
178 views
If you go to your demo and run http://demos.telerik.com/aspnet-ajax/spell/examples/phoneticalgorithm/defaultcs.aspx
please do the following: enter the word Tresting
Phonetic won't give you a testing suggestion
while edit distance does give me testing suggestion.

ok so I go back to my code and add the edit distance based spelling search to my rad editor. But this does not work. When I search I do not get the testing suggestion. It gives me the same suggestions as the Phonetic based search. Please help, thanks.

 

<telerik:RadEditor runat="server" ID="retNotesEditor" SkinID="BasicSetOfTools" Height="400px" OnClientLoad="OnClientLoad" SpellCheckSettings-SpellCheckProvider="EditDistanceProvider" spell>

 

 

<Content>

 

 

</Content>

 

 

</telerik:RadEditor>

 



Rumen
Telerik team
 answered on 30 Dec 2009
2 answers
184 views
I have an Adobe Flash app that needs to retrieve an image from a URL on a webserver. If I just put the radbinary image control inside an ASPX page I can see the image if I browse directly to the page. But the flash application doesn't think it is in image. How can I do this?
robertgalvinjr
Top achievements
Rank 1
 answered on 30 Dec 2009
2 answers
131 views
When I run the DEMO it works fine. When I try to copy and paste the code into my project and run it, the spell checking example produces this huge multi lines toolbar, instead of the one-line toolbar.
http://localhost:8301/radcontrols_aspnetajax/editor/examples/spellchecker/defaultcs.aspx


What am I missing?

Martin
Top achievements
Rank 1
 answered on 30 Dec 2009
3 answers
193 views
We have a similar page to the demo grid here: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filteringtemplatecolumns/defaultcs.aspx In many of the columns, we have RadComboBoxes similar to the "Custom TemplateColumn Country" column.

Issue occurring / High Level:
If I move one of the columns, no postbacks occur. If I then use one of these RadComboBoxes to filter, then a postback occurs and all of the values in the drop downs (filled on prerender) are cleared out. If I then filter again (causing a postback) the values reappear. I'm not handling a certain event. Any ideas out there? Once you see the steps, it should seem obvious, but I'm not seeing it.

Any help would be great!

Steps to Reproduce:
  1. Load grid: Grid is not automatically created. I create the datasource and databind, then use the radgrid prerender to fill the drop down values in the gridboundcolumn filtertemplates.
  2. Use the mouse to move one of the columns to a new location.
  3. Use a column's filter (RadComboBox) to filter an item in the grid. (Postback occurs, calls special function on the server which again sets the datasource and rebind, then runs the radGrids prerender.
  4. Go and open one of the drop downs filled on the prerender and they're empty.
  5. If I change a filter somewhere else that causes a postback, the RadComboBoxes are refilled

ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
            if (!this.IsPostBack)
            {
                RadGridApples.DataSource = [datasource];
                RadGridApples.DataBind();
            }
}

public void GetNewResults(object sender, EventArgs e)
{
            //Update the datasource code

            RadGridApples.DataSource = [enter datasource here];
            RadGridApples.DataBind();
}

protected void RadGridApples_PreRender(object sender, EventArgs e)
        {
            foreach (GridFilteringItem filter in RadGridApples.MasterTableView.GetItems(GridItemType.FilteringItem))
            {
                #region Drop Down
                radComboBoxApples = (RadComboBox)filter.FindControl("radComboBoxApples");
                if (radComboBoxApples != null)
                {
                    radComboBoxApples.ClearSelection();
                    radComboBoxApples.DataSource = Enum.GetNames(typeof(Apples)).ToList();
                    radComboBoxApples.DataBind();
                }

ASPX

Grid information:
<telerik:RadGrid ID="RadGridApples" runat="server" AllowFilteringByColumn="True"
  AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
  GridLines="None" onprerender="RadGridApples_PreRender" Width="100%"
  PageSize="5" OnPageIndexChanged="RadGridApples_PageIndexChanged"
  OnSortCommand="GetNewResults" OnPageSizeChanged="GetNewResults" Skin="Outlook"
     >

Example column:
<telerik:GridBoundColumn HeaderText="Apples" UniqueName="appleCombo"
      DataField="Apple"
      SortAscImageUrl="\App_Themes\XYZ\img\RadGrid\SortAsc.gif"
      SortDescImageUrl="\App_Themes\XYZimg\RadGrid\SortDesc.gif"
      SortExpression="Apple"
      >
      <HeaderStyle Width="90px" />
      <ItemStyle HorizontalAlign="Left" Width="90px"></ItemStyle>
      <FilterTemplate>
        <telerik:RadComboBox ID="RadComboBoxApples" runat="server" AutoPostBack="True" AppendDataBoundItems="true" Width="100%" OnSelectedIndexChanged="GetNewResults">
          <Items>
            <telerik:RadComboBoxItem Text="" Value="" />
          </Items>
        </telerik:RadComboBox>
      </FilterTemplate>
    </telerik:GridBoundColumn>

Client Settings in the grid:
<ClientSettings AllowColumnsReorder="True"
    AllowRowHide="True" AllowRowsDragDrop="True" ReorderColumnsOnClient="True">
    <Selecting AllowRowSelect="True" />
    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    <Resizing AllowColumnResize="True" ClipCellContentOnResize="False" />
  </ClientSettings>


Joe Bailey
Top achievements
Rank 1
 answered on 30 Dec 2009
3 answers
160 views
Based on the information on this page,
http://www.telerik.com/products/aspnet-ajax/resources/right-to-left-support.aspx

It says that:

"Not/Applicable" means that the control does not have any "hard-coded" strings to localize and everything comes from datasource or properties.

What does this really mean? What about RTL? Should I assume that the Chart component does not offer an RTL support but there is nothing (i.e. no hard coding done) that would prevent it from rendering in an RTL fashion. If so, is there anything that can be  done to make it support RTL (i.e. css tweaks).

Judging from the numerous requests asking for  RTL support in radControls, I am puzzled by the slowness in building a seamless framework to support RTL in *all* controls. In this global economy, not being able to display information in a localized manner would surely have an impact on the bottom line.




Velin
Telerik team
 answered on 30 Dec 2009
2 answers
141 views
Hi there,
I'm facing a problem using XmlHttpPanel  here's my scenario:
I have two custom controls(webpart) in my page each one inside a different Panel , the first one has a RadGrid and second One a RadPanelbar that shows details for selected GridRow.
currently I'm using a AjaxSetting  to update the Panelbar by calling an AjaxRequest on row select function of RadGrid on client side and everything works as expected.
but unfortunately performance is really low this way! so I tried to use XmlHttpPanel , I'm doing this  by set_value() function in javascript function for rowSelected event of the Grid, the problem is that this way the panelBar won't load properly and clicking Bars won't work either very similar to the situation where RadScriptManager is not registerd  correctly. It seems like the problem is this issue but the provided solutions did not solve my problem.
I should also mention that since the ServiceRequest event fires after the CreateChildControl method of My RadPanelbar webpart I had to use another method to create the panel bar with ServiceRequest event value (I also tried creating and adding the panelBar in this method which made the situation even worth and panelBar lost it's skin too!), Is this a correct approach?
thanks In advance.
baha2r
Top achievements
Rank 1
 answered on 30 Dec 2009
2 answers
176 views
Hi,

I would like to limit the number of rows expandable in my grid to a single row.  My solution has a RadGrid with a NestedViewTemplate.  When a user selects the row and it is expanded I'd like to collapse any other rows that are already expanded. 

I'd like to do that on the client side before the new row is expanded and databound.  I've tried the client-event OnGroupExpanded but thats not the event being fired.

Thanks
Jase
Daniel
Telerik team
 answered on 30 Dec 2009
3 answers
181 views
I'm running my website on ie8 in compatablity View on.  I"m using ASP.net 2008 V3.5 Sp1.  When ever I click to expand a node I get an error "Microsoft JScript runtime error: Array length must be assigned a finite positive number" in prototype.js.  I can view the Javascript

shift: function() {  
    var result = this[0];  
    for (var i = 0; i < this.length - 1; i++)  
      this[i] = this[i + 1];  
    this.length--;  
    return result;  
  }, 

What's happening is that this.length is equals 0 so when the code subtracts 1 it become -1 which isn't a valid value. 

Here's my code
<%@ Register TagPrefix="radG" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentTitle" runat="server">  
Documents  
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentBody" runat="server">  
<script type="text/javascript">  
 
 
            function RowContextMenu(sender, e)  
            {  
              
                var menu = $find("<%= cRadMenu.ClientID %>");  
                if(menu != null)  
                {  
                    var index = e.get_itemIndexHierarchical();     
                      
                    //-------------------------------------  
                   // var item = menu.findItemByText("Add");  
                    //var parentItem = item.get_parent();  
                    //Removes the item from the items collection of the clicked item's parent   
                    //item.hide();  
                           
                    //if(item != null)  
                     //   menu.delete(item);  
 
 
                    document.getElementById("radGridClickedRowIndex").value = index;  
                     var eevt = e.get_domEvent();  
                       
                         
                    menu.show(evt);  
                    evt.cancelBubble = true;  
                    if (evt.stopPropagation)  
                    {  
                        evt.stopPropagation();  
                    }  
                }  
                /*  
                var contextMenu = $find("<%= cRadMenu.ClientID %>");  
                document.getElementById("radGridClickedRowIndex").value = index;  
              
                if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget)))  
                {  
                   contextMenu.show(e);  
                }  
                        
                $telerik.cancelRawEvent(e);*/  
 
            }  
            </script> 
              
 
   <h1>Documents</h1> 
<div class="row">     
    <div class="left_text_column" style="width:350px;border-right:solid 1px #eee;padding-bottom:10px">  
         
        <radG:RadTreeView   
            ID="RadTreeView1"   
            runat="server"    
            SingleExpandPath ="true"    
            ExpandAnimation-Type="OutQuint"   
            ExpandAnimation-Duration="600"   
            OnNodeClick="RadTreeView1_NodeClick"    
            OnNodeExpand = "RadTreeView1_NodeExpand"   
        > 
        </radG:RadTreeView> 
          
    </div> 
      
    <radG:RadContextMenu   
        id="cRadMenu"    
        Runat="server"   
        Skin="WebBlue"    
        OnItemClick="RadMenu1_ItemClick" 
    > 
        <Items> 
                <radG:RadMenuItem Text="Delete"/>  
                <radG:RadMenuItem Text="Edit"/>  
 
        </Items> 
    </radG:RadContextMenu> 
    <div class="right_text_column" style="width:590px">  
        <radG:RadGrid   
            ID="RadGrid1"   
            OnItemCommand="RadGrid1_ItemCommand"   
            runat="server"   
            HorizontalAlign="NotSet"    
            Skin="WebBlue"    
            AutoGenerateColumns="False"   
            OnItemDataBound="RadGrid1_ItemDataBound"   
            OnNeedDataSource="RadGrid1_OnNeedDataSource"     
            OnInsertCommand="RadGrid1_InsertCommand" 
         > 
           <MasterTableView DataKeyNames= "Id" EditMode ="EditForms" > 
               <Columns> 
                   <radG:GridTemplateColumn HeaderText="Name"  SortExpression="DocumentName">  
                        <ItemTemplate> 
                            <asp:LinkButton ID="lbLink" CommandName="Download" CommandArgument='<%# Bind("FileLocation")%>' runat="server" Text='<%# Bind("Name")%>'  Enabled='<%# !(bool)(DataBinder.Eval(Container, "DataItem.Disabled"))%>'></asp:LinkButton> 
                        </ItemTemplate> 
                   </radG:GridTemplateColumn> 
                   <radG:GridBoundColumn AllowSorting="true" DataField="Description" HeaderText="Description" SortExpression="Description"></radG:GridBoundColumn> 
                   <radG:GridBoundColumn AllowSorting="true" DataField="TypeName" HeaderText="Type" SortExpression="TypeName" ></radG:GridBoundColumn> 
                   <radG:GridBoundColumn AllowSorting="true" DataField="FileSizeString" HeaderText="Size" SortExpression="FileSize" ></radG:GridBoundColumn> 
               </Columns> 
               <RowIndicatorColumn UniqueName="RowIndicator" Visible="False">  
                   <HeaderStyle Width="20px" /> 
               </RowIndicatorColumn> 
               <EditFormSettings EditFormType="Template">  
                    <FormTemplate> 
                        <div style="clear:both;margin:3px;">  
                            <label for="docFileUpload">File:</label> 
                            <asp:FileUpload ID="docFileUpload" runat="server" width="70%"/>  
                              
                            <asp:TextBox   
                                ID="txtDescription"   
                                runat="server"   
                                Width="90%"   
                                Text='<%# Bind( "Description") %>' 
                            > 
                            </asp:TextBox> 
                            <asp:RegularExpressionValidator  
                            id="regExDocValidator1" runat="server" 
                            ErrorMessage="Upload .zip, .jpg, .gif, .pdf & .doc  only." 
                            ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.pdf|.PDF|.doc|.DOC|.ZIP|.zip)$" 
                            ControlToValidate="docFileUpload" ValidationGroup="uploadValidationGroup" Display="Dynamic"></asp:RegularExpressionValidator> 
                        </div> 
                        <div style="clear:both;margin:3px;">  
                            <asp:Button ID="btnUpdate"   
                                        Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Insert" : "Update" %>' 
                                        runat="server"   
                                        CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>' 
                            > 
                            </asp:Button>&nbsp;  
                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" 
                            CommandName="Cancel"></asp:Button> 
                        </div> 
                    </FormTemplate> 
                </EditFormSettings> 
           </MasterTableView> 
           <ClientSettings> 
                            <ClientEvents OnRowContextMenu="RowContextMenu" > 
                            </ClientEvents> 
                            <Selecting AllowRowSelect="true"  /> 
            </ClientSettings> 
           <FilterMenu  HoverBackColor="LightSteelBlue" HoverBorderColor="Navy" NotSelectedImageUrl="~/RadControls/Grid/Skins/Outlook/NotSelectedMenu.gif" 
               SelectColumnBackColor="Control" SelectedImageUrl="~/RadControls/Grid/Skins/Outlook/SelectedMenu.gif" 
               TextColumnBackColor="Window">  
                  
                  
           </FilterMenu> 
       </radG:RadGrid> 
         
          
        <asp:HiddenField ID="hfDocId" runat="server" /> 
        <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /> 
          
    </div> 
</div> 
 
 
</asp:Content> 

using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using System.Data.SqlClient;  
using System.IO;  
using Telerik.Web.UI;  
 
namespace TDMSF15.Documents  
{  
    public partial class Default : System.Web.UI.Page  
    {  
        string ConString = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;  
        RadTreeNode rtn = null;  
        protected void Page_Load(object sender, EventArgs e)  
        {  
 
            if (!Page.IsPostBack)  
            {  
                Session["TreeID"] = 0;  
                GenerateTreeView();  
                /* MembershipUser u = Membership.GetUser(Page.User.Identity.Name);
                 if (!Roles.IsUserInRole(u.UserName, Globals.Role_Administrator) &&
                !Roles.IsUserInRole(u.UserName, Globals.Role_DataEntry))
                 {
                     cRadMenu.Enabled = false;
                     cRadMenu.Visible = false;
                 }*/ 
            }  
        }  
 
        public void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
        {  
           // if (e.CommandName != "Download")  
            //    return;  
 
            RadTreeNode node = this.RadTreeView1.SelectedNode;  
             MembershipUser u = Membership.GetUser(Page.User.Identity.Name);  
              
            if (e.CommandName == RadGrid.InitInsertCommandName)  
            {  
                //Add new" button clicked  
                e.Canceled = true;  
                //Prepare an IDictionary with the predefined values  
                System.Collections.Specialized.ListDictionary newValues = new 
                                        System.Collections.Specialized.ListDictionary();  
 
                newValues["Description"] = string.Empty;
                newValues["ReadOnly"] = false;
                //Insert the item and rebind
                this.rtn = node;
                e.Item.OwnerTableView.InsertItem(newValues);
                
               // RadGrid1.Rebind();
            }
            else 
                if (e.CommandName == "Download")
            {
                string fileName = e.CommandArgument.ToString();
                
               
                string fileLocation = Path.Combine(Globals.uploadDir, fileName);
                if (!File.Exists(fileLocation))
                {
                    throw new Exception("File [" + fileLocation + "] does not exisits");
                }
                FileInfo file = new FileInfo(fileLocation);
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment;filename=" + file.Name);
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.Buffer = true;
                Response.ContentType = "application/octet-stream";
                Response.WriteFile(file.FullName);
            }
            else if (e.CommandName == "Update")
            {
       /*         if (!Roles.IsUserInRole(u.UserName, Globals.Role_Administrator) &&
           !Roles.IsUserInRole(u.UserName, Globals.Role_DataEntry))
                {
                    return;
                }*/
                //get File
                FileUpload fileUpload = (FileUpload)e.Item.FindControl("docFileUpload");
                //TextBox name = (TextBox)e.Item.FindControl("txtName");
                TextBox description = (TextBox)e.Item.FindControl("txtDescription");
               
                //int radGridClickedRowIndex;
                //radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);
                    
                int docId = (int) RadGrid1.MasterTableView.DataKeyValues[Convert.ToInt32(e.Item.ItemIndex)]["Id"];
                if (docId > 0)
                {
                    Domain.TDMSDocument doc = null;
                    if (LxT.Common.Utilities.StringUtil.GetIntValue(this.hfDocId.Value, -1)
                                == Domain.TDMSDocument.globalDocument)
                        doc = (Domain.TDMSDocument)Persistence.TDMSHelpers.GetDocumentHelper().Select(docId);
                    else
                        doc = (Domain.TDMSDocument)Persistence.TDMSHelpers.GetUploadedDocumentHelper().Select(docId);
                    //doc.Name = name.Text;
                    doc.Description = description.Text;
                    doc.modifiedBy = User.Identity.Name;
                    if (fileUpload.HasFile)
                    {
                        doc.FileSize = fileUpload.PostedFile.ContentLength;
                        string newFileLocation = doc.FileLocation.Replace(doc.Name, 
                            fileUpload.FileName);
                        
                        string _filePath = Path.Combine(Globals.uploadDir,
                        newFileLocation/*fileUpload.FileName*/);
                        
                        doc.Name = fileUpload.FileName;
                        
                        //delete old file
                        File.Delete(Path.Combine(Globals.uploadDir,
                                doc.FileLocation));
                        doc.FileLocation = newFileLocation;
                        //save ew file
                        fileUpload.SaveAs(_filePath);
                     
                    }
                    if (LxT.Common.Utilities.StringUtil.GetIntValue(this.hfDocId.Value, -1)
                                == Domain.TDMSDocument.globalDocument)
                        Persistence.TDMSHelpers.GetDocumentHelper().Update(doc);
                    else
                        Persistence.TDMSHelpers.GetUploadedDocumentHelper().Update(doc);
                }
                LoadGridData(node);
            }
            else if (e.CommandName == "Cancel")
            {
                LoadGridData(node);
            }
            
        }
        private void GenerateTreeView()
        {
            SqlConnection dbCon = new SqlConnection(ConString);
            dbCon.Open();
            SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM DocumentTree ORDER BY TreeOrder", dbCon);
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["TreeId"], ds.Tables[0].Columns["parentId"]);
            foreach (DataRow dbRow in ds.Tables[0].Rows)
            {
                string documentId = null;
                string stage = string.Empty;
                int substage = Globals.nullInt;
                int objectType = Globals.nullInt;
                bool allowAdd = false;
                string folder = string.Empty;
                if (dbRow["DocumentType"] != DBNull.Value)
                    documentId = (string)dbRow["DocumentType"];
                if (dbRow["stage"] != DBNull.Value)
                    stage = (string)dbRow["stage"];
                if (dbRow["substage"] != DBNull.Value)
                    substage = (int)dbRow["substage"];
                if (dbRow["objecttype"] != DBNull.Value)
                    objectType = (int)dbRow["objecttype"];
                if (dbRow["allowAdd"] != DBNull.Value)
                    allowAdd = (bool)dbRow["allowAdd"];
                if (dbRow["folder"] != DBNull.Value)
                    folder = (string)dbRow["folder"];
                string readRoles = string.Empty;
                string editDeleteRoles = string.Empty;
                string  addRoles = string.Empty;
                if (dbRow["ViewList"] != DBNull.Value)
                    readRoles = (string)dbRow["ViewList"];
                if (dbRow["EditDeleteList"] != DBNull.Value)
                    editDeleteRoles = (string)dbRow["EditDeleteList"];
                if (dbRow["AddList"] != DBNull.Value)
                    addRoles = (string)dbRow["AddList"];
                if (dbRow.IsNull("parentId"))
                {
                    RadTreeNode node = CreateNode(dbRow["NodeName"].ToString(), false, dbRow["TreeId"].ToString(), documentId, stage, 
                        substage, objectType, allowAdd, folder, 
                        readRoles, editDeleteRoles, addRoles);
                    RadTreeView1.Nodes.Add(node);
                    RecursivelyPopulate(dbRow, node);
                }
            }
        }
        public void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            System.Drawing.Color c = System.Drawing.Color.FromName("#eeeeee");
            
            if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem)
            {
                // int id = (Int32)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
                Domain.TDMSUploadedDocument d = e.Item.DataItem as Domain.TDMSUploadedDocument;
                if (d != null)
                {
                    if (d.StageTypeId == Globals.Stage_NDI_Reinspection)
                    {
                        e.Item.BackColor = c;
                    }
                }
            }
        }
        
    
        private void RecursivelyPopulate(DataRow dbRow, RadTreeNode node)
        {
            foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation"))
            {
                string documentId = null;
                string stage = string.Empty;
                int substage = Globals.nullInt;
                int objectType = Globals.nullInt;
                bool allowAdd = false;
                string folder = string.Empty;
                if (childRow["DocumentType"] != DBNull.Value)
                    documentId = (string)childRow["DocumentType"];
                if (childRow["stage"] != DBNull.Value)
                    stage = (string)childRow["stage"];
                if (childRow["substage"] != DBNull.Value)
                    substage = (int)childRow["substage"];
                if (childRow["objecttype"] != DBNull.Value)
                    objectType = (int)childRow["objecttype"];
                if (childRow["allowAdd"] != DBNull.Value)
                    allowAdd = (bool)childRow["allowAdd"];
                if (childRow["folder"] != DBNull.Value)
                    folder = (string)childRow["folder"];
                
               // childNode.ExpandMode = ExpandMode.ServerSide;
                 string readRoles = string.Empty;
                string editDeleteRoles = string.Empty;
                string  addRoles = string.Empty;
                if (dbRow["ViewList"] != DBNull.Value)
                    readRoles = (string)dbRow["ViewList"];
                if (dbRow["EditDeleteList"] != DBNull.Value)
                    editDeleteRoles = (string)dbRow["EditDeleteList"];
                if (dbRow["AddList"] != DBNull.Value)
                    addRoles = (string)dbRow["AddList"];
                RadTreeNode childNode = CreateNode(childRow["NodeName"].ToString(), false, childRow["TreeId"].ToString(), documentId, 
                    stage, substage, objectType, allowAdd, folder,
                    readRoles, editDeleteRoles, addRoles);
                childNode.PostBack = true;
                node.Nodes.Add(childNode);
                RecursivelyPopulate(childRow, childNode);
            }
        }
        protected void ProcessComponent(RadTreeNode nodeClicked, string docType, string stageId, int subStageId, int objectType)
        {
            nodeClicked.Nodes.Clear();
            /*int objectType = Globals.nullInt;
            if (stageId == Globals.Stage_NDI)
            {
                objectType = (int)Globals.StatusObjects.Part;
            }*/
            //get information from database, and add new nodes
            ArrayList dl = Persistence.TDMSHelpers.GetUploadedDocumentHelper().SelectComponentsByDocumentType(docType, stageId, subStageId, objectType) as ArrayList;
            foreach (LxT.Common.Utilities.Enumerated.EnumeratedSimple es in dl)
            {
                RadTreeNode node = new RadTreeNode(es.Name);
                node.Attributes.Add("ID", es.Id.ToString());
                node.PostBack = true;
                node.ExpandMode = Telerik.Web.UI.TreeNodeExpandMode.ServerSide;
                node.ImageUrl = "../images/folder.gif";
                node.Expanded = false;
                node.Attributes.Add("comp", "yes");
                node.Attributes.Add("doc", docType);
                node.Attributes.Add("stage", stageId);
                node.Attributes.Add("substage", subStageId.ToString());
                node.Attributes.Add("objectType", objectType.ToString());
                node.Attributes.Add("readRoles", nodeClicked.Attributes["readRoles"]);
                node.Attributes.Add("addRoles", nodeClicked.Attributes["addRoles"]);
                node.Attributes.Add("editDeleteRoles", nodeClicked.Attributes["editDeleteRoles"]);
                nodeClicked.Nodes.Add(node);
            }
        }
        private RadTreeNode CreateNode(string text, bool expanded, string id, string documentType, 
            string stage, int subStage, int objectType, bool allowAdd, string folder, 
            string  readRoles, string editDeleteRoles, string addRoles)
        {
            RadTreeNode node = new RadTreeNode(text);
            node.Expanded = expanded;
            node.ImageUrl = "../images/folder.gif";
             node.Attributes.Add("ID",id);
            node.PostBack = true;
            //node.ExpandMode = ExpandMode.ServerSide;
            int Id = LxT.Common.Utilities.StringUtil.ToIntIndex(id);
            node.Attributes.Add("folder", folder);
            node.Attributes.Add("allowAdd", allowAdd.ToString());
            node.Attributes.Add("readRoles", readRoles);
            node.Attributes.Add("addRoles", addRoles);
            node.Attributes.Add("editDeleteRoles", editDeleteRoles);
            if(!string.IsNullOrEmpty(documentType))
            {
                node.PostBack = true;
                node.ExpandMode = TreeNodeExpandMode.ServerSide;
                node.Attributes.Add("doc", documentType);
                if (!string.IsNullOrEmpty(stage))
                {
                    node.Attributes.Add("stage", stage.ToString());
                }
                if (subStage != Globals.nullInt)
                {
                    node.Attributes.Add("subStage", subStage.ToString());
                }
                if (objectType != Globals.nullInt)
                {
                    node.Attributes.Add("objectType", objectType.ToString());
                }
            }
            return node;
        }
        protected void ProcessSection(RadTreeNode nodeClicked)
        {
            nodeClicked.Nodes.Clear();
            int objectType = LxT.Common.Utilities.StringUtil.GetIntValue(nodeClicked.Attributes["objectType"],
                Globals.nullInt);
            string stageId = nodeClicked.Attributes["stage"];
            
            //get information from database, and add new nodes
            ArrayList dl = Persistence.TDMSHelpers.GetUploadedDocumentHelper().SelectSectionsByDocumentType(nodeClicked.Attributes["doc"], 
                LxT.Common.Utilities.StringUtil.GetIntValue(nodeClicked.Attributes["ID"], 0),
                nodeClicked.Attributes["stage"], 
                LxT.Common.Utilities.StringUtil.GetIntValue(nodeClicked.Attributes["substage"], 
                Globals.nullInt ),
                objectType
                ) as ArrayList;
             
            foreach (LxT.Common.Utilities.Enumerated.EnumeratedSimpleTxt es in dl)
            {
                RadTreeNode node = new RadTreeNode(es.IdTxt);
                node.Attributes.Add("ID",es.Name);
                node.PostBack = true;
                if (objectType != (int)Globals.StatusObjects.Section)
                {
                    
                    node.ExpandMode = Telerik.Web.UI.TreeNodeExpandMode.ServerSide;
                }
                node.ImageUrl = "../images/folder.gif";
                node.Expanded = false;
                node.Attributes.Add("type", Globals.StatusObjects.Section.ToString());
                node.Attributes.Add("doc", nodeClicked.Attributes["doc"]);
                node.Attributes.Add("stage", nodeClicked.Attributes["stage"]);
                node.Attributes.Add("substage", nodeClicked.Attributes["substage"]);
                node.Attributes.Add("readRoles", nodeClicked.Attributes["readRoles"]);
                node.Attributes.Add("addRoles", nodeClicked.Attributes["addRoles"]);
                node.Attributes.Add("editDeleteRoles", nodeClicked.Attributes["editDeleteRoles"]);
                nodeClicked.Nodes.Add(node);
            }
        }
        protected void ProcessPart(RadTreeNode nodeClicked)
        {
            nodeClicked.Nodes.Clear();
            //get information from database, and add new nodes
            ArrayList dl = Persistence.TDMSHelpers.GetUploadedDocumentHelper().SelectPartsByDocumentType(
                nodeClicked.Attributes["doc"], nodeClicked.Attributes["ID"],
                
                nodeClicked.Attributes["stage"],
                LxT.Common.Utilities.StringUtil.GetIntValue(nodeClicked.Attributes["substage"], 
                Globals.nullInt)) as ArrayList;
            foreach (LxT.Common.Utilities.Enumerated.EnumeratedSimpleTxt es in dl)
            {
                if (!string.IsNullOrEmpty(es.IdTxt))
                {
                    RadTreeNode node = new RadTreeNode(es.IdTxt);
                     node.Attributes.Add("ID",es.Name);
                    node.PostBack = true;
                    node.PostBack = true;
                    node.ExpandMode = TreeNodeExpandMode.ServerSide;
                    node.ImageUrl = "../images/folder.gif";
                    node.Attributes.Add("type", Globals.StatusObjects.Part.ToString());
                    node.Attributes.Add("doc", nodeClicked.Attributes["doc"]);
                    node.Attributes.Add("partid", es.IdTxt.Substring(4, 3));
                    node.Attributes.Add("section", nodeClicked.Attributes["ID"]);
                    node.Attributes.Add("stage", nodeClicked.Attributes["stage"]);
                    node.Attributes.Add("substage", nodeClicked.Attributes["substage"]);
                    node.Attributes.Add("readRoles", nodeClicked.Attributes["readRoles"]);
                    node.Attributes.Add("addRoles", nodeClicked.Attributes["addRoles"]);
                    node.Attributes.Add("editDeleteRoles", nodeClicked.Attributes["editDeleteRoles"]);
                    nodeClicked.Nodes.Add(node);
                }
            }
        }
        protected void ProcessSubPart(RadTreeNode nodeClicked)
        {
            nodeClicked.Nodes.Clear();
            //get information from database, and add new nodes
            ArrayList dl = Persistence.TDMSHelpers.GetUploadedDocumentHelper().SelectSubPartsByDocumentType(
                nodeClicked.Attributes["doc"], nodeClicked.Attributes["section"],
                  nodeClicked.Attributes["stage"], 
                  
                LxT.Common.Utilities.StringUtil.GetIntValue(nodeClicked.Attributes["substage"], 
                Globals.nullInt),
                nodeClicked.Attributes["partid"] 
                ) as ArrayList;
            foreach (LxT.Common.Utilities.Enumerated.EnumeratedSimpleTxt es in dl)
            {
                if (!string.IsNullOrEmpty(es.IdTxt))
                {
                    RadTreeNode node = new RadTreeNode(es.IdTxt);
                     node.Attributes.Add("ID",es.Name);
                    node.PostBack = true;
                    node.ImageUrl = "../images/folder.gif";
                    node.Attributes.Add("type", Globals.StatusObjects.Part.ToString());
                    node.Attributes.Add("doc", nodeClicked.Attributes["doc"]);
                    node.Attributes.Add("stage", nodeClicked.Attributes["stage"]);
                    node.Attributes.Add("substage", nodeClicked.Attributes["substage"]);
                    node.Attributes.Add("readRoles", nodeClicked.Attributes["readRoles"]);
                    node.Attributes.Add("addRoles", nodeClicked.Attributes["addRoles"]);
                    node.Attributes.Add("editDeleteRoles", nodeClicked.Attributes["editDeleteRoles"]);
                    nodeClicked.Nodes.Add(node);
                }
            }
        }
        protected void RadTreeView1_NodeExpand(object o, RadTreeNodeEventArgs e)
        {
            if (e.Node.Attributes["type"] != null)
            {
                if (e.Node.Attributes["partid"] == null) 
                    ProcessPart( e.Node);
                else
                    ProcessSubPart( e.Node);
            }
            else if (e.Node.Attributes["comp"] != null)
            {
                ProcessSection(e.Node);
            }
            else if  (!string.IsNullOrEmpty(e.Node.Attributes["doc"]))
            {
                //i actually want it to fail here if doc id is not integer
                string doc = e.Node.Attributes["doc"];
                string stage = e.Node.Attributes["stage"];
                int subStage = LxT.Common.Utilities.StringUtil.GetIntValue(e.Node.Attributes["substage"], Globals.nullInt);
                int objectType = LxT.Common.Utilities.StringUtil.GetIntValue(e.Node.Attributes["objecttype"], Globals.nullInt);
                ProcessComponent( e.Node, doc, stage, subStage, objectType);
               
            }
            e.Node.Expanded = true;
        }
        protected void LoadGridData(RadTreeNode node)
        {
            MembershipUser u = Membership.GetUser(Page.User.Identity.Name);
            ArrayList al = null;
            //WebProfile p = new WebProfile(Context.Profile);
            if (node == null)
            {
                RadGrid1.DataSource = new ArrayList();
              
            }
            else
            {
                TDMSF15.Domain.DocumentPermissions dp = new TDMSF15.Domain.DocumentPermissions();
                dp.Read = node.Attributes["readRoles"];
                dp.Add = node.Attributes["addRoles"];
                dp.EditDelete = node.Attributes["editDeleteRoles"];
                if (node.Attributes["type"] != null)
                {
                    if (node.Attributes["type"].CompareTo(Globals.StatusObjects.Section.ToString()) == 0)
                    {
                        al = new ArrayList(Persistence.TDMSHelpers.GetUploadedDocumentHelper().Select(
                          node.Attributes["ID"], null, node.Attributes["doc"],
                          node.Attributes["stage"], node.Attributes["substage"]));
                    }
                    else
                    {
                        al = new ArrayList(Persistence.TDMSHelpers.GetUploadedDocumentHelper().Select(
                            null, node.Attributes["ID"], node.Attributes["doc"],
                            node.Attributes["stage"], node.Attributes["substage"]));
                    }
                    hfDocId.Value = Domain.TDMSDocument.uploadedDocument.ToString();
                }
                else
                {
                    al = new ArrayList(Persistence.TDMSHelpers.GetDocumentHelper().SelectDocumentByTreeId(LxT.Common.Utilities.StringUtil.GetIntValue(node.Attributes["ID"], -1)));
                    hfDocId.Value = Domain.TDMSDocument.globalDocument.ToString();
                }
                string[] roles = dp.readRoles;
                bool read = false;
                foreach (string r in roles)
                {
                    if (!string.IsNullOrEmpty(r))
                    {
                        if (Roles.IsUserInRole(u.UserName, r))
                        {
                            read = true;
                            break;
                        }
                    }
                }
                if (!read)
                {
                    foreach (Domain.TDMSDocument d in al)
                    {
                        d.Disabled = true;
                    }
                }
                RadGrid1.DataSource = al;
        }
            //RadGrid1.DataBind();
            
           /* System.Collections.Specialized.ListDictionary newValues = new
            System.Collections.Specialized.ListDictionary();
            newValues["Description"] = "";  
            //Insert the item and rebind  
            RadGrid1.MasterTableView.InsertItem(newValues);  
            RadGrid1.MasterTableView.IsItemInserted = true;  
 
            if (RadGrid1.MasterTableView.Items.Count == 0)  
            {  
                RadGrid1.MasterTableView.IsItemInserted = true;  
            }*/  
              
        }  
 
        
        protected void RadGrid1_OnNeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
        {  
            LoadGridData(rtn);  
        }  
        protected void RadTreeView1_NodeClick(object o, RadTreeNodeEventArgs e)  
        {  
            if (RadGrid1.MasterTableView.IsItemInserted == true) RadGrid1.MasterTableView.IsItemInserted = false;  
 
             MembershipUser u = Membership.GetUser(Page.User.Identity.Name);  
             string[] roles = null;  
             /*if (Roles.IsUserInRole(u.UserName, Globals.Role_DataEntry) || Roles.IsUserInRole(u.UserName, Globals.Role_Administrator))
             {*/ 
 
                 TDMSF15.Domain.DocumentPermissions dp = new TDMSF15.Domain.DocumentPermissions();  
                 dp.Read = e.Node.Attributes["readRoles"];
                 dp.Add = e.Node.Attributes["addRoles"];
                 dp.EditDelete = e.Node.Attributes["editDeleteRoles"];
                 bool add = LxT.Common.Utilities.StringUtil.GetBooleanValue(e.Node.Attributes["allowAdd"], false);
                 if (add)
                 {
                     
                     roles = dp.addRoles;
                     add = false;
                     foreach (string r in roles)
                     {
                         if (!string.IsNullOrEmpty(r))
                         {
                             if (Roles.IsUserInRole(u.UserName, r))
                             {
                                 add = true;
                                 break;
                             }
                         }
                     }
                     if(add)
                        RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
                     else
                        RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
               
                 }
                 else
                 {
                     RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
                 }
                 roles = dp.editDeleteRoles;
                 bool editDelete = false;
                 foreach (string r in roles)
                 {
                     if (!string.IsNullOrEmpty(r))
                     {
                         if (Roles.IsUserInRole(u.UserName, r))
                         {
                             editDelete = true;
                             break;
                         }
                     }
                 }
                 if (editDelete)
                 {
                     cRadMenu.Enabled = true;
                     cRadMenu.Visible = true;
                 }
                 else
                 {
                     cRadMenu.Enabled = false;
                     cRadMenu.Visible = false;
                 }
           /*  }
             else
             {
                 RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
                
             }*/
            rtn = e.Node;
            RadGrid1.Rebind();
            //LoadGridData(e.Node);
            
        }  
 
        protected virtual void RadGrid1_InsertCommand(object source,GridCommandEventArgs e)
        {
             //get File
               // MembershipUser u = Membership.GetUser(Page.User.Identity.Name);
               // if (!Roles.IsUserInRole(u.UserName, Globals.Role_Administrator) &&
               //!Roles.IsUserInRole(u.UserName, Globals.Role_DataEntry))
               // {
               //     cRadMenu.Enabled = false;
               //     cRadMenu.Visible = false;
               // }
                FileUpload fileUpload = (FileUpload)e.Item.FindControl("docFileUpload");
                TextBox description = (TextBox)e.Item.FindControl("txtDescription");
                rtn = this.RadTreeView1.SelectedNode;
                bool add = LxT.Common.Utilities.StringUtil.GetBooleanValue(rtn.Attributes["allowAdd"], false);
                if (fileUpload.HasFile && add)
                {
                   int _fileSize = fileUpload.PostedFile.ContentLength;
                    string mds = Globals.Mds.Replace(' ', '-');
                    string homeFolder = Path.Combine(mds, rtn.Attributes["folder"]);
                   //string homeFolder = rtn.Attributes["folder"];
                    string _filePath = Path.Combine(Globals.uploadDir, homeFolder);
                    Persistence.DocumentHelper uph = Persistence.TDMSHelpers.GetDocumentHelper();
                    uph.CreateDirectory(_filePath);
                    _filePath = Path.Combine(_filePath,  fileUpload.FileName);
                    fileUpload.SaveAs(_filePath);
                    _filePath = Path.Combine(homeFolder, fileUpload.FileName);
                    Domain.TDMSDocument doc = new Domain.TDMSUploadedDocument();
                    doc.createdBy = Page.User.Identity.Name;
                    doc.modifiedBy = Page.User.Identity.Name;
                    doc.Description = description.Text;
                    
                    doc.Name = fileUpload.FileName;
                    doc.FileSize = _fileSize;
                    doc.FileLocation = _filePath;
                    doc.TreeId = Int32.Parse(rtn.Attributes["ID"]);
                    uph.Insert(doc);
                RadGrid1.MasterTableView.IsItemInserted = false;
                    
                    RadGrid1.Rebind();
                }
        }
        protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
        {
            int radGridClickedRowIndex;
            
            radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);
            /*RadTreeNode node*/ this.rtn = this.RadTreeView1.SelectedNode;
            switch (e.Item.Text)
            {
                case "Delete":
                    
                
                    int docId = (int) RadGrid1.MasterTableView.DataKeyValues[radGridClickedRowIndex]["Id"];
                    if (docId > 0)
                    {
                        if(LxT.Common.Utilities.StringUtil.GetIntValue(this.hfDocId.Value, -1) 
                            == Domain.TDMSDocument.globalDocument)
                            Persistence.TDMSHelpers.GetDocumentHelper().Delete(docId);
                        else
                            Persistence.TDMSHelpers.GetUploadedDocumentHelper().Delete(docId);
                    }
                    //LoadGridData(node);
                    RadGrid1.Rebind();
                    break;
                case "Edit":  
                    RadGrid1.Items[radGridClickedRowIndex].Edit = true;  
                    RadGrid1.Rebind();  
                    //LoadGridData(node);  
                    break;  
                
               
            }  
        }  
      
 
    }  
} 






Alex
Top achievements
Rank 1
 answered on 30 Dec 2009
4 answers
197 views

I have a radgrid with editformsetting using 2 ascx files. each has its condition to calculate sum of two textboxes when leaving the textboxes. but I keep getting error like the page is not recognizing the javascript.

                //Calculate the original pages * the copies and input the result to copy quantity  
                var ActualIndex;  
                var index;  
                var txtRadOriginalPages = null;  
                var txtRadCopies = null;  
                var txtRadCopyQty1 = null;  
 
                function updateTotals(sender, args) {  
                    var v1 = txtOriginalPages.get_value();  
                    var v2 = txtCopies.get_value();  
                    var finalValue = parseFloat(v1) * parseFloat(v2);  
                    txtRadCopyQty1.set_value(parseFloat(finalValue));  
                }  
                function setIndex(sender, args) {  
                    index = args.get_itemIndexHierarchical();  
                }  
                function setActualIndex() {  
                    ActualIndex = index;  
                }  
                function Load1(sender, args) {  
                    txtOriginalPages = sender;  
                }  
                function Load2(sender, args) {  
                    txtCopies = sender;  
                }  
                function Load3(sender, args) {  
                    txtRadCopyQty1 = sender;  
                } 
                        <tr> 
                            <td align="left">  
                                <asp:Label ID="lblOriginalPages" runat="server" Text="Original Pages:"></asp:Label> 
                            </td> 
                            <td align="left">  
                                <telerik:RadNumericTextBox ID="txtRadOriginalPages" runat="server"   
                                    DbValue='<%# Eval("Orig_Pages" ) %>' Font-Size="11px" Skin="Office2007"   
                                    NumberFormat-DecimalDigits="0" Type="Number" Width="100px" > 
                                    <ClientEvents OnValueChanged="updateTotals" OnFocus="setActualIndex" OnLoad="Load1" /> 
                                    <NumberFormat DecimalDigits="0" /> 
                                </telerik:RadNumericTextBox> 
                            </td> 
                            <td align="left">  
                                <asp:Label ID="lblCopies" runat="server" Text="Copies:"></asp:Label> 
                            </td> 
                            <td align="left">  
                                <telerik:RadNumericTextBox ID="txtRadCopies" runat="server"   
                                    DbValue='<%# Eval("Quantity" ) %>' Font-Size="11px" Skin="Office2007"   
                                    NumberFormat-DecimalDigits="0" Type="Number" Width="100px" > 
                                    <ClientEvents OnValueChanged="updateTotals" OnFocus="setActualIndex" OnLoad="Load2" /> 
                                    <NumberFormat DecimalDigits="0" /> 
                                </telerik:RadNumericTextBox> 
                            </td> 
                         </tr> 
                       <tr> 
                            <td align="left">  
                                <asp:Label ID="lblCopyQty1" runat="server" Text="Copy Quantity 1:"></asp:Label> 
                            </td> 
                            <td align="left">  
                                <telerik:RadNumericTextBox ID="txtRadCopyQty1" runat="server"   
                                    DbValue='<%# Eval("Total") %>' Font-Size="11px" Skin="Office2007" Width="100px"   
                                    NumberFormat-DecimalDigits="0" Type="Number">  
                                    <ClientEvents OnLoad="Load3" /> 
                                    <NumberFormat DecimalDigits="0"></NumberFormat> 
                                </telerik:RadNumericTextBox> 
                            </td> 
                            <td align="left">  
                                <asp:Label ID="lblInkType1" runat="server" Text="Ink Type 1:"></asp:Label> 
                            </td> 
                        </tr> 
anybody can help me? Please...
Thank you.
Dimo
Telerik team
 answered on 30 Dec 2009
3 answers
133 views
Hello,
i'm currently using sitefinity community version which use the old version of telerik controls. I want to create a user control(containing for example the latest combobox and the latest radgrid version) and place it inside a page of sitefinity.
Is that possible? and if yes, how to do that?

thank you
Shinu
Top achievements
Rank 2
 answered on 30 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?