Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
133 views

Hi,

We are using ribbon-button and in which we are shorting its name after curtain length e.g xyz... . We see Tooltip by hovering over there , in that also we same text with Ellipsis but there we want full text. So can you please suggest  or tell us how we can achieve that .

Attached Snap shot.

Magdalena
Telerik team
 answered on 29 Mar 2016
0 answers
216 views

I am trying to Implement IBindableTemplate for creating custom Edit Template in Batch Edit Mode. Not able to implement the ExtractValues method of IBindableTemplate interface correctly. When I assign the Control.ID in InstantiateIn() method then i am getting the following error. Without  this control ID how to get the values in ExtractValues() method.

System.Web.HttpException: Multiple controls with the same ID 'DepartmenCode' were found. FindControl requires that controls have unique IDs.   
 at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)    
 at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)    
 at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)    
 at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)    
 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

protected override void OnInit(EventArgs e)
        {
RadGrid theGrid = new RadGrid();
                    theGrid.ID = this.ID + "Grid";
                    theGrid.AutoGenerateColumns = false;
theGrid.NeedDataSource += new GridNeedDataSourceEventHandler(theGrid_NeedDataSource);
                    theGrid.DetailTableDataBind += new GridDetailTableDataBindEventHandler(theGrid_DetailTableDataBind);
                    theGrid.SortCommand += new GridSortCommandEventHandler(theGrid_SortCommand);
                    theGrid.ItemDataBound += new GridItemEventHandler(theGrid_ItemDataBound);
                    theGrid.DataBound += new EventHandler(theGrid_DataBound);
                    theGrid.PreRender += new EventHandler(theGrid_PreRender);
                    theGrid.PageIndexChanged += new GridPageChangedEventHandler(theGrid_PageIndexChanged);
                    //Batch Edit Mode Start 
                    theGrid.BatchEditCommand += new GridBatchEditEventHandler(theGrid_BatchEditCommand);
                    
                    theGrid.MasterTableView.EditMode = GridEditMode.Batch;
                    theGrid.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Row;
                    theGrid.MasterTableView.BatchEditingSettings.OpenEditingEvent = GridBatchEditingEventType.DblClick;
                    theGrid.MasterTableView.BatchEditingSettings.SaveAllHierarchyLevels = true;
                    theGrid.MasterTableView.CommandItemSettings.ShowSaveChangesButton = true;
                    theGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
                    theGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
                    theGrid.ShowHeader = true;
                    theGrid.MasterTableView.CommandItemSettings.ShowCancelChangesButton = true;
                    //Batch Edit Mode End 

SetupGridColumns();
}

private void SetupGridColumns(){
 
foreach (XmlElement displayField in DisplayFields)
            {
SetupGridColumn(displayField)
}

}


 private void SetupGridColumn(fieldName){
GridTemplateColumn col=new GridTemplateColumn();
                
                SPField field = TopList.Fields[fieldName];
                col.ItemTemplate = new DataGridEditTemplate(ListItemType.Item, fieldName, fieldInternalName, field, theGrid, listView.Utility);
                col.EditItemTemplate = new DataGridEditTemplate(ListItemType.EditItem, fieldName,fieldInternalName, field, theGrid, listView.Utility);
                col.DataField = fieldInternalName;
GridTableView.Columns.Add(col);
}

 private void theGrid_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
        {
            foreach (GridBatchEditingCommand command in e.Commands)
            {
                if ((command.Type == GridBatchEditingCommandType.Update))
                {
                    Hashtable newValues = command.NewValues;
                    Hashtable oldValues = command.OldValues;
                    string ID = newValues["ID"].ToString();
                    //string Name = newValues["Name"].ToString();

                    try
                    {
                        SPList list = SPContext.Current.Web.Lists.TryGetList("Department");
                        SPListItem item = list.GetItemById(Convert.ToInt32(ID));
                        foreach (DictionaryEntry entry in newValues)
                        {
                            if ((string)entry.Key != "ID")
                            {
                                item[(string)entry.Key] = entry.Value;
                            }
                        }
                        item.Update();

                    }
                    catch (Exception exc)
                    {

                        Logger.Log(TraceSeverity.High, this.PageUrl, this.Title, this.CurrentUserName, exc.Message, exc.StackTrace);
#if DEBUG
                        ErrorMessage = Utility.GetMessage(WADataViewerConstant.ResourceNamespace, "ERROR_OCCURED", exc.ToString());
#else
                ErrorMessage = Utility.GetMessage(WADataViewerConstant.ResourceNamespace, "ERROR_OCCURED", exc.Message);
#endif
                        e.Canceled = true;
                    }
                }
            }
        }

