Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
90 views
Dear Team,

I have an assignment to check the rad grid cell and if the cell has expected value then assign a context menu to the cell. Can anyone help me with the following:

1) attach the context menu on required cells only
2) Create separate context menu object for every cell which qualify the cell.

C#:
RadContextMenu oRadContextMenu = (RadContextMenu)RadContextMenu;
                    ContextMenuControlTarget oMenuTarget = new ContextMenuControlTarget();
 
GridTableCell gtcPreviousCell = (GridTableCell)e.Item.Cells[(e.Item.Cells.GetCellIndex(radCell)) - 1];
                            if (sColumnName == gtcPreviousCell.Column.UniqueName.ToString())
                            {
                                gtcPreviousCell.ID = sCellValue;
                                oMenuTarget.ControlID = gtcPreviousCell.ID;
                                oRadContextMenu.Targets.Add(oMenuTarget);
                            }

Thanks and Regards,
- Yogesh
Eyup
Telerik team
 answered on 19 Jul 2012
1 answer
107 views
Hi there,

 We are using the RadEditor version 2008.1.515.20 in our application. When the site is opening in the IE the Editor is loading with
"Internet Explorer cannot display the webpage " and we are not able to enter any thing.
 Please find attached screenshot.


The Aspx Code is :
<telerik:RadEditor runat="server" ID="txt_message_body" SkinID="BasicSetOfTools"   skin="Default2006" EditModes="All" Height="400px"  StripFormattingOptions="None" ToolbarMode="Default" Width="680px" >  
             
       <Tools>
     <telerik:EditorToolGroup Tag="FileManagers">
     <telerik:EditorTool Name="Undo" />
     <telerik:EditorTool Name="Redo" />
     <telerik:EditorTool Name="Bold" />
     <telerik:EditorTool Name="Italic" />
     <telerik:EditorTool Name="Underline" />
     <telerik:EditorTool Name="InsertOrderedList" />
     <telerik:EditorTool Name="InsertUnorderedList" />
     <telerik:EditorTool Name="Outdent" />
     <telerik:EditorTool Name="Indent" />
     <telerik:EditorTool Name="LinkManager" />
     <telerik:EditorTool Name="UnLink" />
     <telerik:EditorTool Name="InsertSymbol" />
     <telerik:EditorSeparator />
     <telerik:EditorTool Name="Cut" />
     <telerik:EditorTool Name="Copy" />
     <telerik:EditorTool Name="Paste" />
     <telerik:EditorSeparator />
     <telerik:EditorTool Name="FontName" />
     <telerik:EditorTool Name="RealFontSize" />        
     <telerik:EditorTool Name="ForeColor" />
     <telerik:EditorSeparator />
     <telerik:EditorTool Name="AjaxSpellCheck" />
     </telerik:EditorToolGroup>     
     </Tools>          

               </telerik:RadEditor>

Web.Config:

<httpHandlers>
      <remove path="*.asmx" verb="*"/>
      <add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      <add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      <add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

validate="false"/>
    
    <add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler, Telerik.Web.UI"/>
    <add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler"    validate="false" />
    <add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, Version=2008.2.1001.20, PublicKeyToken=121fae78165ba3d4"
        validate="false" />
    <add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Version=2008.2.1001.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"

validate="false"/>
  <add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Version=2008.2.1001.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
 
  </httpHandlers>
   
 <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI"/>



    </httpModules>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <remove name="ScriptModule"/>
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" preCondition="managedHandler"/>
     
    </modules>

    <handlers>
      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,

PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0,

Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0,

Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      
<add name="Telerik.RadUploadProgressHandler.ashx_*" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI"

preCondition="integratedMode,runtimeVersionv2.0"/>


 <add name="Telerik_Web_UI_DialogHandler_aspx" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" />  

    </handlers>
  </system.webServer>


Thanks,
Aparna
Rumen
Telerik team
 answered on 19 Jul 2012
3 answers
179 views
Hi,

I have a RadGrid in UserControl and I am trying to perform basic Crud operation using Inline edit per this demo.http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/entityframeworkcrud/defaultcs.aspx . This functionality works in another page where we dont use usercontrol. Please help.

User Control.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FollowUp.ascx.cs"
    Inherits="MedAssets.AMS.Web.Controls.FollowUp" %>
  
  
      
<style type="text/css">
       .RemoveEdit
       {
            display:none !important;
           color:lightblue !important;
       }
   </style>
  
