Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
495 views
<telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
       <%-- <script type="text/javascript">
            var manager;
            Sys.Application.add_load(function () {
                manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
               
                })
        </script>
    <script type="text/javascript">
        function gridCommand(sender, args) {
            alert(args.get_commandName());
            if (args.get_commandName() == "DownloadAttachment") {
                manager.set_enableAJAX(false);
 
                setTimeout(function () {
                    manager.set_enableAJAX(true);
                }, 0);
            }
        }
 
     
    </script>--%>
 
        <script type="text/javascript">
            function onRequestStart(sender, args) {
                if (args.get_eventTarget().indexOf("Button") >= 0) {
 
                    args.set_enableAjax(false);
                }
 
            }
 
 
 
        </script>
    </telerik:RadCodeBlock>
  <%--<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gridProjectManagement">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridProjectManagement"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            
        </AjaxSettings>
       
    </telerik:RadAjaxManager>--%>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
   <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="demo" DecoratedControls="All" EnableRoundedCorners="false" />
      <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel2" ClientEvents-OnRequestStart="onRequestStart" CssClass="div-container no-bg" LoadingPanelID="RadAjaxLoadingPanel1">
    
     <telerik:RadGrid ID="gridProjectManagement" GridLines="None" runat="server" AllowAutomaticDeletes="false"
            AllowAutomaticInserts="True" AllowSorting="true"
            OnItemCreated="gridProjectManagement_ItemCreated" OnPreRender="gridProjectManagement_PreRender" AllowAutomaticUpdates="True"
            AutoGenerateColumns="False" OnBatchEditCommand="gridProjectManagement_BatchEditCommand"  OnItemCommand="gridProjectManagement_ItemCommand" OnNeedDataSource="gridProjectManagement_NeedDataSource" OnItemDataBound="gridProjectManagement_ItemDataBound" >
           <ExportSettings ExportOnlyData="true" HideStructureColumns="true" OpenInNewWindow="true" IgnorePaging="true"><Excel Format="Html" /></ExportSettings>
             
          <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID"   Font-Size="Small" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false"
                HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False" >
                                  <CommandItemSettings ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowAddNewRecordButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true" />
 
                <BatchEditingSettings EditType="Cell" OpenEditingEvent="Click" />
                  
<%--                <SortExpressions>
                    <telerik:GridSortExpression FieldName="PerspModel_ID" SortOrder="Descending" />
                </SortExpressions>--%>
                <Columns>
                      
                    <telerik:GridBoundColumn DataField="ID" ForceExtractValue="Always" Display="false"  HeaderText="ID"
                        UniqueName="ID">
                    </telerik:GridBoundColumn>
                    
                     <telerik:GridBoundColumn DataField="Activity" SortExpression="Activity"  HeaderStyle-Width="150px" HeaderText="Activity"
                        UniqueName="Activity">
                    </telerik:GridBoundColumn>
                    
                     
 
                     
                     <telerik:GridNumericColumn DataField="Estimate" HeaderStyle-Width="80px"  AllowSorting="false"   DataType="System.Decimal"  DecimalDigits="1"  HeaderText="Estimate(hours)"
                        SortExpression="Estimate" UniqueName="Estimate">
                    </telerik:GridNumericColumn>
                  
                 <%--    <telerik:GridTemplateColumn ColumnEditorID="EstimateAssumptions" ItemStyle-CssClass="breakWord120" UniqueName="EstimateAssumptions" ItemStyle-Width="100px"  HeaderStyle-Width="150px"  HeaderText="Estimate Assumptions">
                        <ItemTemplate>
                        <%# Eval("EstimateAssumptions")%>
                           
                        </ItemTemplate>
                        <EditItemTemplate>
                             <telerik:RadTextBox ID="txtEditEstimateAssumptions"  Height="50px"  Wrap="true"  TextMode="MultiLine"  ToolTip='<%# Eval("EstimateAssumptions")%>' runat="server" Text='<%# Eval("EstimateAssumptions")%>'></telerik:RadTextBox>
                      
                             </EditItemTemplate>
                     </telerik:GridTemplateColumn>--%>
 