public class DataGridEditTemplate : IBindableTemplate
    {
        ListItemType _templateType; 
        string columnName;
        SPField _spField;
        RadGrid _theGrid;
        bool isAutoPostBack;
        string _fieldInternalName;
        WAUtility _Utility;
        public DataGridEditTemplate(ListItemType templateType, string colname, string fieldInternalName, SPField field, RadGrid grid, WAUtility Utility)
        {
            _templateType = templateType;
            columnName = colname;
            _fieldInternalName = fieldInternalName;
            _spField = field;
            _theGrid = grid;
            _Utility = Utility;
        }

        public void InstantiateIn(System.Web.UI.Control container)
        {
            Label lc = new Label();
            switch (_templateType)
            {
              
                case ListItemType.Item:
                   // lc.Text = "Item " + _fieldInternalName;
                    lc.DataBinding += new EventHandler(lControl_DataBinding);
                    //lc.ID =_fieldInternalName;
                    container.Controls.Add(lc);
                    break;
                case ListItemType.EditItem:
                  
                    container.Controls.Add(GetControlByFieldType(_spField, null));
                    break;
                  
            }
        }
        public void lControl_DataBinding(object sender, EventArgs e)
        {
            Label l = (Label)sender;
            GridDataItem container = (GridDataItem)l.NamingContainer;
            l.Text = ((DataRowView)container.DataItem)[_fieldInternalName].ToString();
        }

private Control GetControlByFieldType(SPField field)
        {
            Control fieldControl = null;
            BaseFormControl basefc = null;

            string validationGroup = field.Id + "ValidationGroup";
            string mask = null;
            string promptCharacter = null;

            bool editable = !field.ReadOnlyField; 
            //bool autoPostBack = IsAutoPostbackField(fieldNode);

            switch (field.Type)
            {
                case SPFieldType.Text:
                    #region -------------Text---------------------- 
                    SPFieldText fieldText = (SPFieldText)field;

                    TextFieldControl tfc = new TextFieldControl();
                    basefc = tfc;
                    tfc.ID = _fieldInternalName;
                    tfc.ContainerID = validationGroup;
                    tfc.Mask = mask;
                    tfc.PromptCharacter = promptCharacter;
                    tfc.FieldMaxLength = fieldText.MaxLength;
                    tfc.FieldDisplaySize = fieldText.DisplaySize;
                    tfc.FieldIMEMode = fieldText.IMEMode;
                    tfc.Editable=editable;
                    fieldControl = tfc;

                    break;
                    #endregion -------------Text---------------------- 
}
}

  public System.Collections.Specialized.IOrderedDictionary ExtractValues(System.Web.UI.Control container)
        {
            System.Collections.Specialized.OrderedDictionary od = null;
            //od.Add("OrderID", ((DropDownList)(((GridEditFormItem)(container)).FindControl("dropdownlist1"))).DataValueField);
            //if (container is GridDataItem)
            //{
            //    GridDataItem dataItem = container as GridDataItem;
            //}
            //if (container is GridEditFormItem)
            {
                od = new System.Collections.Specialized.OrderedDictionary();
                //od.Add(_fieldInternalName, ((DropDownList)(((GridEditFormItem)(container)).FindControl("_fieldInternalName"))).DataValueField);
                //Control ctrl = ((container)).FindControl("_fieldInternalName");

                foreach (Control ctrl in container.Controls)
                {
                    if (ctrl.Controls.Count > 0)
                    {
                        Type ctrlType = ctrl.Controls[0].GetType();
                        if (ctrlType == typeof(DropDownList))
                        {
                            od.Add(ctrl.Controls[0].UniqueID, ((DropDownList)(ctrl.Controls[0])).DataValueField);
                        }
                        if (ctrlType == typeof(TextBox))
                        {
                            od.Add(ctrl.Controls[0].UniqueID, ((TextBox)(ctrl.Controls[0])).Text);
                        }
                        if (ctrlType == typeof(Label))
                        {
                            od.Add(ctrl.Controls[0].UniqueID, ((Label)(ctrl.Controls[0])).Text);
                        }
                    }
                }
            }
            
            
            return od;
        }
    }