<ContentTemplate>
    <div class="formLayoutE" id="divStatus" runat="server" style="padding-left: 15px; padding-right: 5px; padding-top: 5px">
        <asp:Panel ID="pnlMain" runat="server" Height="95%" Width="70%">    
      
       
         <telerik:RadTabStrip ID="tbStripFollowUp" runat="server" MultiPageID="RadMultiPage1"  Skin="Vista"
                SelectedIndex="0" CssClass="tabStrip" CausesValidation="False"  OnTabClick="tbStripFollowUp_TabClick" 
                EnableViewState="False">
                <Tabs>
                    <telerik:RadTab Text="Current" SelectedCssClass="horizontalTabSelected" Selected="True">
                    </telerik:RadTab>
                    <telerik:RadTab Text="History" SelectedCssClass="horizontalTabSelected"  >
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
              
              
             <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" 
                CssClass="multiPage" align="left" Width="100%"
                   EnableViewState="false" >
                
                <telerik:RadPageView ID="RadPageView1" runat="server">
                    <h3 class="formLayoutE_functionsheader">Scheduler</h3><br /> <br/>    
                      
                  <telerik:RadGrid ID="grdFollowUpAlert" runat="server" AutoGenerateColumns="false"  Skin="Windows7" Width="640px" EnableViewState="True"  
        AllowAutomaticDeletes="False" AllowAutomaticInserts="False" AllowAutomaticUpdates="False"
        OnItemCommand="grdFollowUpAlert_ItemCommand"
        OnItemDataBound="grdFollowUpAlert_ItemDataBound"
        OnNeedDataSource="grdFollowUpAlert_NeedsDataSource"
        OnInsertCommand="grdFollowUpAlert_InsertCommand"
        OnUpdateCommand="grdFollowUpAlert_UpdateCommand" 
        OnDeleteCommand="grdFollowUpAlert_DeleteCommand"
        OnCancelCommand="grdFollowUpAlert_CancelCommand"
        <ValidationSettings ValidationGroup="GroupAlphaRange" />
        <MasterTableView DataKeyNames="Id" CommandItemDisplay="Top" EditMode="EditForms">
        <CommandItemSettings AddNewRecordText="Add FollowUp" />
            <Columns>
                
                
                    <telerik:GridBoundColumn  DataField="FollowUpDateTime"  HeaderStyle-Width="100px" HeaderText="FollowUp Date" UniqueName="FollowUpDateTime" DataFormatString="{0:MM/dd/yyyy hh:mm tt}" />              
                    <telerik:GridBoundColumn DataField="Reason" HeaderStyle-Width="140px" HeaderText="Reason" UniqueName="Reason" DefaultInsertValue=" " />    
                    <telerik:GridBoundColumn  DataField="Name"  UniqueName="Name" HeaderStyle-Width="100px" HeaderText="Activity" DefaultInsertValue=" "  />
                    <telerik:GridBoundColumn DataField="CreatedBy" HeaderStyle-Width="55px" UniqueName="CreatedBy" HeaderText="Created By" /> 
                    <telerik:GridButtonColumn ConfirmText="Delete this item?" ConfirmDialogType="RadWindow" UniqueName="DeleteImageButton" HeaderStyle-Width="15px"  
                        ConfirmTitle="Confirm Delete" ButtonType="ImageButton"  CommandName="Delete" />
                          <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditImageButton" HeaderStyle-Width="15px" />
                <telerik:GridBoundColumn DataField="Id" Visible="false" />
                    <telerik:GridBoundColumn DataField="AccountId" HeaderStyle-Width="2px" HeaderText="AccountId" UniqueName="AccountId" Visible="False" />  
                    <telerik:GridBoundColumn DataField="WorkflowActivitySpecTypeId" HeaderStyle-Width="2px" HeaderText="WorkflowActivitySpecTypeId" UniqueName="WorkflowActivitySpecTypeId" Visible="False" />  
            </Columns>
            <EditFormSettings EditFormType="Template" InsertCaption="Add Followup" CaptionFormatString="Edit Followup">
                <FormTemplate
                    <table>
                        <tr>
                            <td>Assign From:</td>
                            <td><telerik:RadComboBox runat="server" ID="dropdownActivity" OnInit="OnInit_dropdownActivity" AppendDataBoundItems="True"
                            /></td>
                            <td>
                                  
                                                              
                            </td>
                        </tr>
                         
                        <tr>
                            <td>FollowUP DateTime:</td>
                            <td><telerik:RadDateTimePicker ID="followUpStartDate" runat="server" AutoPostBack="false"   
                            TimeView-RenderDirection="Vertical" Width="200px" /></td>
                            <td>
                                <asp:RequiredFieldValidator ID="valfollowUpStartDate" runat="server"
                                    ControlToValidate="followUpStartDate"
                                    ValidationGroup="valGroup"
                                    EnableClientScript="false"
                                    SetFocusOnError="true"
                                    Text="FollowUp Date is required"
                                    Display="Dynamic" />
                                 <asp:CustomValidator ID="valCustomFollowUpDateEndDateTime" runat="server"
                                    ControlToValidate="followUpStartDate"
                                    ValidationGroup="valGroup"
                                    ValidateEmptyText="false"
                                    OnServerValidate="ValidateFollowUpDateTimes"
                                    Text="FollowUp Date shouuld be greater than current date" 
                                    Display="Dynamic" />        
                            </td>
                        </tr>
                         
                        <tr>
                            <td valign="top">Reason:</td>
                            <td colspan="3">
                                <telerik:RadTextBox id="txtReason" runat="server" MaxLength="200" Columns="40" TextMode="MultiLine" Rows="4"
                                    SelectionOnFocus="SelectAll"   Text='<%# Bind("Reason") %>'/>
                            </td>
                        </tr>
                           <tr>
                            <td valign="top">Task Complete?:</td>
                            <td colspan="3">
                                <asp:CheckBox id="cbxTaskComplete" runat="server" Text="Match on Task Complete" />
                            </td>
                        </tr>
                       <tr
                            <td colspan="3">
                                <asp:Button ID="btnSave" runat="server" 
                                    Text='<%# (Container is GridEditFormInsertItem) ? "Add" : "Update" %>'
                                    CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' 
                                    ValidationGroup="valGroup" SkinID="Windows7">
                                </asp:Button>                                 
                                <asp:Button runat="server" ID="btnCancel" Text="Cancel" Width="75px" CommandName="Cancel" SkinID="Windows7" />
                            </td>
                        </tr>
                    </table>
                </FormTemplate>               
            </EditFormSettings>
            <NoRecordsTemplate>There are no Follow Up entries to display.</NoRecordsTemplate>
        </MasterTableView>
    </telerik:RadGrid>
  
                </telerik:RadPageView>
                <telerik:RadPageView ID="RadPageView2"  runat="server" CssClass="pageViewEducation">
                    <br/>
                   <h3 class="formLayoutE_functionsheader">Follow Up History</h3><br /> <br/>    
                  <telerik:RadGrid ID="grdFollowUpHistory" runat="server" CssClass="Grid" Width="90%" Height="90%"  OnNeedDataSource="grdFollowUpHistory_NeedsDataSource"
                  OnItemDataBound="grdFollowUpHistory_ItemDataBound"
                            Skin="Windows7" AutoGenerateColumns="false" GridLines="Vertical" AllowSorting="True" AllowPaging="True" >
                            <PagerStyle Mode="NextPrevAndNumeric" />
                              
                            <MasterTableView DataKeyNames="FollowupID">
                                <Columns>
                                  <telerik:GridBoundColumn  DataField="FollowUpDateTime"  HeaderStyle-Width="40px" HeaderText="FollowUp Date" UniqueName="FollowUpDateTime" DataFormatString="{0:MM/dd/yyyy hh:mm tt}" />              
                                  <telerik:GridBoundColumn DataField="Reason" HeaderStyle-Width="80px" HeaderText="Reason" UniqueName="Reason" DefaultInsertValue=" " />    
                                  <telerik:GridBoundColumn DataField="Name" HeaderStyle-Width="40px" UniqueName="Name" HeaderText="Activity" DefaultInsertValue=" "  />
                                  <telerik:GridBoundColumn DataField="CreatedBy" HeaderStyle-Width="40px" HeaderText="Created By" /> 
                                  <telerik:GridBoundColumn DataField="WorkflowActivitySpecTypeId" HeaderStyle-Width="2px" HeaderText="WorkflowActivitySpecTypeId" UniqueName="WorkflowActivitySpecTypeId" Visible="False" />
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
                          
  
                </telerik:RadPageView>
                 
            </telerik:RadMultiPage>
  
  
  
  
  
