Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
335 views
Hi,
I am trying to enable//disable RadNumericextBox using javascript.
I am using the following as I saw in the documentation but i get the error: ntbRetention.enable is not a function

function UseBackupChanged(useBackup,ntbRetentionId) { 
 
 
    var ntbRetention = document.getElementById(ntbRetentionId);    
        
    if (useBackup == true) {       
        ntbRetention.enable(); 
    } 
    else { 
        ntbRetention.disable(); 
    } 
} 

Can anyone please help what am I doing wrong??

Thanks!
Ruth
Pavlina
Telerik team
 answered on 06 Oct 2009
3 answers
114 views
I have a popup edit form and in my template I have a table with a width of 100% but when I run my project and open the edit form it's not 100%.  The behavior makes me think the white space tot he right is where a scrollbar would be. But there is no scrollbar.

How can I get rid of this extra white space within my template. In the designer it shows the table as 100% of the template. 
Pavlina
Telerik team
 answered on 06 Oct 2009
1 answer
768 views
Hi Telerik !

Iam using the RAD FILE EXPLROER in one of my project. I have uploade the files with the following extensions :-

.docx,
.doc, .xslx
.pdf & many images file such as .jpeg,.jpg,.gif,.bmp.

I have implemented the following javascript function in order to open the file in the context menu:-

 function OnClientFileOpen(oExplorer, args) {  
            debugger;  
            var item = args.get_item();  
            var fileExtension = item.get_extension();  
 
            //var fileDownloadMode = document.getElementById("chkbxDownoaldFile").checked;  
            if ((fileExtension == "jpg" || fileExtension == "gif") && fileExtension == "xlsx" || fileExtension == "docx") {// Download the file   
                // File is a image document, do not open a new window  
                args.set_cancel(true);  
 
                // Tell browser to open file directly  
                var requestImage = "FileSystemHandler.ashx?path=" + item.get_url();  
                document.location = requestImage;  
            //}  
        }  
 
 
 
 I have the following code implemented on to my FileSystemHandler.ashx file :-
<%@ WebHandler Language="C#" Class="Handler" %> 
using System;  
using System.Data;  
using System.Configuration;  
using System.Web;  
using System.IO;  
using System.Collections.Generic;  
using System.Xml;  
 
public class Handler : IHttpHandler  
{  
    #region IHttpHandler Members  
 
    string pathToConfigFile = "~/App_Data/MappingFile.mapping";  
    private HttpContext _context;  
    private HttpContext Context  
    {  
        get  
        {  
            return _context;  
        }  
        set  
        {  
            _context = value;  
        }  
    }  
 
 
    public void ProcessRequest(HttpContext context)  
    {  
        Context = context;  
 
        if (context.Request.QueryString["path"] == null)  
        {  
            return;  
        }  
 
        string virtualPathToFile = Context.Server.HtmlDecode(context.Request.QueryString["path"]);  
        string physicalPathToFile = "";  
        Dictionary<string, string> mappedPathsInConfigFile = this.GetMappingsFromConfigFile();  
        foreach (KeyValuePair<string, string> mappedPath in mappedPathsInConfigFile)  
        {  
            if (virtualPathToFile.ToLower().StartsWith(mappedPath.Key.ToLower()))  
            {  
                // Build the physical path to the file ;  
                physicalPathToFile = virtualPathToFile.Replace(mappedPath.Key, mappedPath.Value).Replace("/", "\\");  
 
                break;// Brak the foreach loop ;  
            }  
        }  
 
        if (physicalPathToFile == null)  
        {  
            return;  
        }  
 
        System.IO.StreamReader streamReader = new System.IO.StreamReader(physicalPathToFile);  
        System.IO.BinaryReader br = new System.IO.BinaryReader(streamReader.BaseStream);  
 
        byte[] bytes = new byte[streamReader.BaseStream.Length];  
 
        br.Read(bytes, 0, (int)streamReader.BaseStream.Length);  
 
        if (bytes == null)  
        {  
            return;  
        }  
 
        streamReader.Close();  
        br.Close();  
        string extension = System.IO.Path.GetExtension(physicalPathToFile);  
        string fileName = System.IO.Path.GetFileName(physicalPathToFile);  
 
        if (extension == ".jpg")  
        { // Handle *.jpg and  
            WriteFile(bytes, fileName, "image/jpeg jpeg jpg jpe", context.Response);  
        }  
        else if (extension == ".gif")  
        {// Handle *.gif  
            WriteFile(bytes, fileName, "image/gif gif", context.Response);  
        }  
    }  
    private void WriteFile(byte[] content, string fileName, string contentType, HttpResponse response)  
    {  
        response.Buffer = true;  
        response.Clear();  
        response.ContentType = contentType;  
 
        response.AddHeader("content-disposition", "attachment; filename=" + fileName);  
 
        response.BinaryWrite(content);  
        response.Flush();  
        response.End();  
    }  
      
      
    public bool IsReusable  
    {  
        get  
        {  
            return false;  
        }  
    }  
 
 
    /// <summary> 
    /// Retrieves the mapping for view paths ;  
    /// </summary> 
    /// <param name="virtualPathToConfigFile">The fvirtual path to the config file </param> 
    /// <returns>The mappings </returns> 
    private Dictionary<string, string> GetMappingsFromConfigFile()  
    {  
        XmlDocument configFile = new XmlDocument();  
        string physicalPathToConfigFile = Context.Server.MapPath(this.pathToConfigFile);  
        configFile.Load(physicalPathToConfigFile);// Load the configuration file ;  
 
        XmlElement rootElement = configFile.DocumentElement;  
        XmlNode mappingsSection = rootElement.GetElementsByTagName("Mappings")[0]; // get all mappings ;  
 
        Dictionary<string, string> mappingsFromConfigFile = new Dictionary<string, string>();  
        foreach (XmlNode mapping in mappingsSection.ChildNodes)  
        {  
            XmlNode virtualPathAsNode = mapping.SelectSingleNode("child::VirtualPath");  
            XmlNode physicalPathAsNode = mapping.SelectSingleNode("child::PhysicalPath");  
            mappingsFromConfigFile.Add(this.AddSlashAtEndOfVirtualPath(virtualPathAsNode.InnerText), this.AddSlashAtEndOfPhysicalPath(physicalPathAsNode.InnerText));  
        }  
 
        return mappingsFromConfigFile;  
    }  
 
    /// <summary> 
    /// Gets the path to the generic handler. It should be a virtual path  
    /// </summary> 
    /// <returns>Path to the generic handler</returns> 
    private string GetPathTogenericHandler()  
    {  
        XmlDocument configFile = new XmlDocument();  
        string physicalPathToConfigFile = Context.Server.MapPath(this.pathToConfigFile);  
        configFile.Load(physicalPathToConfigFile);// Load the configuration file ;  
 
        XmlElement rootElement = configFile.DocumentElement;  
        XmlNode handlerPathSection = rootElement.GetElementsByTagName("genericHandlerPath")[0]; // get all mappings ;  
 
        return handlerPathSection.InnerText;  
    }  
 
    //////////////////////////////////////////////////////////////////////////////////////////////////////////  
    //  The custom methods   
    //////////////////////////////////////////////////////////////////////////////////////////////////////////  
    /// <summary> 
    /// Adds a backslash at the end of a physical path if the slash does not exists ;  
    /// </summary> 
    /// <param name="physicalPath">Physical path</param> 
    /// <returns></returns>  
    private string AddSlashAtEndOfPhysicalPath(string physicalPath)  
    {  
 
        if (!physicalPath.EndsWith("\\"))  
        {  
            return physicalPath + "\\";  
        }  
        else  
        {  
            return physicalPath;  
        }  
    }  
 
    /// <summary> 
    /// Adds a backslash at the end of a virtual path if the slash does not exists ;  
    /// </summary> 
    /// <param name="virtualPath">Virtual path</param> 
    /// <returns></returns>  
    private string AddSlashAtEndOfVirtualPath(string virtualPath)  
    {  
 
        if (!virtualPath.EndsWith("/"))  
        {  
            return virtualPath + "/";  
        }  
        else  
        {  
            return virtualPath;  
        }  
    }  
    #endregion  
    } 
Also, I have used the following in the ASPX Page :-

<telerik:RadFileExplorer runat="server" ID="DocumentsRadFileExplorer" Width="734px" 
                    Height="400px" VisibleControls="All" EnableCreateNewFolder="true" EnableCopy="true" EnableOpenFile="true" 
                    OnClientMove="OnClientMove" OnClientFileOpen="OnClientFileOpen" OnClientDelete="OnClientDelete" OnClientLoad="attachHandlers" > 
             <Configuration SearchPatterns="*.*"></Configuration> 
                </telerik:RadFileExplorer> 
Now whenever I try to open the file with .doc or .docx or .pdf extension file does not get open in MS word format. PDF file opens ups but with its name changed as FileHandler.pdf.

Apart form that, I have used all the sample that has been sent by all your member earlier but all in vain.

Below is the list of javascript function that I have used so far :-
       function OnClientFileOpen(sender, args)      
{  
   var item = args.get_item();  
   if (item && !item.isDirectory() && (item.get_extension() == "docx") && (item.get_extension() == "doc"))  
   {  
       //file is a MS Office document, do not open a new window.    
       args.set_cancel(true);  
         
       //tell browser to open file directly  
       //window.location.href = item.get_url();  
       var requestImage = "Handler.ashx?path=" + item.get_url();  
       window.location.href = requestImage;  
         
   }  
}   
      
        function OnExplorerFileOpen(oExplorer, args) {  
            var item = args.get_item();  
            var fileExt = item.get_extension();  
            if (fileExt == "jpg") {  
                var oWindowManager = oExplorer.get_windowManager();  
                args.set_cancel(true);  
                var newURL = "Popup.aspx?path=" + item.get_path();  
                var oWindow = oWindowManager.open(newURL, "RadWindow1");  
                oWindow.setSize(500, 500);  
            }  
            else if (fileExt == "pdf") {  
                setTimeout(  
                        function() {  
                            var oWindow = oExplorer.get_windowManager().getActiveWindow();  
                            oWindow.setSize(500, 600);  
                        }, 500);  
            }  
        }  
 
 
        function OnClientFileOpen(sender, args) {  
            LogEvent("Item open: " + args.get_item().get_name());  
        }  
 
        function LogEvent(text) {  
            var d = new Date();  
            var ddateStr = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();  
            var eventConsole = $get("eventConsole");  
            eventConsole.innerHTML += "[" + dateStr + "] " + text + "<br/>";  
        }  
 
        function OnClientFileOpen(oExplorer, args) {  
            debugger;  
            var item = args.get_item();  
            var fileExtension = item.get_extension();  
 
            //var fileDownloadMode = document.getElementById("chkbxDownoaldFile").checked;  
            if ((fileExtension == "jpg" || fileExtension == "gif") && fileExtension == "xlsx" || fileExtension == "docx") {// Download the file   
                // File is a image document, do not open a new window  
                args.set_cancel(true);  
 
                // Tell browser to open file directly  
                var requestImage = "FileSystemHandler.ashx?path=" + item.get_url();  
                document.location = requestImage;  
            //}  
        }  
 


Please help me to solve my problem .

Thanks & Regards

Ajay Jamwal 
Fiko
Telerik team
 answered on 06 Oct 2009
1 answer
150 views

I add a RadRotator to my page control collection dynamically. I create a new itemTemplate and assign a datasource.


DataTable
dataTable = GetDataSetFromXml().Tables[0];

 

RadRotator1.ItemTemplate = new RotatorItemTemplate();

RadRotator1.DataSource = dataTable;

RadRotator1.DataBind();

RadRotator1.ScrollDirection = RotatorScrollDirection.Up.  

....

private class RotatorItemTemplate : ITemplate

 

{

Label literal;

public void InstantiateIn(Control container)

{

literal = new Label();

literal.DataBinding += literal_DataBinding;

container.Controls.Add(literal);

}

static void literal_DataBinding(object sender, EventArgs e)

{

Label labelControl = (Label)sender;

RadRotatorItem rotatorItem = (RadRotatorItem)labelControl.NamingContainer;

string html = (string)((DataRowView)rotatorItem.DataItem)["Html"];

labelControl.Text = "<table cellpadding=\"0\" cellspacing=\"1\"><tr><td>" + html + "</td></tr></table>";

}

}

When i run my project the rotator shows all the rotatoritems side by side; the rotator doen't scroll.
The RadScriptManagers is included in the page.

Can anyone help me solve this problem?

Fiko
Telerik team
 answered on 06 Oct 2009
1 answer
116 views
Is it possible to disable automatic expanding of a tree node?

When I select a folder that has children, the explorer automatically opens that tree. I don't want that to happen. I only want the tree to expand if the user explicitly clicks the "+" plus button.

Greg
Fiko
Telerik team
 answered on 06 Oct 2009
3 answers
58 views
Hello all,
I recently upgraded to the ASP.NET AJAX release for my radgrids. However, my pagers are all messed up now.

In the old version we used the mode NextPrevAndNumeric and the pager displayed as:
Change Page: < 1 2 3 4 5 6 7  > | Displaying page 1 of 7, items 1 to 25 of 174

Now it displays as:
First Page Previous Page
1 2 3 4 5 6 7 
Next Page Last Page
174 items on 7 pages

I guess i missed something in converting to the new version. Any ideas?

Thanks!
Patrick Simon
hd
Top achievements
Rank 1
 answered on 06 Oct 2009
1 answer
102 views
Hi,

i want to give my radGrid's TemplateItem control the following textbinding from my Linq2Sql object which has a user2id propertie foreign key:

Text='<%# DataBinder.Eval(Container.DataItem,"User2.lastname").ToString() %>'

but what can i do to handle the case that the user2id foreign key is null which makes the User2 object null?

is there a chance to handle it in the asp code?

Or do i have to catch the user2id instead of the User2 object and use it in codebehind with the ItemDataBound?

thx, Mario
Tsvetoslav
Telerik team
 answered on 06 Oct 2009
5 answers
138 views
Is there any way of showing an appointment over the top of another one e.g. 5 - 10 pm (blue) shown with 6 - 8 pm (red) drawn on top so that the red one can be seen to have a higher priority than the blue one.
Peter
Telerik team
 answered on 06 Oct 2009
1 answer
59 views
Hi,

Im using treeview control in MVC through client side binding and client side method which is assigned to OnClientNodePopulating event, is not calling.

following is the asp.net code


 <telerik:RadTreeView runat="server" ID="RadTreeView1" DataTextField="SearchKeyword"
        DataValueField="id" LoadingStatusPosition="AfterNodeText" OnClientNodePopulating="nodePopulating" >
        <DataBindings>
            <telerik:RadTreeNodeBinding Depth="0" ExpandMode="WebService" />
        </DataBindings>
    </telerik:RadTreeView>


client side code:

function onSuccess(result, node) {
    debugger;
    node.hideLoadingStatus();
    //the result in JSON format is available as a "d" field
    var data = result.d;

    //Traverse the array of objects and create combobox items
    for (var i = 0; i < data.length; i++) {
        var dataItem = data[i];

        var childNode = new Telerik.Web.UI.RadTreeNode();
        childNode.set_text(dataItem.Text);
        childNode.set_value(dataItem.id);
        childNode.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.WebService);
        node.get_nodes().add(childNode);
    }
    node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ClientSide);
    node.expand();
}

