Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
1.7K+ views
Hi,

Can somebody help me with showing and hiding tabs in code behind? I've tried many methods and none seem to work. I really appreciate your assistance with this one.

Thanks,
Ron.
Richard
Top achievements
Rank 1
 answered on 17 Dec 2011
6 answers
1.0K+ views
Is there a way to ensure that the RadGrid control height is always 100% of the datasource content?

For example, if there are only 3 rows in the grid, the height of the grid control would only be as tall as the three rows in the datasource plus the header row.  All controls on the page below the grid would be displayed directly below the grid.

If the datasource of the grid changed so that the results contained 15 rows, the height of the grid would change to show all 15 rows, and again, any controls on the page below the grid would show directly below the results.

Thanks.
soraya
Top achievements
Rank 1
 answered on 16 Dec 2011
10 answers
247 views
I find an issue in Radgrid.  I couldnt fix it.   I create some columns programmatically.  When I hide colum from header context menu, some blank colum is appear al last.  Copy aspx, aspx.cs and Image (before and after hide column)...  ASPX:                                            <%@ Page Title="" Language="C#" MasterPageFile="~/UI/Doculex.Master" AutoEventWireup="true" CodeBehind="DocumentsList.aspx.cs" Inherits="WebSearch.UI.DocumentsList" %>
<%@ MasterType VirtualPath="~/UI/Doculex.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
   


    <telerik:RadAjaxPanel  runat="server"   EnableViewState="true"  EnableEmbeddedScripts="true" EnableAJAX= "false"   >

    <div class="headerPage">
        <asp:Label ID="lblTitle" runat="server"></asp:Label>
    </div>
    <div class="containerSub" id ="containerSub" runat="server">
    <telerik:RadSplitter  ID ="Splitter"  Width = "100%"  Height ="100%" Orientation="Vertical"  runat="server">
        <telerik:RadPane runat="server" ID="gridPane" Scrolling="None" Height="80%"  Width="100%">
              
             
             <telerik:RadGrid ID="DocumentGrid" runat="server"
                AllowPaging="True" AllowSorting="True"
                AllowFilteringByColumn="true"             
                CellSpacing="0" Height="500px"
                EnableHeaderContextMenu ="true" EnableHeaderContextFilterMenu="true"
                GridLines="None"    AllowMultiRowSelection="true"
                PageSize="12"  AutoGenerateColumns="false" Width="100%"
                EnableLinqExpressions="false"  EnableViewState="True"
                onneeddatasource="DocumentGrid_NeedDataSource"
                onprerender="DocumentGrid_PreRender"  
                onitemcommand="DocumentGrid_ItemCommand"   >
            <ItemStyle VerticalAlign="Top" />
           
            <GroupingSettings CaseSensitive="false" />
         
            <MasterTableView  CommandItemDisplay="None"  DataKeyNames="Id"
                TableLayout="Auto"  PagerStyle-Mode="NumericPages" >
                  <Columns>
                        <telerik:GridClientSelectColumn  CommandName="Select" UniqueName="Select"></telerik:GridClientSelectColumn>     
                       
                   
                                   
                    </Columns>
                </MasterTableView>
                  <ClientSettings Scrolling-SaveScrollPosition="true"  EnablePostBackOnRowClick="true"  Scrolling-AllowScroll="true"  ActiveRowIndex="true" AllowColumnsReorder="true" AllowColumnHide="true">
                  
                  <Selecting AllowRowSelect="true"  />
                           <ClientEvents OnColumnHidden="ColumnHiding" />
                           <Resizing AllowColumnResize="true"></Resizing>

                              
                         </ClientSettings>
                </telerik:RadGrid>

               
        </telerik:RadPane>
       <telerik:RadPane ID="searchPane" Width="20px"  runat="server" Scrolling="None" Height="350px" >
            <telerik:RadSlidingZone runat="server" ID="PaneZone" SlideDirection="Left"   >
                  <telerik:RadSlidingPane ID="DocPreview" runat="server" Width="300px"   OnClientDocked = "PaneDockDocPreview"
                                             OnClientUndocked = "PaneUnDockDocPreview">
                                             <div Id="preview" runat="server"></div>
                 </telerik:RadSlidingPane>
                  <telerik:RadSlidingPane ID="Properties" runat="server" Width="300px" OnClientDocked = "PaneDockProperties"
                                             OnClientUndocked = "PaneUnDockProperties" IconUrl="~/UI/Images/properties.png">
                                             <div id="PropertyList" style="margin-top:5%" runat="server" visible="true">
                                             
                                             </div>

                                               
                 </telerik:RadSlidingPane>
                 <telerik:RadSlidingPane Scrolling="Y" ID="FileNotesPane" runat="server" Width="300px" OnClientDocked = "PaneDockNotes"
                                             OnClientUndocked = "PaneUnDockNotes" IconUrl="~/UI/Images/note.png" visible="false">
                                             <div id="Div1" style="margin-top:5%; width:100%"  runat="server">

                                               <asp:LinkButton ID="lnkAddComment" runat="server" onclick="lnkAddComment_Click" >
                                                  <asp:ImageButton ID="imgAdd" runat="server" ImageUrl="~/UI/Images/add.png" />
                                              <asp:Label ID="lblAddComment" runat="server" /></asp:LinkButton>&nbsp;&nbsp; </div><div class="clear"></div>
                                            
                                            <asp:Panel ID="pnlComment" Visible="false" runat="server">
                                                <table style="width:100%">
                                                    <tr>
                                                        <td><asp:Label ID="lblComent" runat="server"></asp:Label></td><td></td></tr>
                                                        <tr>
                                                        <td ><asp:TextBox  TextMode="MultiLine" CssClass="commentsWithScroll"  Wrap="true" ID="txtComents" runat="server"></asp:TextBox>
                                                         <telerik:RadSpell ID="spellComments" Runat="server" ControlToCheck="txtComents"   />
   
                                                         <asp:RequiredFieldValidator ID="rfvComment" runat="server" ControlToValidate="txtComents" Display="Dynamic" ErrorMessage="*" CssClass="validator" />
                                                        
                                                            <asp:RegularExpressionValidator ID="rExpComments" runat="server" ControlToValidate="txtComents"  CssClass="validator"
                                                        Display="Dynamic"   ValidationExpression="^([\S\s]{1,280})$"></asp:RegularExpressionValidator> </td>
                                                        <td  style="text-align:right"><asp:ImageButton ID="imgSave" runat="server" OnClick="imgSave_Click" ImageUrl="~/UI/Images/add.png" />
                                                       <asp:ImageButton ID="imgCancel" runat="server" ImageUrl="~/UI/Images/cancel.png"   OnClick="imgCancel_Click" /></td>                                                      
                                                        
                                                        </tr></table>
                                                        <div class="clear"></div>
                                                        
                                                        </asp:Panel><asp:Repeater ID="NotesRepeater" runat="server">

                                            <ItemTemplate>
                                              
                                                    <div class="note">
                                                        <div class="dateNote">
                                                           <%# Eval("Date") %>
                                                        </div>
                                                         <div class="ownerNote">
                                                          <%# Eval("OwnerComment")%>
                                                        </h3>
                                                        <div class="commentNote">
                                                          <%# Eval("Comments")%>
                                                        </div>
                                                    </div>
                                                    <div class="clear"></div>
                                            </ItemTemplate>
                                         

                                        </asp:Repeater>


                                             

                                               
                 </telerik:RadSlidingPane>
            </telerik:RadSlidingZone>
        </telerik:RadPane>
    </telerik:RadSplitter>
    
    </div>
     

    </telerik:RadAjaxPanel>