</asp:Panel>
    </div>
      
</ContentTemplate>

CodeBehind
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using MedAssets.AAA;
using MedAssets.AMS.Business.Common;
using MedAssets.AMS.Business.WorkDistribution;
using MedAssets.AMS.Common;
using MedAssets.AMS.DataAccess;
using MedAssets.AMS.Web.Admin.WorkDistribution;
using MedAssets.AMS.Workflow;
using MedAssets.Aaa.Security;
using MedAssets.Aaa.TaskQueues;
using MedAssets.Aaa.Users;
using MedAssets.Log;
using MedAssets.AMS.Workflow;
  
using StructureMap;
  
using Telerik.Web.UI;
  
namespace MedAssets.AMS.Web.Controls
{
  
    public partial class FollowUp : BaseWorkflowControl 
    {
          
  
        private const string mTimeZoneCookieName = "TZOS"; // Time zone Offset
        private IWorkFollowup iWorkFollowup = new WorkFollowup();
        private IWorkflow m_workflow;
        public IWorkflow Workflow
        {
            get
            {
                var workflow = m_workflow ?? (m_workflow = WorkflowService.GetActiveWorkflowForAccount(AccountADT.Account.Id));
                return workflow ?? (new Workflow.Workflow(new WorkflowKey(AccountADT.Account.FacilityId, Guid.NewGuid())) { AccountId = AccountADT.AccountId });
            }
            set { m_workflow = value; }
        }
  
  
       private CultureInfo enUS = new CultureInfo("en-US"); 
        private int? activitySpecTypeId;
        private DateTime followUpDate;
        private Boolean isComplete = false;
        private string reason = string.Empty;
        private Guid followUpId;
  