<%--                     <telerik:GridBoundColumn DataField="EstimateAssumptions" ItemStyle-CssClass="breakWord120" SortExpression="EstimateAssumptions"  HeaderStyle-Width="150px" HeaderText="Estimate Assumptions"
                        UniqueName="EstimateAssumptions">
                    </telerik:GridBoundColumn>--%>
                   
                   <telerik:GridAttachmentColumn 
                        EditFormHeaderTextFormat="Upload File:" HeaderStyle-Width="150px" HeaderText="Attachment" AttachmentDataField="Attachment" UploadControlType="RadAsyncUpload"
                        AttachmentKeyFields="ID" FileNameTextField="FileName" DataTextField="FileName"
                        UniqueName="Attachment">
                    </telerik:GridAttachmentColumn>
 
                </Columns>
 
            </MasterTableView>
            <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="300px" SaveScrollPosition="true"></Scrolling>
                                 <%-- <ClientEvents OnBatchEditOpened="OnBatchEditOpened" OnBatchEditOpening="BatchEditOpening"   />--%>
 
               
            <%--<ClientEvents OnCommand="gridCommand"></ClientEvents>--%>
        </ClientSettings>
        </telerik:RadGrid>
           </telerik:RadAjaxPanel>
 
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Web.UI.WebControls;
using System.IO;
using Telerik.Web.UI;
using RetirementAcceleratorTool.DataAccess;
using RetirementAcceleratorTool.UIClass;
 
namespace RetirementAcceleratorTool.UserControls
{
    public partial class ProjectManagementROIControl : System.Web.UI.UserControl
    {
        private EntitiesModel _dataContext;
 
        protected EntitiesModel DbContext
        {
            get
            {
                if (_dataContext == null)
                {
                    _dataContext = new EntitiesModel();
                }
                return _dataContext;
            }
        }
 
        public override void Dispose()
        {
            if (_dataContext != null)
            {
                _dataContext.Dispose();
            }
            base.Dispose();
        }
 
 
        private int? appname;
 
        public int? AppName
        {
            get
            {
                if (Session["AppName"] != null)
                {
                    return Convert.ToInt32(Session["AppName"]);
                }
                else
                    return null;
            }
        }
 
        public List<ApplicationName> ListApplicationName
        {
            get
            {
                var list = new List<ApplicationName>();
 
                using (var db = new EntitiesModel())
                {
                    list = db.ApplicationNames.Where(x => x.InScope == true && x.IsRetirementCandidate == true).ToList();
                }
 
                return list;
            }
        }
 