</asp:Content>
ASPX.Cs using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using WebSearch.Components;
using WebSearch.SecurityModel;
using WebSearch.UI.Model;
using WebSearch.UI.Model.Items.Grid;
using WebSearch.UI.Model.Screen;

namespace WebSearch.UI
{
    public partial class DocumentsList : System.Web.UI.Page
    {
        #region Properties
        
        private string _culture;
        private ResourceManager _resources;
        private readonly smOrganization _organization= new smOrganization();
        private List<string> hideColum = new List<string>();
        
        #endregion

        #region Events
       
        protected void Page_Load(object sender, EventArgs e)
        {
            GetInfo();
          
            if (Page.IsPostBack)
            {
                App.SavePreferencesGrid(DocumentGrid);
                App.SavePane();
               if(DocumentGrid.MasterTableView.GetSelectedItems().Length ==0)
               {
                   Session["SelectedRows"] = null;

                   if (Request.QueryString["A"] == "pop" || Request.QueryString["A"] == "note")
                   {
                       Response.Redirect("~/UI/DocumentsList.aspx");
                   }
               }
            }

            if (!Page.IsPostBack)
            {
                LoadSettings();
              
                App.LoadPreferencesGrid(DocumentGrid);
                App.LoadPane(PaneZone);
                LoadCorrectAction();
            }
           

            DocumentGrid.HeaderContextMenu.ItemCreated += new RadMenuEventHandler(HeaderContextMenu_ItemCreated);
            
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            CreateColumns();
        }