        protected void OnPreInit(EventArgs e)
        {
            setCookieForTimezoneOffset();   
        }
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if(!IsPostBack)
            {
                m_workflow = WorkflowService.GetActiveWorkflowForAccount(AccountADT.Account.Id);
                PopulateGrid("grdFollowUpAlert", true);
                PopulateGrid("grdFollowUpHistory", true);
               // RadScheduler1.TimeZoneOffset = new TimeSpan(getTimezoneOffset(), 0, 0);
                InitializeAppointments();
                 
            }
  
        }
        
  
        private static int GetEnumValue(Enum wfEnum )
        {
            return (int)Enum.Parse(wfEnum.GetType(), wfEnum.ToString());
        }
  
  
  
        private void InitializeAppointments()
        {
  
              
  
            //DateTime start = DateTime.UtcNow.Date;
            //start = start.AddHours(6);
            //Appointments.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, new Reminder(30).ToString(), 1));
            //Appointments.Add(new AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
  
            //start = start.AddDays(-1);
            //DateTime dayStart = RadScheduler1.UtcDayStart(start);
            //Appointments.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, string.Empty, 1));
            //Appointments.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
  
            //start = start.AddDays(2);
            //Appointments.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
        }
  
  
        public override void Populate()
        {
              
        }
  
        private void PopulateGrid(string gridName, bool needRebind)
        {
            var cbo = (RadGrid)FindControlRecursive(Page, gridName);
            if (gridName == "grdFollowUpAlert")
            {
               
                //if(IsWorkFlowOverridden(Workflow))
                //{
                //    //var tbControl = (RadTab)FindControlRecursive(Page, "Current");
                //    //tbControl.Visible = false;
                //    return;
                //}
                if (cbo != null)
                {
                    cbo.DataSource = GetFollowUpDetails().Where(a => a.IsComplete == false);
                    
                      
                }
  
            }
  
            if (gridName == "grdFollowUpHistory")
            {
                if (cbo != null)
                {
                    cbo.DataSource = GetFollowUpDetails().Where(a => a.IsComplete == true);
                    if (needRebind) { cbo.Rebind(); }
                }
            }
             
        }
  
        private IEnumerable<WorkFollowup> GetFollowUpDetails()
        {
            return ObjectFactory.GetInstance<IWorkflowFollowupManager>().GetWorkflowFollowUp(AccountId, FacilityId);
        }
  
        private void SaveFollowUp(IWorkFollowup workfollowup)
        {
            ObjectFactory.GetInstance<IWorkflowFollowupManager>().Save(workfollowup);
        }
  
        private void DeleteFollowUp(Guid followUpId)
        {
            ObjectFactory.GetInstance<IWorkflowFollowupManager>().Delete(followUpId);
        }
  
  
  