        public List<ActivityArchivalSupportPM> ListActivityArchivalSupportPM
        {
            get
            {
                var list = new List<ActivityArchivalSupportPM>();
 
                using (var db = new EntitiesModel())
                {
                    list = db.ActivityArchivalSupportPMs.Where(x => x.IsProjectManagement == true).ToList();
                }
 
                return list;
            }
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void gridProjectManagement_ItemCreated(object sender, GridItemEventArgs e)
        {
            //if (e.Item is GridDataItem)
            //{
            //    GridDataItem dataItem = e.Item as GridDataItem;
            //    GridAttachmentColumn ibtnAddToCart = (GridAttachmentColumn)(dataItem["Attachment"]);
            //    ImageButton ibtnAddToCart1 = (ImageButton)(dataItem["TemplateColumn1"]).FindControl("ibtnAddToCart");
            //    //ajaxify the button
            //    RadAjaxManager1.AjaxSettings.AddAjaxSetting(ibtnAddToCart1, gridProjectManagement, RadAjaxLoadingPanel1);
            //}
        }
 
        protected void gridProjectManagement_PreRender(object sender, EventArgs e)
        {
 
        }
 
        protected void gridProjectManagement_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            int s = e.Commands.Count();
            foreach (GridBatchEditingCommand command in e.Commands)
            {
 
                Hashtable newValues = command.NewValues;
                Hashtable oldValues = command.OldValues;
 
                int? id = (int?)newValues["ID"];
                //Convert.ToInt64(newValues["ID"].ToString());
                RadAsyncUpload upload = (gridProjectManagement.MasterTableView.GetBatchEditorContainer("Attachment").Controls[0] as RadAsyncUpload) as RadAsyncUpload;
                // string fileName = upload.UploadedFiles[0].FileName;
                string fileName = "";
                foreach (UploadedFile file in upload.UploadedFiles)
                {
 
                    byte[] result;
                    using (var streamReader = new MemoryStream())
                    {
                        file.InputStream.CopyTo(streamReader);
                        result = streamReader.ToArray();
                    }
                    if (Equality(result, (byte[])newValues["FileName"]))
                    {
                        fileName = file.FileName;
                    }
                }
 
                // string newFirstName = newValues["PerspectiveRating"].ToString();
                if (id.HasValue)
                {
                    var OldeItem = ListActivityArchivalSupportPM.Where(x => x.ID == Convert.ToInt32(id)).FirstOrDefault();
 
                    using (var db = new EntitiesModel())
                    {
                        var p = db.ActivityArchivalSupportPMs.Where(x => x.ID == Convert.ToInt32(id)).FirstOrDefault();
                        if (newValues["Estimate"] != null)
                        {
                            p.Estimate = Convert.ToDecimal(newValues["Estimate"].ToString());
                        }
 
                        p.FileName = fileName;
                        p.Activity = (string)newValues["Activity"];
                        p.EstimateAssumptions = (string)newValues["EstimateAssumptions"];
                        p.ApplicationID = AppName.Value;
                        if (newValues["FileName"] != null)
                        {
                            p.Attachment = (Byte[])newValues["FileName"];
                        }
                        db.SaveChanges();
                        try
                        {
                            //save chanages to Db
 
                        }
                        catch (System.Exception)
                        {
                        }
                    }
                    //do update
                }
                else
                {
                    ActivityArchivalSupportPM newItem = new ActivityArchivalSupportPM();
                    if (newValues["Estimate"] != null)
                    {
                        newItem.Estimate = Convert.ToDecimal(newValues["Estimate"].ToString());
                    }
 
 
 
                    newItem.EstimateAssumptions = (string)newValues["EstimateAssumptions"];
                    newItem.Activity = (string)newValues["Activity"];
                    newItem.IsProjectManagement = true;
                    newItem.IsArchivalSupport = false;
                    newItem.ApplicationID = AppName.Value;
                    newItem.FileName = fileName;
                    if (newValues["FileName"] != null)
                    {
                        newItem.Attachment = (Byte[])newValues["FileName"];
                    }
                    DbContext.Add(newItem);
 
                    try
                    {
                        //save chanages to Db
                        DbContext.SaveChanges();
                        //command.Item.Edit = false;
                    }
                    catch (System.Exception)
                    {
                    }
 
                }
            }
        }
 
        protected void gridProjectManagement_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.DownloadAttachmentCommandName)
            {
                RadAjaxManager Manager = new RadAjaxManager();
                Manager.EnableAJAX = false;
                GridDownloadAttachmentCommandEventArgs args = e as GridDownloadAttachmentCommandEventArgs;
                string fileName = args.FileName;
                int attachmentId = (int)args.AttachmentKeyValues["ID"];
 
                var query = DbContext.ActivityArchivalSupportPMs.Where(x => x.ID == attachmentId).FirstOrDefault();
                byte[] binaryData = (byte[])query.Attachment;
                Response.ClearContent();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
                Response.AddHeader(
 
           "Content-Length", fileName.Length.ToString());
                Response.BinaryWrite(binaryData);
                //  Response.TransmitFile(fileName);
                //Response.OutputStream.Write(binaryData, 0, binaryData.Length);
                //Response.Flush();
                //Response.Close();
                Response.End();
            }
 
 
        }
 
        protected void gridProjectManagement_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            if (AppName.HasValue)
            {
                var list = ListActivityArchivalSupportPM.Where(x => x.ApplicationID == AppName).ToList();
                if (list.Count > 0)
                {
 
                    gridProjectManagement.DataSource = list;
 
                }
                else
                {
 
                    gridProjectManagement.DataSource = string.Empty;
                }
 
 
            }
        }
 
        protected void gridProjectManagement_ItemDataBound(object sender, GridItemEventArgs e)
        {
            //if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
            //{
            //    GridEditableItem editItem = (GridEditableItem)e.Item;
            //    RadTextBox txtbx = (RadTextBox)editItem["EstimateAssumptions"].Controls[0];
            //    //txtbx.MaxLength = 500;
            //    //txtbx.Width = 800;
            //    txtbx.Height = 50;
            //    txtbx.TextMode = InputMode.MultiLine;
            //}
        }
 
        public void BindGrid()
        {
            if (AppName.HasValue)
            {
                var list = ListActivityArchivalSupportPM.Where(x => x.ApplicationID == AppName).ToList();
                if (list.Count > 0)
                {
 
                    gridProjectManagement.DataSource = list;
 
                }
                else
                {
 
                    gridProjectManagement.DataSource = string.Empty;
                }
 
            }
            else
            {
                gridProjectManagement.DataSource = string.Empty;
            }
 
            gridProjectManagement.DataBind();
 
        }
 
        public bool Equality(byte[] a1, byte[] b1)
        {
            int i;
            if (a1.Length == b1.Length)
            {
                i = 0;
                while (i < a1.Length && (a1[i] == b1[i])) //Earlier it was a1[i]!=b1[i]
                {
                    i++;
                }
                if (i == a1.Length)
                {
                    return true;
                }
            }
 
            return false;
        }
 
        protected void gridProjectManagement_DeleteCommand(object sender, GridCommandEventArgs e)
        {
 
        }
    }
}