Abhishek
Top achievements
Rank 1
 asked on 29 Mar 2016
2 answers
516 views

Hello,

I've been trying to implement some logic using RadButton, RadComboBox and RadTextBox altogether in order to set a RadLabel text.
Everything is part of an Edit Form of a RadGrid component using EditFormType="WebUserControl"

Below is my ASPX code :

01.<telerik:RadButton ID="RadButton1" runat="server" ToggleType="Radio"
02.  ButtonType="StandardButton" AutoPostBack="false" ReadOnly="true" ClientIDMode="Static"
03.  UseSubmitBehavior="false" RenderMode="Lightweight" GroupName="GroupTest"
04.  Checked="true">
05.  <ToggleStates>
06.    <telerik:RadButtonToggleState Text="TTC" PrimaryIconCssClass="rbToggleRadioChecked" />
07.    <telerik:RadButtonToggleState Text="TTC" PrimaryIconCssClass="rbToggleRadio" />
08.  </ToggleStates>
09.</telerik:RadButton>
10.<telerik:RadButton ID="RadButton2" runat="server" ToggleType="Radio"
11.  ButtonType="StandardButton" AutoPostBack="false" ReadOnly="true" ClientIDMode="Static"
12.  UseSubmitBehavior="false" RenderMode="Lightweight" GroupName="GroupTest" >
13.  <ToggleStates>
14.    <telerik:RadButtonToggleState Text="HT" PrimaryIconCssClass="rbToggleRadioChecked" />
15.    <telerik:RadButtonToggleState Text="HT" PrimaryIconCssClass="rbToggleRadio" />
16.  </ToggleStates>
17.</telerik:RadButton> 
18.<telerik:RadTextBox ID="RadTextBox1" runat="server"
19.  Text='<%# DataBinder.Eval(Container, "DataItem.Field1") %>' RenderMode="Lightweight"  
20.  onkeyup="myJsFunction1(event, 'RadTextBox1');"
21.  Width="110px" ClientIDMode="Static"></telerik:RadTextBox> 
22.<telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight"
23.  SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Field2") %>'
24.  DataTextField="value" DataValueField="value" Width="80px" ClientIDMode="Static"></telerik:RadComboBox> 
25.<telerik:RadLabel ID="RadLabel1" runat="server" RenderMode="Lightweight"
26.  ClientIDMode="Static"></telerik:RadLabel>

 