        private void setCookieForTimezoneOffset()
        {
            if (Request.Cookies[mTimeZoneCookieName] == null)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "Timezone", 
                     string.Format
                     (  @"<script language=""javascript"">document.cookie = ""{0}="" + new Date().getTimezoneOffset(); </script>",  
                              mTimeZoneCookieName)); 
                  
            }  
        }
        public int TimezoneOffset
        {
            get
            {
               return getTimezoneOffset();  
            }  
        }  
          
        private int getTimezoneOffset() 
        {  
            int returnValue = (Request.Cookies[mTimeZoneCookieName] == null) ? 0 : Convert.ToInt32(Request.Cookies[mTimeZoneCookieName].Value); 
              
          // JavaScript returns 300 if the offset is -5 offset so I convert the number  
            return (returnValue / 60) * -1;   
        }
  
  
  
  
        private IWorkDistributionManager _workDistributionManager;
  
        private IWorkDistributionManager WorkDistributionManager
        {
            get
            {
                return _workDistributionManager ??
                       (_workDistributionManager = ObjectFactory.GetInstance<IWorkDistributionManager>());
            }
        }
  
        private IUserTreeManager _userTreeManager;
  
        private IUserTreeManager UserTreeManager
        {
            get { return _userTreeManager ?? (_userTreeManager = ObjectFactory.GetInstance<IUserTreeManager>()); }
        }
  
        private ITaskQueueImpersonation iTaskQueueImpersonation = new TaskQueueImpersonation();
       
  
        protected void grdFollowUpAlert_NeedsDataSource(object sender, GridNeedDataSourceEventArgs args)
        {
  
            PopulateGrid("grdFollowUpAlert", false);
        }
  
        protected void grdFollowUpHistory_NeedsDataSource(object sender, GridNeedDataSourceEventArgs args)
        {
  
            PopulateGrid("grdFollowUpHistory", false);
        }
        protected void grdFollowUpAlert_ItemCommand(object sender, GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                //cancel default edit command and load the edited data in the external form
                case RadGrid.EditCommandName:
                    //iTaskQueueImpersonation = WorkDistributionManager.GetTaskQueueImpersonation(
                    //    (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"]);
                    e.Item.OwnerTableView.IsItemInserted = false;
                    break;
                case RadGrid.InitInsertCommandName:
                    grdFollowUpAlert.MasterTableView.ClearEditItems();
                    break;
            }
             
        }
  
        protected void grdFollowUpAlert_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                  
            }
  
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                if (e.Item.OwnerTableView.IsItemInserted)
                {
                    var insertedItem = (GridEditFormItem)e.Item;
  
                    var ctlFollowUpStartDate = (RadDateTimePicker)insertedItem.FindControl("followUpStartDate");
                    ctlFollowUpStartDate.MinDate = DateTime.Today;
  
                }
                else
                {
                   iWorkFollowup  = (IWorkFollowup)e.Item.DataItem;
  
                    GridEditFormItem edititem = (GridEditFormItem)e.Item;
  
                    var ctldropdownActivity = (RadComboBox)edititem.FindControl("dropdownActivity");
  
                    RadComboBoxItem itemAc =
                        ctldropdownActivity.FindItemByValue(iWorkFollowup.WorkflowActivitySpecTypeId.ToString());
                    itemAc.Selected = true;
  
                    var minDate = iWorkFollowup.FollowupDateTime;
  
                    var ctlFollowUpDate = (RadDateTimePicker)edititem.FindControl("followUpStartDate");
                    ctlFollowUpDate.MinDate = minDate;
                    ctlFollowUpDate.DbSelectedDate = iTaskQueueImpersonation.StartDate.ToString();
  
                    var isComplete = (CheckBox)edititem.FindControl("cbxTaskComplete");
                    isComplete.Checked = iWorkFollowup.IsComplete;
                }
            }
  
            if (e.Item is GridDataItem)
            {
                GridDataItem ditem = (GridDataItem)e.Item;
  
                TableCell accountCell = (TableCell)ditem["AccountId"];
  
                if (IsWorkFlowOverriddenByAccountId(new Guid(accountCell.Text)))
                {
                    ditem.Display = false;
                }
                else
                {
                    //GridEditCommandColumn editcol = (GridEditCommandColumn)["EditImageButton"].Controls[0];
  
                    TableCell userCell = (TableCell) ditem["CreatedBy"];
                    if (userCell.Text != HttpContext.Current.User.Identity.Name)
                    {
                        var imgBtn = (ImageButton)ditem["DeleteImageButton"].Controls[0];
  
                        ditem["EditImageButton"].CssClass = "RemoveEdit"; 
                        var lnk = ditem["EditImageButton"].Controls[0] as LinkButton;
                        ditem["EditImageButton"].Controls.Remove(lnk);
                        imgBtn.Visible = false;
                        //editcol.Display = false;
                    }
  
                }
                TableCell specTypeId = (TableCell)ditem["WorkflowActivitySpecTypeId"];
                TableCell specTypeName = (TableCell)ditem["Name"];
                var en = (WorkflowActivitySpecType)Convert.ToInt32(specTypeId.Text);
                specTypeName.Text  = en.Description();
  
                TableCell followUpDateTime = (TableCell) ditem["FollowUpDateTime"];
  
                DateTime dt = DateTime.ParseExact(followUpDateTime.Text, "g", enUS, DateTimeStyles.None);
                //DateTime dt = DateTime.ParseExact(followUpDateTime.Text, "yyyyMMddHHmm", null);
                //DateTime loadedDate = DateTime.ParseExact(loadedString, "d", null);
  
                dt = dt.AddHours(TimezoneOffset);
  
                followUpDateTime.Text = dt.ToString();
  
                //if(!string.IsNullOrEmpty(specTypeId.Text))
                //{
                //    
                //    var wf = GetWorkFlowByAccountId(new Guid(accountCell.Text));
  
                //    var fid = new Guid("A73FC5C9-B2EC-4DE7-992C-07F38797CC9E");
                //    //var specTypeList =
                //    //    GetWorkFlowSpecByFacilityId(Workflow.FacilityId).Where(a => a.SpecType == en);
  
                //    var specTypeList =
                //     GetWorkFlowSpecByFacilityId(fid).Where(a => a.SpecType == en);
                //    foreach(var list in specTypeList )
                //    {
                //        foreach(var ts in list.TaskSpecList)
                //        {
                //            ts.WorkflowActivitySpecId = en;
                //        }
                //    }
  
                //    TableCell activitySpecTypeNameCell = (TableCell)ditem["Name"];
                //    activitySpecTypeNameCell.Text  = (specTypeList.Count() > 0)? specTypeList.FirstOrDefault().Name :string.Empty;
  
                //}
  
  
            }
        }
  
        protected void grdFollowUpHistory_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem ditem = (GridDataItem) e.Item;
  
                TableCell specTypeId = (TableCell) ditem["WorkflowActivitySpecTypeId"];
                TableCell specTypeName = (TableCell) ditem["Name"];
                var en = (WorkflowActivitySpecType) Convert.ToInt32(specTypeId.Text);
                specTypeName.Text = en.Description();
  
                TableCell followUpDateTime = (TableCell) ditem["FollowUpDateTime"];
  
                DateTime dt = DateTime.ParseExact(followUpDateTime.Text, "g", enUS, DateTimeStyles.None);
                //DateTime dt = DateTime.ParseExact(followUpDateTime.Text, "yyyyMMddHHmm", null);
                //DateTime loadedDate = DateTime.ParseExact(loadedString, "d", null);
  
                dt = dt.AddHours(TimezoneOffset);
  
                followUpDateTime.Text = dt.ToString();
            }
        }
        private static string GetDescription(Enum en)
        {
            Type type = en.GetType();
  
            MemberInfo[] memInfo = type.GetMember(en.ToString());
  
            if (memInfo != null && memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
  
                if (attrs != null && attrs.Length > 0)
                {
                    return ((DescriptionAttribute)attrs[0]).Description;
                }
            }
  
            return en.ToString();
        }
        protected void grdFollowUpAlert_InsertCommand(object sender, GridCommandEventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
  
            //Get the GridEditFormInsertItem of the RadGrid 
            GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
  
            //Access the textbox from the insert form template and store the values in variables. 
             var specType = (WorkflowActivitySpecType)System.Enum.Parse(typeof(WorkflowActivitySpecType), ((RadComboBox)insertedItem.FindControl("dropdownActivity")).SelectedItem.Text);
            var x = (int) specType;
            //activitySpecTypeId = ((RadComboBox)insertedItem.FindControl("dropdownActivity")).SelectedIndex > 0 ? 
            //    : null;
            //    Convert.ToInt32(((RadComboBox)insertedItem.FindControl("dropdownActivity")).SelectedItem.Value);
  
            followUpDate = (DateTime)((RadDateTimePicker)insertedItem.FindControl("followUpStartDate")).DbSelectedDate;
  
         
            var radReason = ((RadTextBox)insertedItem.FindControl("txtReason")).Text;
            if (radReason != string.Empty)
                reason = radReason;
  
            isComplete = ((CheckBox)insertedItem.FindControl("cbxTaskComplete")).Checked;
  
            followUpId = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
  
     
            IWorkFollowup iworkfollowup = new WorkFollowup(new WorkFollowupKey(Guid.NewGuid()));
            iworkfollowup = UpdateFollowUp(iworkfollowup, false);
              
            SaveFollowUp(iworkfollowup);
  
          }
  
        protected void grdFollowUpAlert_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
  
            //Get the GridEditableItem of the RadGrid 
            GridEditableItem editedItem = e.Item as GridEditableItem;
  
            //Access the textbox from the edit form template and store the values in variables. 
            if (editedItem != null)
            {
                activitySpecTypeId =
                     Convert.ToInt32(((RadComboBox)editedItem.FindControl("dropdownActivity")).SelectedItem.Value);
  
                followUpDate = (DateTime)((RadDatePicker)editedItem.FindControl("followUpStartDate")).DbSelectedDate;
  
                
                var radReason = ((RadTextBox)editedItem.FindControl("txtReason")).Text;
                reason = radReason != string.Empty ? radReason : string.Empty;
  
                followUpId = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
  
                isComplete = ((CheckBox)editedItem.FindControl("cbxTaskComplete")).Checked;
  
                IWorkFollowup iworkfollowup = new WorkFollowup(new WorkFollowupKey(followUpId));
                iworkfollowup = UpdateFollowUp(iworkfollowup, false);
              
                SaveFollowUp(iworkfollowup);
  
            }
        }
        
  
        private IWorkFollowup UpdateFollowUp(IWorkFollowup workfollowup, bool isNew)
        {
  
            workfollowup.AccountId = AccountId;
            workfollowup.FacilityId = FacilityId;
            workfollowup.WorkflowActivitySpecTypeId = activitySpecTypeId;
            workfollowup.FacilityId = FacilityId;
            workfollowup.FollowupDateTime = followUpDate;
              
  
  
            if (isNew)
            {
                 
                if (reason != string.Empty)
                    workfollowup.Reason = reason;
                workfollowup.IsComplete = false;
                workfollowup.CreatedBy = HttpContext.Current.User.Identity.Name;
                workfollowup.CreatedOn = DateTime.Now;
                  
            }
            else
            {
  
                workfollowup.Reason = reason == string.Empty ? null : reason;
                workfollowup.IsComplete = isComplete;
                workfollowup.ModifiedBy = HttpContext.Current.User.Identity.Name;
                workfollowup.ModifiedOn = DateTime.Now;
                //workfollowup.FollowupId = followUpId;
            }
  
            return workfollowup;
        }
  
        protected void grdFollowUpAlert_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var id = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"];
  
            DeleteFollowUp(id);
              
        }
  
        protected void grdFollowUpAlert_CancelCommand(object sender, GridCommandEventArgs e)
        {
            //grdFollowUpAlert.Rebind();
        }
  
      
        protected void ValidateFollowUpDateTimes(object sender, ServerValidateEventArgs args)
        {
            var validator = (CustomValidator)sender;
            var editItem = (GridEditFormItem)validator.NamingContainer;
  
            var ctlfollowUpDate = (RadDateTimePicker)editItem.FindControl("followUpStartDate");
            var dbSelectedDate = ctlfollowUpDate.DbSelectedDate;
             
  
            var dateFollowUp = (DateTimeOffset?)((DateTime)dbSelectedDate);
  
            args.IsValid = dateFollowUp > DateTime.Now;
  
        }
  
        protected void OnInit_dropdownActivity(object sender, EventArgs e)
        {
            LoadDropdown();
        }
  
        
        private void LoadDropdown()
        {
             
           var cbo = (RadComboBox)FindControlRecursive(Page, "dropdownActivity");
             if (cbo != null)
            {
                cbo.Items.Clear();
  
                var enumList = Enum.GetValues(typeof(WorkflowActivitySpecType)).Cast<WorkflowActivitySpecType>().ToList();
                  
                cbo.DataSource = enumList;
                 //cbo.DataTextField = "Name";
                 //cbo.DataValueField = "WorkflowActivitySpecTypeId";
                cbo.DataBind();
                cbo.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem { Text = "--Select a Value--", Value = "--Select a Value--" });
                cbo.SelectedIndex = 0; 
                  
            }
        }
  
        public static Control FindControlRecursive(Control root, string id)
        {
            if (id == string.Empty)
                return null;
  
            if (root.ID == id)
                return root;
  
            foreach (Control c in root.Controls)
            {
                Control t = FindControlRecursive(c, id);
                if (t != null)
                {
                    return t;
                }
            }
            return null;
        }
  
        private bool IsWorkFlowOverridden(IWorkflow workflow)
        {
            var workflowStatus = workflow.WorkflowStatus;
            return (workflowStatus == WorkflowStatus.AutoAccountOverride ||
                    workflowStatus == WorkflowStatus.ManualAccountOverride);
        }
  
        private bool IsWorkFlowOverriddenByAccountId(Guid accountId)
        {
  
            var workflow = WorkflowService.GetActiveWorkflowForAccount(accountId) ??
                (new Workflow.Workflow(new WorkflowKey(AccountADT.Account.FacilityId, Guid.NewGuid())) { AccountId = accountId });
              
            var workflowStatus = workflow.WorkflowStatus;
            return (workflowStatus == WorkflowStatus.AutoAccountOverride ||
                    workflowStatus == WorkflowStatus.ManualAccountOverride);
        }
  
        private IWorkflow GetWorkFlowByAccountId(Guid accountId)
        {
  
            return WorkflowService.GetActiveWorkflowForAccount(accountId) ??
                (new Workflow.Workflow(new WorkflowKey(AccountADT.Account.FacilityId, Guid.NewGuid())) { AccountId = accountId });
  
            
        }
        private IEnumerable<IWorkflowActivitySpec> GetWorkFlowSpecByFacilityId(Guid facilityId)
        {
            return ObjectFactory.GetInstance<IWorkflowFollowupManager>().GetWorkflowSpecByFaclilityId(facilityId);
  
              
        }
  
        protected void tbStripFollowUp_TabClick(object sender, RadTabStripEventArgs e)
        {
           
        }
  
    }
}
Kris
Top achievements
Rank 1
 answered on 19 Jul 2012