        void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e)
        {
            CommonFunctions.HideColumns(sender, e);
            CommonFunctions.HideSpecialColumns("Select", e.Item);
            CommonFunctions.HideSpecialColumns("Id", e.Item);
            CommonFunctions.HideSpecialColumns("Path", e.Item);
            CommonFunctions.HideSpecialColumns("FileName", e.Item);
           
        }

        protected void lnkAddComment_Click(object sender, EventArgs e)
        {
            pnlComment.Visible = true;
            txtComents.Text = null;
            lnkAddComment.Visible = false;
        }

        protected void DocumentGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            DocumentGrid.DataSource = GenericGrid.ListDocuments;
        }

        protected void DocumentGrid_PreRender(object sender, EventArgs e)
        {
            DocumentGrid.MasterTableView.GetColumnSafe("RowIndicator").Display = false;
            DocumentGrid.MasterTableView.GetColumnSafe("Id").Display = false;
            DocumentGrid.MasterTableView.GetColumnSafe("Path").Display = false;

           if (hideColum.Count > 0)
            {
                foreach (string col in hideColum)
                {
                    DocumentGrid.MasterTableView.GetColumnSafe(col).Display = false;
                }
            }


         

            CommonFunctions.GridOptions(DocumentGrid);
        }

        protected void imgSave_Click(object sender, ImageClickEventArgs e)
        {
            if (!Page.IsValid) return;

            string comment = txtComents.Text.Trim();

            _organization.FileNotes = new smFileNotes
            {
                Comments = comment,
                UserId = App.CurrentUserId(),
                FileId = Convert.ToInt16(Session["ID"].ToString()),
                Date = DateTime.Now,
            };
            _organization.CreateNote();
            pnlComment.Visible = false;
            LoadNotes();
            lnkAddComment.Visible = true;
        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            txtComents.Text = null;
            pnlComment.Visible = false;
            lnkAddComment.Visible = true;
        }

       

        protected void DocumentGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {

                case "RowClick":

                    Session["SelectedRows"] = null;

                     Properties.Visible = false;
                     FileNotesPane.Visible = false;

                    if (DocumentGrid.MasterTableView.GetSelectedItems().Length == 0)
                    {
                        preview.InnerHtml = null;
                        
                        PaneZone.DockedPaneId = null;
                        PaneZone.ExpandedPaneId = null;

                        gridPane.Width = Unit.Empty;
                        searchPane.Width = Unit.Pixel(20);
                        return;
                    }

                    if (DocumentGrid.MasterTableView.GetSelectedItems().Length == 1)
                    {
                        Preview();
                        Session["SelectedRows"] = DocumentGrid.MasterTableView.GetSelectedItems();
                        Session["tab"] = Convert.ToString((int)Doculex.Tabs.ActiveDocument);
                    }

                    if (DocumentGrid.MasterTableView.GetSelectedItems().Length > 1)
                    {
                        Session["SelectedRows"] = DocumentGrid.MasterTableView.GetSelectedItems();
                        Session["tab"] = Convert.ToString((int)Doculex.Tabs.MultipleDocument);

                        PaneZone.ExpandedPaneId = "";
                        PaneZone.DockedPaneId = "";

                        FileNotesPane.Visible = false;
                        Properties.Visible = false;
                    }
                    
                    ((HtmlGenericControl)Master.FindControl("header")).Controls.Clear();

                    if (Session["container"] != null)
                    {
                        UIContainer _container = (UIContainer)Session["container"];

                        MenuScreen _menu = new MenuScreen(Convert.ToInt16(Session["tab"]));
                        Session["menu"] = _menu;
                        _container.Menu = (MenuScreen)Session["menu"];

                        ((HtmlGenericControl)Master.FindControl("header")).Controls.Add(_container.RenderHeader());
                    }

                    break;

            }
        }
        #endregion

        #region Methods

        private void LoadCorrectAction()
        {
            if (Request.QueryString["A"] == "prop")
            {
                LoadProperties();
            }
            if (Request.QueryString["A"] == "note")
            {
                LoadNotes();
            }
        }

        private void CreateColumns()
        {
            List<smDocumentTypeField> documentTypeFieldList = _organization.GetDocumentTypeField(1);

           
          
            GridBoundColumn boundColumnId = new GridBoundColumn();
            DocumentGrid.MasterTableView.Columns.Add(boundColumnId);

            boundColumnId.DataField = "Id";
            boundColumnId.UniqueName = "Id";
            boundColumnId.Visible = false;
            boundColumnId.HeaderStyle.Width = Unit.Pixel(1);
            boundColumnId.ItemStyle.Width = Unit.Pixel(1);

            boundColumnId = new GridBoundColumn();
            DocumentGrid.MasterTableView.Columns.Add(boundColumnId);

            boundColumnId.DataField = "Path";
            boundColumnId.UniqueName = "Path";
            boundColumnId.Visible = false;
           

            GridImageColumn imgeColum = new GridImageColumn();
            DocumentGrid.MasterTableView.Columns.Add(imgeColum);

            imgeColum.DataImageUrlFields = new string[] { "Image" };
            imgeColum.HeaderText = "File Type";
            imgeColum.DataImageUrlFormatString = "~/UI/Images/{0}";
            imgeColum.ImageAlign = ImageAlign.Middle;
            imgeColum.AllowFiltering = false;
            imgeColum.UniqueName = "Image";
           

           
            foreach (smDocumentTypeField documentTypeField in documentTypeFieldList)
            {
                GridBoundColumn boundColumn = new GridBoundColumn();
                DocumentGrid.MasterTableView.Columns.Add(boundColumn);

                boundColumn.DataField = documentTypeField.Name;
                boundColumn.HeaderText = documentTypeField.Header;
                boundColumn.UniqueName = documentTypeField.Name;
                boundColumn.Visible = documentTypeField.IsVisible;
              
                if (documentTypeField.IsVisible == false)
                {
                    hideColum.Add(documentTypeField.Name);
                }
            }

        }

        private void GetInfo()
        {
            _culture = App.CurrentCulture();
            _resources = App.GetMasterResources("DocumentsList");
        }

        private void LoadSettings()
        {
            lblTitle.Text = _resources.GetString(lblTitle.ID, new CultureInfo(_culture));

            DocPreview.IconUrl = VirtualPathUtility.ToAbsolute("~/UI/Images/preview.png");
            DocPreview.TabView = SplitterSlidePaneTabView.ImageOnly;
            DocPreview.Title = _resources.GetString("TitleViewPane", new CultureInfo(_culture));
            DocPreview.UndockText =
                _resources.GetString("UndockViewPane", new CultureInfo(_culture));
            DocPreview.DockText =
                _resources.GetString("DockViewPane", new CultureInfo(_culture));
            DocPreview.ToolTip =
                _resources.GetString("ToolTipViewPane", new CultureInfo(_culture));

            PaneZone.Style.Add("position", "static");

            Properties.Visible = false;
            FileNotesPane.Visible = false;
           // DocPreview.Visible = false;

        }
        
        private void LoadSettingsNotes()
        {
            //spellComments.Language = _culture;
            //spellComments.DictionaryLanguage = _culture;

         
            FileNotesPane.TabView = SplitterSlidePaneTabView.ImageOnly;
            FileNotesPane.Title = _resources.GetString("TitleNotesPane", new CultureInfo(_culture));
            Properties.UndockText =
                _resources.GetString("UndockNotesPane", new CultureInfo(_culture));
            FileNotesPane.DockText =
                _resources.GetString("DockNotesPane", new CultureInfo(_culture));
            FileNotesPane.ToolTip =
                _resources.GetString("ToolTipNotesPane", new CultureInfo(_culture));

            FileNotesPane.Visible = true;
            Properties.Visible = false;
          //  DocPreview.Visible = true;

            ImageButton imgSave = (pnlComment.FindControl("imgSave") as ImageButton);
            ImageButton imgCancel = (pnlComment.FindControl("imgCancel") as ImageButton);
            RegularExpressionValidator rExpComments = (pnlComment.FindControl("rExpComments") as RegularExpressionValidator);

            lblAddComment.Text = _resources.GetString(lblAddComment.ID, new CultureInfo(_culture));
            imgSave.ToolTip = _resources.GetString(imgSave.ID, new CultureInfo(_culture));
            imgSave.AlternateText = _resources.GetString(imgSave.ID, new CultureInfo(_culture));
            imgCancel.ToolTip = _resources.GetString(imgCancel.ID, new CultureInfo(_culture));
            imgCancel.AlternateText = _resources.GetString(imgCancel.ID, new CultureInfo(_culture));
            rExpComments.ErrorMessage = _resources.GetString(rExpComments.ID, new CultureInfo(_culture));
        }

        protected void ToggleRowSelection(object sender, EventArgs e)
        {
            ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
        }

        private void LoadNotes()
        {
            LoadSettingsNotes();
            FillCheckGrid();
         
            rExpComments.ErrorMessage = _resources.GetString(rExpComments.ID, new CultureInfo(_culture));

            GridDataItem[] selectedItems = (GridDataItem[])Session["SelectedRows"];

            if (selectedItems.Length == 0) return;

            foreach (var selectedItem in selectedItems)
            {
                Hashtable newValues = new Hashtable();
                
                selectedItem.ExtractValues(newValues);
                Session["ID"] = Convert.ToInt16(newValues["Id"]);
                NotesRepeater.DataSource = _organization.GetNotes(Convert.ToInt16(newValues["Id"]));
                NotesRepeater.DataBind();
            }
            
            FileNotesPane.Visible = true;
            PaneZone.DockedPaneId = FileNotesPane.ID;
            PaneZone.ExpandedPaneId = FileNotesPane.ID;
        }

        private void LoadProperties()
        {
            LoadSettingsProperties();
            GridDataItem[] selectedItems = (GridDataItem[]) Session["SelectedRows"];
            
            if (selectedItems == null) return;

            if (selectedItems.Length == 0) return;

                
            Table tbProperty = new Table();
            FillCheckGrid();

            List<smDocumentTypeField> documentTypeFieldList = _organization.GetDocumentTypeField(1);



            foreach (var smDocumentTypeField in documentTypeFieldList)
            {
                TableRow row = new TableRow();

                TableCell cell = new TableCell();
                Label lbl = new Label { Text = smDocumentTypeField.Name + ":" };
                cell.CssClass = "LabelCol";
                cell.Controls.Add(lbl);
                row.Cells.Add(cell);

                foreach (GridDataItem item in selectedItems)
                {
                    Hashtable newValues = new Hashtable();
                    item.ExtractValues(newValues);

                    if (newValues[smDocumentTypeField.Name] != null && newValues[smDocumentTypeField.Name].ToString().Length > 30)
                    {
                        newValues[smDocumentTypeField.Name] = newValues[smDocumentTypeField.Name].ToString().Substring(
                            0, 30) + "...";
                    }

                    cell = new TableCell();
                    lbl = new Label { Text = newValues[smDocumentTypeField.Name] == null ? null : newValues[smDocumentTypeField.Name].ToString() };
                    cell.CssClass = "TextBoxCol";
                    cell.Controls.Add(lbl);
                    row.Cells.Add(cell);
                }

                tbProperty.Rows.Add(row);
            }
            PropertyList.Controls.Add(tbProperty);
            Properties.Visible = true;
            PaneZone.DockedPaneId = Properties.ID;
            PaneZone.ExpandedPaneId = Properties.ID;
        }

        private void LoadSettingsProperties()
        {
           
            Properties.TabView = SplitterSlidePaneTabView.ImageOnly;
            Properties.Title = _resources.GetString("TitlePropertiesPane", new CultureInfo(_culture));
            Properties.UndockText =
                _resources.GetString("UndockPropertiesPane", new CultureInfo(_culture));
            Properties.DockText =
                _resources.GetString("DockPropertiesPane", new CultureInfo(_culture));
            Properties.ToolTip =
                _resources.GetString("ToolTipPropertiesPane", new CultureInfo(_culture));

            FileNotesPane.Visible = false;
            Properties.Visible = true;
           // DocPreview.Visible = true;
        }

        private void Preview()
        {
           
            foreach (GridDataItem selectedItem in DocumentGrid.MasterTableView.GetSelectedItems())
            {
                Hashtable newValues = new Hashtable();

                selectedItem.ExtractValues(newValues);


                String fileName = newValues["FileName"].ToString();
                String path = newValues["Path"].ToString();

                string[] extension = fileName.Split('.');

                switch (extension[1].ToString().ToLower())
                {
                    case "txt":
                        StreamReader oStreamReader = File.OpenText(path);
                        string contents = oStreamReader.ReadToEnd();

                        preview.InnerHtml = contents;

                        oStreamReader.Close();
                        break;
                        
                    case "pdf":

                        preview.InnerHtml =
                            "<iframe src=\"../TempFolder/" + fileName + "\" style=\"width:718px; height:700px;\" frameborder=\"0\"></iframe>";

                        break;

                    default:

                        preview.InnerHtml = "<b>Preview not available<b>";
                        break;

                }

                PaneZone.ExpandedPaneId = DocPreview.ID;
                PaneZone.DockedPaneId = DocPreview.ID;

                searchPane.Width = Unit.Empty;
              //  searchPane.Width = Unit.Pixel(20);
               
            }
        }

        public void ExecuteAction(string action)
        {
          
            switch (action)
            {
                case "delete":

                    if (DocumentGrid.MasterTableView.GetSelectedItems().Length <= 0)
                    {
                      //  RadAjaxManager1.Alert("Select Document to delete");
                    }
                    else
                    {
                        Hashtable newValues;
                        DataTable dt = (DataTable)Session["grid"];
                        DataTable dataTable = dt.Copy();

                        foreach (GridDataItem selectedItem in DocumentGrid.MasterTableView.GetSelectedItems())
                        {

                            newValues = new Hashtable();

                            selectedItem.OwnerTableView.ExtractValuesFromItem(newValues, selectedItem);

                            foreach (DataRow row in dt.Rows)
                            {
                                if (row["id"].ToString() == newValues["id"].ToString())
                                {
                                    DataRow deleteRow = dataTable.Rows.Find(row["id"]);
                                    dataTable.Rows.Remove(deleteRow);
                                }
                            }

                        }
                        dataTable.AcceptChanges();
                        Session["action"] = "1";
                        Session["grid"] = dataTable;
                        DocumentGrid.DataSource = dataTable;
                        DocumentGrid.DataBind();

                    }
                    break;

                case "zip":
                       
                       
                    break;

               
            }
        }

        public void FillCheckGrid()
        {
          
            GridDataItem[] selectedItems = (GridDataItem[])Session["SelectedRows"];
            
            if (selectedItems == null) return;

            if (selectedItems.Length == 0) return;
           

            foreach (var selectedItem in selectedItems)
            {
                Hashtable newValues = new Hashtable();

                selectedItem.ExtractValues(newValues);

                foreach (GridDataItem row in DocumentGrid.MasterTableView.Items)
                {
                    if (row["Id"].Text ==  newValues["Id"].ToString())
                    {
                        row.Selected = true;
                    }
                }
            }
        }
        #endregion
    }
}


