Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
512 views
Hi,

I am dynamically adding menu items and submenu items to RadContextMenu. I have a Radgrid, on right click it shows contextmenu. Items in context menu are dynamically added based on row clicked.

This context menu renders fine most of the time but one in a while item width do not cover 100% and shows transparent background. How can I fix this issue?

JavaScript code to add context menu items:
............................................................................
function GetInformationFromServerAndCreateTicketBayContextMenuItems(sender, eventArgs) {
            var cmTechFilterID = $telerik.$("[id$='cmTechFilter']").attr("id"); //Gets the ID, this is external JS safe...you can use the = .ClientID asp method though
            var menu = $find(cmTechFilterID);
           // menu.trackChanges();
            menu.get_items().clear();
           // menu.commitChanges();


            var evt = eventArgs.get_domEvent();
            if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") {
                return;
            }

            //this prevents from displaying browser context menu
            var evt = eventArgs.get_domEvent();
         
           evt.cancelBubble = true;
           var index = eventArgs.get_itemIndexHierarchical();
           document.getElementById("radGridClickedRowIndexCM").value = index;
           sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);

          

           var rgTicketsGridID = $telerik.$("[id$='rgTicketsGrid']").attr("id"); //Gets the ID, this is external JS safe...you can use the = .ClientID asp method though
           var grid = $find(rgTicketsGridID);

           var dataItem1 = grid.get_masterTableView().get_dataItems()[index];
           var currentTicketID = dataItem1.getDataKeyValue("ID");
           var apptID1 = dataItem1.getDataKeyValue("ApptID");
           var Status = dataItem1.getDataKeyValue("Status");

           var baseUrl = 'WorkforceServices/RequestHandler.ashx?q=getticketbaycontextmenuitems&TicketID=' + currentTicketID + "&ApptID=" + apptID1;
           var serviceOptions = {};
           serviceOptions.url = baseUrl;
           serviceOptions.data = null;
           serviceOptions.type = 'GET';
           serviceOptions.processData = false;
           serviceOptions.contentType = "application/json";
           serviceOptions.dataType = 'json';
           serviceOptions.success = function (result) {

               menu.trackChanges();
               menu.get_items().clear();

               var ticketBayContextMenuItems = result.TicketBayContextMenus;
                       var ticketStatuses = result.TicketStatuses;
                       var bumpStatuses = result.BumpStatuses ;

                       if (ticketBayContextMenuItems.length > 0) {
                           for (var index = 0; index < ticketBayContextMenuItems.length; index++) {
                               var description = ticketBayContextMenuItems[index].Value;
                               var value = ticketBayContextMenuItems[index].Key;
                               if (description == "_BreakLine_") {
                                   var menuItem = new Telerik.Web.UI.RadMenuItem();
                                   menuItem.set_isSeparator(true);
                                   menu.get_items().add(menuItem);
                               }
                               else {
                                   var contextMenuItem = new Telerik.Web.UI.RadMenuItem();
                                   contextMenuItem.set_text(description);
                                   contextMenuItem.set_value(value);

                                  
                                   menu.get_items().add(contextMenuItem);

                                   if (apptID1 < 1) {
                                       if (description == "Show In M4")
                                           contextMenuItem.set_visible(false);
                                       else if (description == "Exclude from Appointment Optimization")
                                           contextMenuItem.set_visible(false);
                                       else if (description == "Show Route")
                                           contextMenuItem.set_visible(false);
                                       else if (description == "Directions")
                                           contextMenuItem.set_visible(false);
                                       else if (description == "Find Tech")
                                           contextMenuItem.set_visible(false);
                                   }


                                   if (value == "ChangeTicketState") {
                                       if (ticketStatuses.length == 0) {
                                           contextMenuItem.set_visible(false);
                                       }
                                       else {
                                           for (var indexRCItem = 0; indexRCItem < ticketStatuses.length; indexRCItem++) {
                                               var destinationStateID = ticketStatuses[indexRCItem].DestinationState;
                                               var transitionName = ticketStatuses[indexRCItem].TransitionName
                                               var destinationStateID = ticketStatuses[indexRCItem].DestinationState;
                                               var nextTransitionItem =  new Telerik.Web.UI.RadMenuItem();
                                               nextTransitionItem.set_text(transitionName);
                                               nextTransitionItem.set_value(destinationStateID);
                                               $(nextTransitionItem).css("width", "100%");
                                               contextMenuItem.get_items().add(nextTransitionItem);

                                           } //end of for loop  
                                       }//end of if
                                   }
                                   else if (value == "BumpStatus") {
                                       if (result.BumpStatuses.length == 0) {
                                           contextMenuItem.set_visible(false);
                                       }
                                       else {
                                           for (var indexBS = 0; indexBS < bumpStatuses.length; indexBS++) {
                                               var code = bumpStatuses[indexBS].Code;
                                               var description = bumpStatuses[indexBS].Description;
                                               var bsMenuItem = new Telerik.Web.UI.RadMenuItem();
                                               bsMenuItem.set_text(description);
                                               bsMenuItem.set_value(code);
                                               $(bsMenuItem).css("width", "100%");
                                               contextMenuItem.get_items().add(bsMenuItem);
                                           }//end of for loop
                                       }//end of else
                                   }//end of if (value == "BumpStatus")


                               }//end of else not break line
                           } //end of for loop

                       }// end of if (ticketBayContextMenuItems.length > 0)

                     
                $(contextMenuItem).css("width", "100%");
                menu.commitChanges();
                $(contextMenuItem).css("width", "100%");
               menu.show(evt);
               evt.cancelBubble = true;
               evt.returnValue = false;

               if (evt.stopPropagation) {
                       evt.stopPropagation();
                       evt.preventDefault();
               }

           };


           serviceOptions.error = function (xhr) {
                   alert('Error:' + xhr.statusText);
                  menu.trackChanges();
                  menu.get_items().clear();
                   menu.commitChanges();

                   menu.show(evt);
                   evt.cancelBubble = true;
                   evt.returnValue = false;

                   if (evt.stopPropagation) {
                       evt.stopPropagation();
                       evt.preventDefault();
                   }
           };


           var workforceServiceProxy = new WorkforceServiceProxy(serviceOptions);
           workforceServiceProxy.callService();

}