4 answers
199 views
Hi,
i am using rad-grid with hierarchy and in that for the details table i am having the edit button and when i am clicking on edit below the row will appear and including that ":" is appearing in front of the label

below is the sample code i used and the image is also attached

please give me the solution ASAP

 
<Telerik:GridTemplateColumn UniqueName="editit">  
                                    <HeaderTemplate>  
                                        <asp:Label ID="lblParameterValue" runat="server" Text="Parameter Value"></asp:Label></HeaderTemplate>  
                                    <ItemTemplate>  
                                        <asp:Label ID="lblParameterValue" runat="server" Text='<%#Eval("ParaValue") %>'></asp:Label>  
                                    </ItemTemplate>  
                                    <EditItemTemplate>  
                                        <asp:Label ID="lblParameterDesc" runat="server" Text='<%#Eval("ParameterDesc") %>'></asp:Label>  
                                        <asp:TextBox ID="txtParameterValue" runat="server" Text='<%#Eval("ParaValue") %>' />  
                                        <asp:Label ID="lblParameterName" runat="server" Text='<%#Eval("ParameterName") %>'  
                                            Visible="false"></asp:Label>  
                                        <%--<ajaxToolkit:FilteredTextBoxExtender ID="filterAccountNumber" runat="server" TargetControlID="txtParameterValue"  
                                    FilterType="Numbers" />--%>  
                                        <asp:Label ID="lblParameterKey1" runat="server" Text='<%#Eval("ParameterKey") %>'  
                                            Visible="false"></asp:Label>  
                                        <asp:Label ID="lblMinLength" Visible="false" runat="server" Text='<%#Eval("MinLength") %>'></asp:Label>  
                                        <asp:Label ID="lblMaxLength" Visible="false" runat="server" Text='<%#Eval("MaxLength") %>'></asp:Label>  
                                        <asp:Label ID="lblAllowedSplChars" Visible="false" runat="server" Text='<%#Eval("AllowedSplChars") %>'></asp:Label>  
                                        <asp:Label ID="lblisSpaceAllowed" Visible="false" runat="server" Text='<%#Eval("isSpaceAllowed") %>'></asp:Label>  
                                        <asp:Label ID="lblRegularExp" Visible="false" runat="server" Text='<%#Eval("RegularExp") %>'></asp:Label>  
                                        <asp:Label ID="lblDataType" Visible="false" runat="server" Text='<%#Eval("DataType") %>'></asp:Label>  
                                    </EditItemTemplate> 
 
 
 
 