public class MyTemplate : ITemplate
{
    protected Image ImageIcon;

    private readonly string ColName;

    public MyTemplate(string cName)
    {
        ColName = cName;
    }

    public void InstantiateIn(System.Web.UI.Control container)
    {
        ImageIcon = new Image();
        ImageIcon.ID = "ImageIcon";
        ImageIcon.DataBinding += new EventHandler(ImageIcon_DataBinding);
        container.Controls.Add(ImageIcon);
    }

    public void ImageIcon_DataBinding(object sender, EventArgs e)
    {
        Image iconFileType = (Image)sender;

        GridDataItem container = (GridDataItem)iconFileType.NamingContainer;
        iconFileType.ImageUrl = ((DataRowView)container.DataItem)[ColName].ToString() ;
    }
}                                                                                                                                                                       
July
Top achievements
Rank 2
 answered on 16 Dec 2011
1 answer
106 views
i have a problem with the OnNodeClick event in the tree view. I have the following code in ascx file :

<telerik:RadAjaxLoadingPanel  ID = "RadAjaxLoadingPanel1" runat ="server"></telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel ID = "RadAjaxPanel" runat = "server" >
            <telerik:RadTreeView ID ="RadTreeView1" runat ="server" Width ="100%" OnNodeExpand = "RadTreeView1_NodeExpand" LoadingStatusPosition ="BeforeNodeText"
                OnNodeClick = "RadTreeView1_NodeClick"  >                            
            </telerik:RadTreeView>
        </telerik:RadAjaxPanel>