Here is my html tag for grid and contextmenu
..................................................................................

 <telerik:RadGrid ID="rgTicketsGrid" runat="server"  AllowPaging="true"
                         
                        .................................................................. >
                            <MasterTableView AllowFilteringByColumn="False" .................................>
                            </MasterTableView>
                          
                          
                            <ClientSettings AllowDragToGroup="True" AllowRowsDragDrop="True" EnableRowHoverStyle="True">
                                        <ClientEvents OnRowContextMenu="GetInformationFromServerAndCreateTicketBayContextMenuItems"   />
                            </ClientSettings >
             
                      
                  
                            ...................................................................................................................
                        </telerik:RadGrid>

                        <telerik:RadContextMenu ID="cmTechFilter" runat="server" EnableRoundedCorners="true"
                            EnableShadows="true" EnableViewState="true" OnClientItemClicked="TicketBay_ContextMenuClicked"  >   
      
                        </telerik:RadContextMenu>
Thanks,
Prava
Prava kafle
Top achievements
Rank 1
 answered on 02 Feb 2015
1 answer
336 views
So far I have been able to successfully dynamically load a radtreeview inside a radpanelbar. There are just 2 issues i'm facing now and hopefully someone could help me out. 

Issue 1.

After a post back (control added to an ajaxmanager) generated from a radpanel item selected event, my radtreeview disappears.

Issue 2.

RadTreeView node click event does not fire.

I will paste brief segments of my code below. 

ParentChildItems = function that returns a List<Child> object full of children...

foreach (Child child in ParentChildItems)
                    {
                        RadTreeView treeView = new RadTreeView();
                        RadPanelItem item = new RadPanelItem(child.Display);
                        RadPanelItem itemFolder = new RadPanelItem();
                        item.Value = child.ChildID;
 
                        List<Object> folders = new Child(General.DB).findAllFoldersByDrawer(child.ChildID);
 
                        if (folders.Count > 1)
                        {
                            treeView.ID = child.ChildID + "_tView";
                            treeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);
                            treeView.CheckChildNodes = true;
 
                            RadTreeNodeBinding binding = new RadTreeNodeBinding();
                            binding.Expanded = true;
                            treeView.DataBindings.Add(binding);
                            treeView.DataTextField = "Display";
                            treeView.DataFieldID = "ChildID";
                            treeView.DataValueField = "ChildID";
                            treeView.DataFieldParentID = "ChildChildID";
                            treeView.DataSource = folders;
                            treeView.ShowLineImages = true;
                            treeView.DataBind();
 
                            itemFolder.Controls.Add(treeView);
                            item.Items.Add(itemFolder);
                        }
 
                        pnlDrawers.Items.Add(item);
 
                        if (folders.Count > 1)
                        {
                            AjaxManager.AjaxSettings.AddAjaxSetting(AjaxManager, treeView, RadAjaxLoadingPanel1, UpdatePanelRenderMode.Inline);
                            AjaxManager.AjaxSettings.AddAjaxSetting(pnlDrawers, treeView, RadAjaxLoadingPanel1, UpdatePanelRenderMode.Inline);
                            AjaxManager.AjaxSettings.AddAjaxSetting(treeView, treeView, RadAjaxLoadingPanel1, UpdatePanelRenderMode.Inline);
                        }
                    }