Thanks in advance
Vara Prasad.M
Sadi
Top achievements
Rank 1
 answered on 19 Jul 2012
2 answers
80 views
Hello

How can we access each  row value of a particular column in radgrid? Thanks in advance....

Regards
Rekha.
Rekha
Top achievements
Rank 1
 answered on 19 Jul 2012
7 answers
128 views
Hi Team,

I created a page with one RadGrid , few RadTextBox controls and one asp button.

When i click on enter key for first time then Button click event is firing....
But when i click mouse on any RadTextBox and press Enter key of the Key Board, then the filter menu [pop up] of RadGrid comes to that RadTextBox.
Why this filter menu[popup] is displaying for RadTextBoxes, Its has to display for RadGrid only

Please suggest me how to resolve that issue.
Kostadin
Telerik team
 answered on 19 Jul 2012
10 answers
766 views
Hi,

Have a custom template for my CommandItemTemplate and I am trying to hide or unhide a linkbutton when they click another one, but nothing has worked so far and I am out of ideas.  it just does not find the linkbuttons, when i click on one I want to hide it then unhide the other to return.
<CommandItemTemplate>
                                           <table width="100%">
                                               <tr>
                                                   <td align="left">
                                                       <asp:LinkButton ID="lnkAddNew" runat="server" Text="Add New Record" Font-Bold="true" Font-Underline="true" CommandName="AddNew"></asp:LinkButton>
                                                             
                                                       <asp:LinkButton ID="lnkExisting" runat="server" Text="View History" Font-Bold="true" Font-Underline="true" CommandName="ViewHist"></asp:LinkButton>
                                                       <asp:LinkButton ID="lnkCurrent" runat="server" Text="View Current" Font-Bold="true" Font-Underline="true" CommandName="ViewCurrent" Visible="false"></asp:LinkButton>
                                                   </td>
                                               </tr>
                                           </table>
                                       </CommandItemTemplate>