function nodePopulating(sender, args) {
    debugger;
    var node = args.get_node();
    node.showLoadingStatus(sender.get_loadingMessage(), sender.get_loadingStatusPosition());
    //get only the child nodes of the current node
    var filter = "&$filter=parentId eq " + node.get_value();

    //Call the ADO.NET Data Service
    $telerik.$.ajax({
        type: "GET", // HTTP method
        url: '<%= ResolveUrl("TreeViewAdoNetService.svc/Links?") %>' + filter, // ADO.NET DataService URL
        contentType: "application/json; charset=utf-8", //request the result to be in JSON
        dataType: "json",
        success: function(result) { //callback method to invoke when the request is complete
            onSuccess(result, node);
        }
    });
    args.set_cancel(true);
}

Atanas Korchev
Telerik team
 answered on 06 Oct 2009
1 answer
155 views
hi All.
I have the Nested Grid Like this as showen below.
Now.Can i know how to Expand the Grid (OrdersGrid). I expanded the Parent Grid(RadGrid1) in PreRender Event .But i can't able to Expand the childgrid(OrdersGrid).

Can Any one Help me please......


<telerik:RadGrid ShowGroupPanel="True" ID="RadGrid1" 
            AllowSorting="True" AutoGenerateColumns ="false"  
            runat="server" GridLines="None" AllowPaging="True" Width="976px" Skin="Hay" > 
             <ClientSettings> 
      <Selecting AllowRowSelect="True" /> 
      <ClientEvents /> 
      </ClientSettings> 
             <MasterTableView DataKeyNames ="companyname" > 
             <NestedViewTemplate > 
             <asp:Panel ID ="Panel1" runat ="server" Height="136px" > 
                  <telerik:RadTabStrip runat="server" ID="TabStip1" Skin="Hay" MultiPageID="Multipage1" SelectedIndex="0" Width="464px"> 
   <Tabs > 
    
                                 <telerik:RadTab runat="server" Text="Unpaid Invoices" PageViewID="PageView2"> 
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Fully Paid Invoices" PageViewID="PageView3"> 
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Part-Payments" PageViewID="PageView4"> 
                                </telerik:RadTab> 
   </Tabs>    
                             
                             
     </telerik:RadTabStrip> 
     <telerik:RadMultiPage runat="server" ID="radmultipage1" SelectedIndex="0" RenderSelectedPageOnly="false"> 
         <telerik:RadPageView runat="server" ID="RadPageView1"> 
                            <telerik:RadGrid ID="OrdersGrid" runat="server" Skin="Hay" Width="800px" AutoGenerateColumns="False" GridLines="None" OnPreRender="OrdersGrid_PreRender"> 
                                <ClientSettings > 
                                <Selecting AllowRowSelect ="True" /> 
                                <ClientEvents  /> 
                                </ClientSettings> 
                                <MasterTableView DataKeyNames ="" > 
                                <NestedViewTemplate > 
                                <asp:Panel ID ="Panel2" runat ="server" > 
                                <telerik:RadTabStrip runat ="server" ID ="tabstrib1" MultiPageID ="Multipage2" SelectedIndex ="0" Width ="464px" Skin="Hay"> 
                                <Tabs > 
                                <telerik:RadTab runat ="server" Text ="Details" PageViewID ="newpageview2" Selected="True"></telerik:RadTab> 
                                <telerik:RadTab runat ="server" Text="Attachments" PageViewID ="newpageview3"></telerik:RadTab> 
                                <telerik:RadTab runat ="server" Text ="Comments" PageViewID ="newpageview3"></telerik:RadTab> 
                                </Tabs> 
                                </telerik:RadTabStrip> 
                                </asp:Panel> 
                                </NestedViewTemplate> 
                                    <Columns> 
                                        <telerik:GridBoundColumn DataField="loan_reference_number" HeaderText="Loan Reference NUmber" 
                                            UniqueName="column3"> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="invoice_number" HeaderText="Invoice Number" UniqueName="column4"> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField=" PSF_sanctionamount" HeaderText="PSF Sanction Amount" 
                                            UniqueName="column6"> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="date_of_credit" HeaderText="Due Date" UniqueName="column1"> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="actual_debit_date" HeaderText="Grace Period" 
                                            UniqueName="column"> 
                                        </telerik:GridBoundColumn> 
                                    </Columns> 
                                    <ExpandCollapseColumn Visible="True"> 
                                    </ExpandCollapseColumn> 
                                </MasterTableView> 
                             
                            </telerik:RadGrid> 
                        </telerik:RadPageView> 
                         
     </telerik:RadMultiPage> 
             </asp:Panel> 
             </NestedViewTemplate> 
                 <Columns> 
                     <telerik:GridBoundColumn DataField="companyname" HeaderText="Company name" UniqueName="column1" Visible ="False"  > 
                     </telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn DataField="currency" HeaderText="Currency" UniqueName="column3"> 
                     </telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn DataField="overdraftlimit" HeaderText="Over Draft Limit" 
                         UniqueName="column"> 
                     </telerik:GridBoundColumn> 
                         <telerik:GridBoundColumn DataField="Credit Utilized" HeaderText="Credit Utilized" 
                         UniqueName="column10"> 
                     </telerik:GridBoundColumn> 
                      <telerik:GridBoundColumn DataField="Available Credit" HeaderText="Available Credit" 
                         UniqueName="column8"> 
                     </telerik:GridBoundColumn> 
                 </Columns> 
                 <GroupByExpressions > 
                 <telerik:GridGroupByExpression > 
                 <GroupByFields > 
                 <telerik:GridGroupByField FieldName ="companyname" FieldAlias="companyname" FormatString="" HeaderText="" /> 
                 </GroupByFields> 
                 <SelectFields > 
                 <telerik:GridGroupByField FieldName ="companyname" FieldAlias="companyname" FormatString="" HeaderText="" /> 
                 </SelectFields> 
                 </telerik:GridGroupByExpression> 
                 </GroupByExpressions> 
                 <ExpandCollapseColumn Visible="True"> 
                 </ExpandCollapseColumn> 
             </MasterTableView> 
                               
             
            </telerik:RadGrid> 

Thank you.
Suresh K
Schlurk
Top achievements
Rank 2
 answered on 06 Oct 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?