public class Child
    {
        #region properties
        public string ChildID { get; set; }
        public string ParentID { get; set; }
        public string ChildChildID { get; set; }
        public string Label { get; set; }
        public string FirstName { get; set; }
        public string MName { get; set; }
        public string Lastname { get; set; }       
}


Ivan Danchev
Telerik team
 answered on 02 Feb 2015
14 answers
497 views
Hello,

I am doing some functionality with drag & drop effect in which I have to drag from one listview to another listview and also in the same listview for reordering purposes. What happens is that I can't capture the drop when user drops inside the listview but outside an html element (LinkButton, Label, etc).

What I tried to do was to put in my ItemTemplate a div running at server and then tried with a Panel containing the data I'm showing in the ListView, so my codebehind could capture this as a htmlElement, but it won't, DestinationHtmlElement is an empty element.

What should I do??

I was looking the ListBox aproximation and the drag & drop example is more or less what I am looking for, but I did not use that because I have to customize the List content as a Link followed by a Label and also it shouldn't have a scroll but it should have a variable height depending on the ammount of data it has

Hope you can help me soon, and if you didn't understand me just let me know

Thanks in advance,

Camilo
Pavlina
Telerik team
 answered on 02 Feb 2015
4 answers
2.4K+ views
Hi,

I am using RadToolTipManager control and displaying tooltip. Tooltip text i am reading from the database.
for normal text i am able to display tooltip with no problem, but in my text there are carriage return characters (like \n \r),
that causes problem and does not display and gives me error.

Please see code:

 

private void PopulateQuestion()

 

{

lblSectionName.Text =

this.Question.PageTitle;

 

divSection.Visible = (

this.Question.PageTitle != string.Empty);

 

lblQuestionSequence.Text =

"Q." + this.Question.Sequence.ToString() + " - ";

 

lblQuestionText.Text =

this.Question.QuestionText;

 

 

// Set help icon alt text

 

 

//imgHelp.AlternateText = this.Question.AdditionalContent;

 

 

//imgHelp.Attributes.Add("title", this.Question.AdditionalContent); // For FireFox

 

 

// string s = "Khwaja \n saiyed";

 

 

// string newstr = s.Replace("\n", "<br/>");

 

 

//this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, s.ToString(), true);

 

 

this.RadToolTipManager1.TargetControls.Add(imgHelp.ClientID, this.Question.AdditionalContent.ToString(), true);

 

 

}


 

 

protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)

 

{

 

Label lblInsideToolTip = new Label();

 

lblInsideToolTip.Text = e.Value;

e.UpdatePanel.ContentTemplateContainer.Controls.Add(lblInsideToolTip);

 

 

 

 

}


I hope this makes sense to all of you.

Thanks
Khwaja

Nicolaï
Top achievements
Rank 2
 answered on 02 Feb 2015
1 answer
165 views
Hi,
I' working with the version 2014.2.724.45 and our standard is IE9 and I have problems with the clientPasteHtml.  My test page is very simple:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TelerikRadEditorPaste.Default" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            function onClientPasteHtml(editor, args) {
                var commandName = args.get_commandName();
                if (commandName == "Paste") {
                    alert('OK --> CommandName = ' + commandName);
                } else {
                    alert('NOT OK --> CommandName = ' + commandName);
                }
            }
        </script>
         
        <asp:ScriptManager runat="server"></asp:ScriptManager>
 
        <telerik:RadEditor ID="radEditorMandate" runat="server" Width="856px" Height="590px" StripFormattingOptions="NoneSupressCleanMessage, ConvertWordLists, MSWordNoMargins" OnClientPasteHtml="onClientPasteHtml">
            <ContextMenus>
                <telerik:EditorContextMenu TagName="*">
                    <telerik:EditorTool Name="Paste" />
                </telerik:EditorContextMenu>
            </ContextMenus>
            <Tools>
                <telerik:EditorToolGroup>
                    <telerik:EditorTool Name="Paste" />                   
                </telerik:EditorToolGroup>
            </Tools>
            <CssFiles>
                <telerik:EditorCssFile Value="~/RadEditor.css" />
            </CssFiles>
        </telerik:RadEditor>
    </form>
</body>
</html>

If we use the keyboard to paste text (ctrl+v), the command name is OK (Paste), but if we use the toolbar or the context menu, the command name is not OK (undefined)