So my issue is that everytime I try to use some built in Telerik ClientEvent for RadComboBox, RadTextBox or RadButton I'm facing two problems :

  1. My JavaScript function supposed to be called is never called e.g. OnClientCheckedChanged="myJsFunction" is never fired
  2. As soon as one component has an OnClient event declared (whether it's the RadButton, the RadTextBox or the RadCombobox) the RadButton rendering is totally messed up (see the screenshot_1.png attached to good display and screenshot_2.png attached for messed up display))

In place of the RadTextBox's onkeyup if I use the ClientEvents-OnKeyPress event I get exactly the same problem.

I also tried to implement some client side logic to the same RadButton shown up there outside of any RadGrid but I'm still facing this issue.

I am really facing a dead end with this. Of course I could use some ASP basic controls to implement the behavior but I'd like to keep some coherence for the rendering of my web page.

Regards,

Benjamin Bourgeois.

Benjamin
Top achievements
Rank 1
 answered on 29 Mar 2016
4 answers
982 views
Hi,

I have an issue using 2 RadWindowManager in the same page: the javascript OnClientClose method of a RadWindow managed by the second RadWindowManager is never invoked, when closing this window.

To describe more precisely my scenario: the page contains 2 usercontrols where each defines their RadWindowManager and their RadWindow (used as dialog boxes). When closing a RadWindow, their OnClientClose method is getting back some arguments, and pass them into a hidden input control of each user control (TopicId in Control1, ContactId in Control2), and finally invoke a hidden button (btnHidden in each userControl) in order to execute some treatment server-side.

It works fine for the RadWindows in Control 1. The OnImageUploader() javascript function is invoked properly. But is does not work for the RadWindow in Control 2, the OnClientClose() is never invoked.

Here is a simplified version of these 2 controls.

Control 1:

    <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
    <script type="text/javascript">
        //<![CDATA[
        function openImageUploader() {
            var oWnd = radopen("ImageUploader.aspx", "RadWindow2");
        }
  
        function openImageCatalog() {
            var oWnd = radopen("ImageCatalog.aspx", "RadWindow3");
        }
  
        function OnImageUploaderClose(oWnd, args) {
  
            //get the transferred arguments
            var arg = args.get_argument();
            if (arg) {
                var contactInput = document.getElementById("<%= TopicId.ClientID %>");
                if ( contactInput ) contactInput.value = arg.topicId;
  
                var btn = document.getElementById("<%= btnHidden.ClientID %>");
                if (btn) btn.click();
            }
        }
          
        //]]>    
        </script>
    </telerik:RadScriptBlock>
  
    <telerik:RadWindowManager ID="RadWindowManager2" ShowContentDuringLoad="false" VisibleStatusbar="false"
        ReloadOnShow="true" runat="server" Skin="Web20">
        <Windows>
            <telerik:RadWindow runat="server" ID="RadWindow2" 
                Modal="true"
                Behaviors="Move,Close" 
                OnClientClose="OnImageUploaderClose" 
                NavigateUrl="~/Customer/ImageUploader.aspx" 
                Width="460px" Height="300px"  
                >
            </telerik:RadWindow>
            <telerik:RadWindow runat="server" ID="RadWindow3" 
                Modal="true"
                Behaviors="Move,Close" 
                OnClientClose="OnImageUploaderClose" 
                NavigateUrl="~/Customer/ImageCatalog.aspx" 
                Width="420px" Height="480px" 
                >
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
  
    <asp:HiddenField ID="TopicId" runat="server" />
  
    <div style="float:left; margin-left:5px;" >
  
    </div>
  
<asp:Button 
    ID="btnHidden" 
    runat="server" 
    Text="_hiddenrefresh" 
    style="display:none;" 
    CausesValidation="true" 
    UseSubmitBehavior="true" 
    OnClick="btnHidden_Click" 
    Width="32px" />

Control 2:

 

<telerik:RadScriptBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    //<![CDATA[
    function openAddressBook()
    {
        var oWnd = radopen("AddressBook.aspx", "RadWindow1");
    }
      
    function OnClientClose(oWnd,args)
    {
        //get the transferred arguments
        var arg = args.get_argument();
        if(arg)
        {
            var contactInput = document.getElementById("<%= ContactId.ClientID %>");
            contactInput.value = arg.contactId;
  
            var btn = document.getElementById("<%= btnHidden.ClientID %>");
            if (btn) btn.click();
        }
    }
    //]]>
</script>
</telerik:RadScriptBlock>
  
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
    ReloadOnShow="true" runat="server" Skin="Web20">
    <Windows>
        <telerik:RadWindow runat="server" ID="RadWindow1" 
            Modal="true"
            Behaviors="Move,Close" OnClientClose="OnClientClose" 
            NavigateUrl="~/Customer/AddressBook.aspx" Width="280px" Height="540px" >
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
  
<div style="margin-bottom:10px;">            
  
    <asp:HiddenField ID="ContactId" runat="server" />
      
</div>
  
<asp:Button 
    ID="btnHidden" 
    runat="server" 
    Text="_hiddenrefresh" 
    style="display:none;" 
    CausesValidation="true" 
    UseSubmitBehavior="true" 
    OnClick="btnHidden_Click" 
    Width="32px" />

 

 


After several tests, it appears that the RadWindowManager in control 1 is receiving the close event.
So I imagine that I need to use and define only one RadWindowManager somewhere, but then how can I pass my dialog box results to the correct control ? ( my knowledge with JavaScript in very poor )

Many thanks for any help
Emmanuel

 

Sandhya
Top achievements
Rank 1
 answered on 29 Mar 2016
1 answer
87 views

I have a grid in which I am creating and populating a nested detail view using a private class (DetailTemplate) which inherits from ITemplate. The detail view is populated with controls in the InstantiiateIn method of the DetailTemplate class.

In Page_Init, I create a new instance of DetailTemplate and assign it to master.MasterTableView.NestedViewTemplate where master is the main grid and parent of the nested detail view.

The first time the page is browsed, the page renders as expected with an Expand/Collapse column in the master grid and expanding/collapsing any of the master grid's rows works as expected.

After postbacks which result in the master grid being rebound, the Expand/Collapse column of the master grid disappears. I'm guessing I'm missing assigning a new instance of DetailTemplate to master.MasterTableView.NestedViewTemplate somewhere when the master grid gets rebound. What am I missing?

Kostadin
Telerik team
 answered on 29 Mar 2016
13 answers
350 views
Can you please provide a demo to show how to filter(using CheckListFilter) the grid with a filtered data set. I have searched through the forum but can't find
a suitable solution which can be fitted in my project. Suppose I have 2 columns in Rad Grid. Column A and B. If I filter the grid using 
column A, then  only those values will show in column B's filter list which are now showing in the grid. It would be very 
helpful if you can provide a demo for it.


Thanks in advance.
Iffat
Kostadin
Telerik team
 answered on 29 Mar 2016
1 answer
132 views

Doing the following in IE will result in both lines being set to 20px:

  • set the font size to a non-default size (in this case 20px)
  • type some text
  • hit enter for a new line
  • type some text

The same thing done in Chrome results in only the first line being 20px, with the second line being set back to the default font size.

Here is the resulting HTML in IE:
<span style="font-size: 20px;">first line<br> second line</span>

and in Chrome:
<span style="font-size: 20px;">first line<br></span>second line

Is there anything that can be done to have Chrome behave like IE in this situation, so that new lines will still be within the font setting span tag?  Using v 2014.1.225.45.

Ianko
Telerik team
 answered on 29 Mar 2016
2 answers
129 views

Hi All,

I wanted to drag a single row from one radgrid to another, but the radgrid row while being dragged is too awkwardly long or big (my radgrid's width is to screen width). Is there a functionality where I could replace a row's appearance while being dragged by the cursor?

 

Thanks,
Jes

 
Jes
Top achievements
Rank 1
 answered on 29 Mar 2016
2 answers
153 views

I have a very strange problem I am using a RadGrid with an .ascx user control form to do editing and adding of new records.  The form works fine when I am editing a record but crashes when I attempt to add a record.

This is the code used to setup the dropdown on the .ascx page

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="EntityDataSource1"
                        DataTextField="StatusDescription" DataValueField="StatusDescription"
                        SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Status") %>'>
                        <asp:ListItem Selected="True" Text="Select" Value="">
                            </asp:ListItem>
                    </asp:DropDownList>

This is the C# code behind for that page.

namespace CrimeTips
{
    public partial class InvestigationDetailsControl : System.Web.UI.UserControl
    {
        private object _dataItem = null;
 
 
        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
 
        }
 
        protected void DropDownList1_SelectedIndexChanged(object sender, DropDownListEventArgs e)
        {
            string StatusValue = DropDownList1.DataValueField;
        }
         
    }
}

And here is the ASPX code for the EditFormSettings

<EditFormSettings UserControlName="InvestigationDetailsControl.ascx" EditFormType="WebUserControl">
                        <EditColumn UniqueName="EditCommandColumn1">
 
                    </EditColumn>
                    </EditFormSettings>

The problem is when I edit the data the form works without any issues.  However, when I attempt to add a records the application crashes with the yellow screen of death with an error message stating

'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value 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.ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

I do not understand why the form works for editing purposes but will not render for the add record can someone offer an explanation and a fix for the problem?

 

Thanks

Perry
Top achievements
Rank 1
 answered on 28 Mar 2016
1 answer
218 views

hi

I would like to hide link when time has passed. How should i go about it? Thanks a lot

<telerik:GridBoundColumn DataField="Time"   FilterControlAltText="Filter Time column" HeaderText="Time" ReadOnly="True" SortExpression="Time" UniqueName="Time">
                    <ColumnValidationSettings>
                    </ColumnValidationSettings>
                </telerik:GridBoundColumn>

   <telerik:GridButtonColumn CommandName="detailcolumn" FilterControlAltText="Filter column column" ItemStyle-ForeColor="#3498DB" ItemStyle-Font-Underline="true"  HeaderText="Detail" Text="Detail" 
                        UniqueName="detailcolumn" >                     
                    </telerik:GridButtonColumn>

 

Kostadin
Telerik team
 answered on 28 Mar 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?