i have tried different approaches to resolve the issue below. but not able to fix it. kindly help me on this.

i am not able to download the file. and not able to disable ajax. the file is saved in db in byte format

message - Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '���JFIF'.

http://screencast.com/t/CQePwsXg7cmm

please find video for further detail.​

Pavlina
Telerik team
 answered on 03 Aug 2015
3 answers
91 views

Hi,

I have a fully programmatically implemented Radgrid, with filters enabled. When you implement a Filter Template Class (to make a custom filter), you have to implement the function InstantiateIn, which has the container as a parameter. In this function you add the components of your Filter Template to this container, but I want to add controls to the container from outside this function. ​Is it possible to find this container form the Page_Load function? I've serached everything, and I have seen that you can get it at ItemCreated or ItemDataBound, I don't exactly remember. But this is not what I want, I want to get it from Page_Load. How can I do that?

 Thanks

Pau
Top achievements
Rank 1
 answered on 03 Aug 2015
2 answers
117 views

hiii,

I have created an application For grouping. i am accessing data from 4 tables in one datatable by performing union

and seperating them by adding one extra column of tablenames.

and i want to display that 4 tables in 4 groups.

It is showing it clearly when each table have only one row.

but when i insert new row in any of 4 table then 2 groups are created for that table.

 Please help me to solve this problem.

 

i have attached data that im fetching from db and image of result

 

please reply me

Bozhidar
Telerik team
 answered on 03 Aug 2015
4 answers
153 views
Is there a PDF417 barcode included in kendo ? 
And if it is where is an example how to use it. 

Thank you
Vasil
Telerik team
 answered on 03 Aug 2015
3 answers
559 views

Going through the radgrid documentation there is a limitation that we cannot use the BatchEdit or inplace Mode with virtualization.

What is the alternate or workaround to that?

My client do not want to use paging but want to provide the editing feature on the GRID which has thousands of records. Additionally performance has to be handled as number of records in the GRID can be of order of 000's so definitely need to use virtualization or paging.

Any suggestion on to get around this and achieve this functionality.

Eyup
Telerik team
 answered on 03 Aug 2015
3 answers
72 views

Dear Team,

I'm displaying hierarchical data using Treeview. We need to change the datasource of treeview dynamically based on user input. I'm using the below code do achieve the functionality:

In ASPX:

function LoadTreeView(projectid) {
                        var ajaxManager = $find("<%= RadAjaxManagerforGrid.ClientID %>");
                        ajaxManager.ajaxRequest("treeview_databind," + projectid);
                     }

 

In Code behind:

protected void RadAjaxManagerforGrid_AjaxRequest(object sender, AjaxRequestEventArgs e)
       {
           string[] arguments = e.Argument.Split(',');
           if (arguments[0] == "search")
           {
               string _search = arguments[1];
               int result = BindProjectData(false, _search);
               if (result == 0)
               {
                   Label lblEmptyMessage = RadListView1.Controls[0].FindControl("lblmessage") as Label;
                   lblEmptyMessage.Text = "No records to display.";
               }
           }
           else if(arguments[0] == "treeview_databind")
           {
               int? folderId = Convert.ToInt32(arguments[1]);
               BindFolderTreeViewData(folderId);
               hdnSelectedFolderId.Value = arguments[1];
               ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alertScript", "$('#video-move').modal('show');", true);
           }
       }

 