And i am adding the nodes in the code behind:

My code behind:

Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        LoadRootNodes(RadTreeView1, TreeNodeExpandMode.ServerSideCallBack)
    End Sub
 
Private Shared Sub LoadRootNodes(ByVal treeView As RadTreeView, ByVal expandMode As TreeNodeExpandMode)
        Dim RootNode As New RadTreeNode()
        RootNode.Text = "Guest"
        RootNode.Value = "1"
        RootNode.ExpandMode = expandMode
        treeView.Nodes.Add(RootNode)
    End Sub
 
Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs)
        PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSideCallBack)
    End Sub
 
Private Shared Sub PopulateNodeOnDemand(ByVal e As RadTreeNodeEventArgs, ByVal expandMode As TreeNodeExpandMode)
        For i As Integer = 1 To 10
            Dim childNode As New RadTreeNode
            childNode.Text = i.ToString
            childNode.Value = i.ToString
            e.Node.Nodes.Add(childNode)
        Next
        e.Node.Expanded = True
    End Sub
 
Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs)
        Dim str As String = e.Node.Value
    End Sub
 
On Init i am just loading one root node guest, and when Expand is clicked, i am populating
1 to 10 as child nodes. Now, when i click on one of the nodes, i can hit the break point  at RadTreeView1_NodeClick and when i run, the tree is getting populated and
everything is fine. Now, my problem is, when i click another node, i CANT hit
the break point(on the second node click) and the tress is also not getting
populated. I can just see "Guest" and not the below nodes. Can any one
please help me. Thanks
Sagar
Top achievements
Rank 1
 answered on 16 Dec 2011