If (e.CommandName = "ViewHist") Then
          Dim cmdItem As GridCommandItem = DirectCast(e.Item, GridCommandItem)
          Dim hist As LinkButton = DirectCast(cmdItem.FindControl("lnkExisting"), LinkButton)
          Dim curr As LinkButton = DirectCast(cmdItem.FindControl("lnkCurrent"), LinkButton)
          hist.Visible = False
          curr.Visible = True
          HFHist.Value = 1
          myRadGrid.Rebind()
          myRadGrid.Columns(0).Visible = False
      End If


tried this as well
Dim cmdItem As GridCommandItem = DirectCast(myRadGrid.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)

Kevin
Top achievements
Rank 1
 answered on 19 Jul 2012
2 answers
95 views
Hi,

   I have recently upgraded telerik to version 2012.1.411.35, from 2009.3.1314.35. I have since encountered an issue with the Raddatepicker. When loading a page with a calendar control on it, the control initially seems to ignore the locale, showing a date format of YYYY-MM-DD-HH-MM-SS for 2-3 seconds, before adjusting itself to the proper format such as YYYY-MM-DD.

We have implemented these using C#, running windows XP and IE8. The issue goes away if I revert back to telerik 2009, but we chose to upgrade to make use of the new telerik controls. I'd appreciate any help regarding this issue.

Thanks,

Ricardo Hernandez
Ricardo
Top achievements
Rank 1
 answered on 19 Jul 2012
4 answers
104 views
HI, 

i'm trying to make AllowSubmitOnEnter work. I have a RadGrid witch is updated through a templateform. With AllowSubmitOnEnter = true, data is update only if the focus is in a RadTextBox or a RadNumericTextBox. If the focus is in a RadioButton or a CheckBox, the changes are canceled and the first row of my Grid enters in edit mode. 

Is there something to do with this? 

Thanks

Tommy
Tommy
Top achievements
Rank 1
 answered on 19 Jul 2012
2 answers
92 views
I'm having a heck of a time just finding how to do basic operations. I feel bad about posting something as simple as this, but how does one do simple things like assign a value to this control and retreive the selected value?

Does one use "RadDatePicker1.DateInput.Text", or is there a better property to get at this?

I was using this property and got "Text property cannot be set. String was not recognized as a valid DateTime." and am suspecting perhaps isn't the way.

Thanks in advance!

Edit: I found a property called "selectedDate" and that seems to work. However I'm not sure if this is the recommended practice.
Darren
Top achievements
Rank 2
 answered on 19 Jul 2012
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?