Could you help to solve this problem??

I tested with IE11 and I meet the same behavior.

Thank you and have a nice day.

Steeve
Ianko
Telerik team
 answered on 02 Feb 2015
1 answer
145 views
Hi there,

I am using a custom skin build with the Visual Style Builder and I am having trouble implementing the following scenario:

When I hover over a main item the color of the main item changes from Red to White, which is OK (see Main item hover.png)
When I hover over a sub item I want the color of the Main text item still be White. Now it changes back to Red (see Sub item hover.png).

Anybody any idea?Thanx!

Marcel
Ivan Danchev
Telerik team
 answered on 02 Feb 2015
6 answers
835 views

I drag a RadScheduler to my webform, and start debug, then I get an error message as following. Please tell me how to solve the problem. Thank you very much for your helping.

DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding]
Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.EnsureDataFieldsAreSet() +205
Telerik.Web.UI.Scheduling.DataSourceViewSchedulerProvider.GetAppointments(RadScheduler owner) +130
Telerik.Web.UI.RadScheduler.PerformSelect() +240
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
Telerik.Web.UI.RadScheduler.EnsureDataBound() +116
Telerik.Web.UI.RadScheduler.CreateChildControls(Boolean bindFromDataSource) +144
Telerik.Web.UI.RadScheduler.CreateChildControls() +47
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360


Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
Boyan Dimitrov
Telerik team
 answered on 02 Feb 2015
1 answer
270 views
Hi All,

Very odd behaviour here...pretty basic radwindow.  Opens based on Hyperlink ElementOpenerID.
See the page here: http://dcmapsa.azurewebsites.net/map.aspx

Bottom left under Help, there are 3 links. They should open 3 different windows.  Simply does not work.  My guess is code conflict somewhere.

Odd thing is that it works on this page without issue...
http://dcmapsa.azurewebsites.net/default.aspx

Anybody got any ideas on this glitch?

Thanks
Brett

​
Marin Bratanov
Telerik team
 answered on 02 Feb 2015
1 answer
152 views
Hi,

I have a grid I am converting from an Infragistics WebGrid to a Telerik RadGrid.  It is a relatively simple grid.  I need to submit the rows after an entire form is filled out.  There can be one to many rows.  I have tried this in a sub that gets called when entire form is submitted:

  For Each row As GridDataItem In RadGrid1.MasterTableView.Items

but it always returns false

Am I doing this correctly?  Does it actually have to be done as a grid event somehow?  How would I do that if I don't want to submit it until a user clicks an asp submit button.  I'm using vb.net by the way.

Thanks for your help!

Julie
Eyup
Telerik team
 answered on 02 Feb 2015
7 answers
263 views
Hi,

I have a question about the RadGrid when you use both paging and grouping. If all the groups are expanded it works fine. But if i collapse a couple of groups, the rowcount of the group are still counted as if they where expanded?

For instance if I have 5 groups with 10 rows each and a pagesize of 20. When I start the page all the groups are expanded, and the first page is shown with 2 groups of 10 rows each. That is good beacuse I want to show 20 rows on each page. But then if I have a "Collapse All"-button that I press, there is only 2 rows showing on my first page? The 2 groups collapsed is only 2 rows but is counted as if thay where expanded?

Is there any way to solve this? I want the page to show as much data as I have set in the pagesize.

This is my grid (I have tried both Client and Server GroupLoadMode):

 

 

<telerik:RadGrid ID="RadGridBuyWarrants" runat="server"

 

 

 

 

OnNeedDataSource="RadGridBuyWarrants_NeedDataSource" AutoGenerateColumns="false"

 

 

 

 

AllowSorting="true" AllowPaging="true" PageSize="20"

 

 

 

 

ShowGroupPanel="false" onitemcommand="RadGridBuyWarrants_ItemCommand"

 

 

 

 

onitemdatabound="RadGridBuyWarrants_ItemDataBound">

 

 

 

<PagerStyle Mode="NumericPages" />

 

 

 

 

<ClientSettings AllowGroupExpandCollapse="True" AllowDragToGroup="True" AllowColumnsReorder="True"/>

 

 

 

<MasterTableView Width="100%" GroupLoadMode="Server">

 


This is my expand/collapse all code:

 

 

foreach (GridItem item in RadGridBuyWarrants.MasterTableView.Controls[0].Controls)

 

 

{

 

 

 

if (item is GridGroupHeaderItem)

 

 

{

 

item.Expanded =

 

true;

 

 

}

 

}


Would be very greatful if anyone could help me solve this.
Pavlina
Telerik team
 answered on 02 Feb 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?