1 answer
59 views
Hello,

I'm doing a programmatic insert with a radgrid, and graving the newvalues out of the insertitem. I am doing this in a procedure handling then InsertCommand event. The insert itself works just fine...

The trouble is that I can't figure out how to close the insert form. I can rebind the grid, but that doesn't do it, I have tried IsItemInserted = false, but that throws an error. How on earth do you get the grid to just close and rebind normally when doing a programmatic insert?

Thanks,

Mike
Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Dec 2011
2 answers
79 views
hello this is my i want when i click on in retrun my grid's row id in code thanks
<telerik:GridButtonColumn UniqueName="Edit" ButtonType="ImageButton" ImageUrl="../../Images/Edit.png"
                Display="true" Text="<%$Resources:Caption,Edit%>"  HeaderButtonType="PushButton">
            </telerik:GridButtonColumn>

Jayesh Goyani
Top achievements
Rank 2
 answered on 16 Dec 2011
1 answer
102 views
Hi,

This is an Internet Explorer only related issue, it doesn't happen in Firefox, and as such I don't know how to trouble-shoot it.

I have a MasterTable that contains a bunch of columns, a few of which have specific widths set. The columns are created dynamically using AutoGeneratedColumns, and the widths are set in the ColumnCreated procedure.

This MasterTable has two DetailTables, and I currently have two entries. The first one has only short amounts of data in it, and as such no column ever has more than one line of text in it. This one works absolutely fine, I can expand and collapse the DetailTables without any problems at all.