BindFolderTreeViewData() Method:

 

protected void BindFolderTreeViewData(int? folderId)
       {
           if(folderId!=null)
           {
           RadTreeFolders.Nodes.Clear();
           List<Folder> lst = DomainDAL.GetFolderHierarchy(folderId);
           RadTreeFolders.DataSource = lst;
           RadTreeFolders.DataFieldID = "FolderID";
           RadTreeFolders.DataFieldParentID = "ParentFolderID";
           RadTreeFolders.DataValueField = "FolderID";
           RadTreeFolders.DataTextField = "FolderName";
           RadTreeFolders.DataBind();
      }

 

Treeview is not getting refreshed/not displaying any data. Can you please help

 

Thanks,

Phani

Eyup
Telerik team
 answered on 03 Aug 2015
1 answer
47 views

Hi 

the issue We are getting undefined alert while adding <form> tag in MOSSRadEditor  htmlmode 
user like to copy content from a lot of places but sometime they tends to copy some action tag like < form> into the editForm
after they save it, will hit a pop up error on  undefined. 

 

same issue u can get here 

http://sharepoint.telerik.com/aspnet-ajax/web-parts/Pages/Content-Editor-Web-Part-using-RadEditor.aspx

 â€‹(U go to html view
Add in <form>
N switch back to Design view
U will get undefine)

please let me know how to solve this issue..

Stanimir
Telerik team
 answered on 03 Aug 2015
1 answer
117 views
Hi,

I am using the below Java script code for copy the excell data(ClipBoard) and paste it into rad grid. It's working fine. But if I use RadcomboBox in EditItemTemplate then i can't able to read the values in Mozilla and safari. In I.E I can done.
Actual After Postback RadCombo Values are Disappearing in FireFox and Safari.

function pasteFromExcel() {
            if (!lastFocused) return;
            var browser = navigator.appName;
            if (browser == "Microsoft Internet Explorer") {
                var clipData = window.clipboardData.getData('Text');
                var crlf = String.fromCharCode(13) + String.fromCharCode(10);
                var table = clipData.split(crlf);
                for (var tRow = 0; tRow < table.length - 1; tRow++)
                    table[tRow] = table[tRow].split(String.fromCharCode(9));
                Array.remove(table, table[table.length - 1]);
                fillTable(table);
            }
            else {

                var clipDiv = document.getElementById("Div1");
                clipDiv.style.display = "block";
                var clipBoardText1 = document.getElementById("clipboardtext1");
                clipBoardText1.style.visibility = "visible";
                if (clipBoardText1.value != "") {
                    var clipData = clipBoardText1.value;
                    var table = clipData.split("\n");
                    for (var tRow = 0; tRow < table.length - 1; tRow++)
                        table[tRow] = table[tRow].split(String.fromCharCode(9));
                    Array.remove(table, table[table.length - 1]);
                    fillTable(table);
                    clipBoardText1.value = "";
                    clipDiv.style.display = "none";
                }
            }
        }


Thanks & Regards,

Thippa Reddy
Priyank
Top achievements
Rank 1
 answered on 01 Aug 2015
1 answer
80 views

Is it possible to customize the range that is displayed on my Yaxis?  If the recordset populating the chart has numbers from 75,000,000 - 85,000,000, I don't want to start at 0 but say have my range be 65,000,000 - 95,000,000.  But the range can change based upon the data being returned.  It would be nice to have my range be 10% of the minimum value and maximum value.  Something else is that my values returned may also be a percentage. 

 Also on my Xaxis I will be displaying dates.  How do I only show the labels where the month is a quarter end (3, 6, 9, 12)?

 Thanks

Kurt Kluth
Top achievements
Rank 1
 answered on 31 Jul 2015
6 answers
2.0K+ views
I recently upgraded one of our projects to a more recent version but it had issues, so I downgraded it to a previous version (2011Q1).

One of my programmers here did not have Q1 on his computer so I told him to install and when he tries he receives a message saying he has a more recent version installed and the install stops.

Is there a way to install a previous version of the controls?

I know different version can live on the same machine, my currently computer has the last 4 versions (plus a few versions of Radcontrols for ASP.Net). But I've upgraded all versions in the right order, not installed a previous version in the middle.

Thanks
John
Top achievements
Rank 1
 answered on 31 Jul 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?