The second one has a Note that is about 500 characters long (the note in the previous one is 10 characters long). When I expand THIS detail table the MasterTableView loses all it's widths for the columns and they all become completely random widths, seemingly dependent on the content and not on the actual defined sizes. When I collapse it they return to normal.

While this isn't the biggest problem in the world it is incredibly annoying from a design point of view because I don't want the columns to randomly resize whenever one of the DetailTables happens to contain a stupidly long value that's too wide for the column it's in and has to be wrapped across two or more lines. I've tried a few things, like setting the e.Column.ItemStyle.Wrap = true, but that made no difference at all. I'm going to guess that Internet Explorer is screwing with it in a way that Firefox can cope with happily, and I'm going to assume there's either a CSS or Javascript solution to it that I'm not aware of.

Please see the attached screenshots if this isn't 100% clear. You'll note one doesn't have the detail tables expanded, one does but the line of data in the notes table is small enough that it only stays on one line, and in the other the note is so large it spans across four lines (which I tried to make obvious by using black and grey), and on that one the whole MasterTable shifts the column sizes randomly.

Any help would be appreciated.
Pete
Top achievements
Rank 1
 answered on 16 Dec 2011
1 answer
53 views
I have setup my editor as follows but on switching design html it changes the paths to http://localhost/ 

   <telerik:RadEditor ID="txtcontent" EditModes="Design, Html"     OnClientInit="OnClientInitFilter"
                ContentFilters="FixUlBoldItalic, FixEnclosingP, IECleanAnchors, MozEmStrong, ConvertFontToSpan, ConvertToXhtml, IndentHTMLContent, EncodeScripts, OptimizeSpans, ConvertCharactersToEntities" 
                                    ToolsFile="~/Account/ToolsFile.xml"  Runat="server"  >
                        <CssFiles >
                        <telerik:EditorCssFile Value="EditorContentArea.css" />
                        </CssFiles>
                                   <ImageManager ViewPaths="~/Img" UploadPaths="~/Img" DeletePaths="~/Img" /> 
                       
                        </telerik:RadEditor>
                  

latest demo version of controls is being used.
Rumen
Telerik team
 answered on 16 Dec 2011
1 answer
62 views

Hello,
When i click on column header of the radcalendar it selects all the days of week for that month, ie. When i click on 'W' then it selects all the Wednesdays for that month. But what i want is when i click on 'W' then it should select all the Wednesdays for an entire date range (range i have set using rangemindate and rangemaxdate span across 10 months) after asking a confirmation

For this i have done the following

string day = "Wednesday"; // i am setting this value dynamically through client side OnColumnHeaderClick
for (DateTime date = rangeStart; date.CompareTo(rangeEnd) < 1; date = date.AddDays(1))
                {
                    if (day == Enum.GetName(typeof(DayOfWeek), date.DayOfWeek)) 
                    {
                        RadDate rd = new RadDate(date);
                        radCalendarAM.SelectedDates.Add(rd);
                    }
                }

This works perfectly when selecting dates. Now if i click on the same column header again i want to remove all the "wednesdays" for the entire date range. To remove i have done the following

DayOfWeek dow = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), day);
                for (int i = 0; i < radCalendarAM.SelectedDates.Count; i++)
                {
                    RadDate date = (RadDate)radCalendarAM.SelectedDates[i];
                    if (date.Date.DayOfWeek == dow)
                    {
                        radCalendarAM.SelectedDates.RemoveAt(i);
                    }
                }

But this code does'nt remove all the Wednesdays in the date range, it leave behind alternate wednesdays (or which ever day) selected.
Can you advice on this?

-thanks



CJ
Top achievements
Rank 1
 answered on 16 Dec 2011
4 answers
351 views
Hi there,

I have been using the RadCalendar on my webpage.

RadControls for ASP.NET AJAX Q1 2011
version 2011.1.413.35
on a .net 3.5 website

Adding a selected date is easy enough:
        RadCalendar1.SelectedDates.Add(new RadDate(new DateTime(2011, 7, 28)));

Removing a previously added selected date gives an error, however:
        RadCalendar1.SelectedDates.Remove(new RadDate(new DateTime(2011, 7, 28)));
 
Error:
Cannot remove the specified item because it was not found in the specified Collection.
despite the fact that it was added.

Or if I do something like this, it Contains comes back as true, and then remove comes up with the same error.

if (RadCalendar1.SelectedDates.Contains(new RadDate((DateTime)item["CourseDate"]))) {
    RadCalendar1.SelectedDates.Remove(new RadDate((DateTime)item["CourseDate"]));
}

Any ideas?
CJ
Top achievements
Rank 1
 answered on 16 Dec 2011
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?