Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
187 views
I have been trying to use the RadGrid to display some data in a SharePoint application page. I think it's close to how I want it to be, but I am having trouble with a few things:

  1. The column alignment between the MasterTable and the DetailTables is off, all the DetailTables seem to be shifted to the right.
  2. I need to figure out how to switch out the image for the expand/collapse button
  3. I need to know how to modify the column width

Any help would be appreciated, I have included a screenshot of the grid and the code I'm using.

Thanks,
Alexander


<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/_layouts/application.master" CodeBehind="~/Pages/VersionHistory.aspx.cs"
         Inherits="BlackBlade.ListActions.DocumentSectionManager.Monitor.VersionHistory, BlackBlade.ListActions.DocumentSectionManager.Monitor,Version=1.0.0.0,Culture=neutral,PublicKeyToken=932c3000eeb6dd9c"
    %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register assembly="Telerik.Web.UI, Version=2008.3.1125.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="cc1" %>
 
 
<asp:Content ID="Main" runat="server" contentplaceholderid="PlaceHolderMain" >   
        <style type="text/css">
        .RadGrid_Vista td{padding:0}
         
        </style>
         
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <!--skins Web20, Office2007, Black -->
        <telerik:RadGrid ID="RadGrid1" runat="server" DecoratedControls="All" Skin="Vista" OnColumnCreated="RadGrid1_ColumnCreated"
            OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound">
            <MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" AllowSorting="true"
                DataKeyNames="GUID, ParentGUID" Width="100%">
                <SelfHierarchySettings ParentKeyName="ParentGUID" KeyName="GUID" />
            </MasterTableView>
            <ClientSettings AllowExpandCollapse="true" />
        </telerik:RadGrid>
     
        <!-- content end --> 
     
</asp:Content>
 
<asp:Content ID="PageTitle" runat="server"
             contentplaceholderid="PlaceHolderPageTitle" >
   Version History
</asp:Content>
 
<asp:Content ID="PageTitleInTitleArea" runat="server"
             contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
   BlackBlade Version History
</asp:Content>



using System;
using Telerik.Web.UI;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Reflection;
using System.Collections.Generic;
using Microsoft.SharePoint.WebControls;
using System.Data;
 
namespace BlackBlade.ListActions.DocumentSectionManager.Monitor
{
    public partial class VersionHistory : LayoutsPageBase
    {
        private DataTable dataTable = new DataTable();
        protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column is GridExpandColumn)
            {
                e.Column.Visible = false;
            }
            else if (e.Column is GridBoundColumn)
            {
                e.Column.HeaderStyle.Width = Unit.Pixel(100);
            }
        }
 
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                base.OnLoad(e);
 
                string strItemId = this.Request["ItemID"];
                string strListId = this.Request["ListID"];
 
                SPWeb site = this.Web;
                SPList list = site.Lists[new Guid(strListId)];
                SPListItem item = list.GetItemById(Convert.ToInt32(strItemId));
 
                ColumnSetup();
 
                VersionCollectionTree tree = new VersionCollectionTree(item);
                PopulateData(tree.headers[0], "root");
                RadGrid1.DataSource = dataTable;
 
                RadGrid1.MasterTableView.FilterExpression = "ParentGUID = 'root'";
            }
            catch
            {
            }
        }
 
 
 
        protected override void OnPreRenderComplete(EventArgs e)
        {
            base.OnPreRenderComplete(e);
            HideExpandColumnRecursive(RadGrid1.MasterTableView);
 
            RadGrid1.MasterTableView.GetColumn("GUID").Visible = false;
            RadGrid1.MasterTableView.GetColumn("ParentGUID").Visible = false;
            RadGrid1.MasterTableView.HorizontalAlign = HorizontalAlign.Left;
 
 
        }
 
        public void HideExpandColumnRecursive(GridTableView tableView)
        {
            GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
            foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
            {
                foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                {
                    nestedView.Style["border"] = "0";
                    nestedView.GetColumn("GUID").Visible = false;
                    nestedView.GetColumn("ParentGUID").Visible = false;
                    nestedView.HorizontalAlign = HorizontalAlign.Left;
 
                    Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
                    if (nestedView.Items.Count == 0)
                    {
                        if (MyExpandCollapseButton != null)
                        {
                            MyExpandCollapseButton.Style["visibility"] = "hidden";
                        }
                        nestedViewItem.Visible = false;
                    }
                    else
                    {
                        if (MyExpandCollapseButton != null)
                        {
                            MyExpandCollapseButton.Style.Remove("visibility");
                        }
                    }
 
                    if (nestedView.HasDetailTables)
                    {
                        HideExpandColumnRecursive(nestedView);
                    }
                }
            }
        }
 
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "Title");
 
            if (e.Item is GridHeaderItem && e.Item.OwnerTableView != RadGrid1.MasterTableView)
            {
                e.Item.Style["display"] = "none";
            }
 
            if (e.Item is GridNestedViewItem)
            {
                e.Item.Cells[0].Visible = false;
            }
        }
 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            CreateExpandCollapseButton(e.Item, "Title");
        }
 
        public void CreateExpandCollapseButton(GridItem item, string columnUniqueName)
        {
            if (item is GridDataItem)
            {
                if (item.FindControl("MyExpandCollapseButton") == null)
                {
                    Button button = new Button();
                    button.Click += new EventHandler(button_Click);
                    button.CommandName = "ExpandCollapse";
                    button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand";
                    button.ID = "MyExpandCollapseButton";
 
                    if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
                    {
                        string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID);
 
                        button.OnClientClick = script;
                    }
 
                    int level = item.ItemIndexHierarchical.Split(':').Length;
                    if (level > 1)
                    {
                        button.Style["margin-left"] = level * 10 + "px";
                    }
 
                    TableCell cell = ((GridDataItem)item)[columnUniqueName];
                    cell.Controls.Add(button);
                    cell.Controls.Add(new LiteralControl(" "));
                    cell.Controls.Add(new LiteralControl(((GridDataItem)item)[columnUniqueName].Text.ToString()));
                }
            }
        }
 
        void button_Click(object sender, EventArgs e)
        {
            ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand";
        }
 
        private void ColumnSetup()
        {
            dataTable.Columns.Add("Title", typeof(string));
            dataTable.Columns.Add("Version");
            dataTable.Columns.Add("Modified");
            dataTable.Columns.Add("User");
            dataTable.Columns.Add("Size");
            dataTable.Columns.Add("Comment");
            dataTable.Columns.Add("GUID", typeof(string));
            dataTable.Columns.Add("ParentGUID", typeof(string));
        }
 
        private void PopulateData(VersionCollectionTree.Node node, string parentGUID)
        {
            DataRow row = dataTable.NewRow();
 
            string GUID = node.versionCollection.latest.file.UniqueId.ToString();
 
            row["GUID"] = GUID;
            row["ParentGUID"] = parentGUID;
            row["Title"] = node.versionCollection.latest.file.Name;
            row["Version"] = node.versionCollection.latest.versionLabel;
            row["Modified"] = node.versionCollection.latest.created;
            row["User"] = node.versionCollection.latest.user.Name;
            row["Size"] = node.versionCollection.latest.size;
            row["Comment"] = node.versionCollection.latest.comment;
            dataTable.Rows.Add(row);
 
            if (node.hasChildren)
            {
                foreach (VersionCollectionTree.Node child in node.children)
                {
                    PopulateData(child, GUID);
                }
            }
        }
    }
}


Pavlina
Telerik team
 answered on 24 Sep 2010
1 answer
121 views
I'm trying to use AsyncUpload in an MVC application, and I want it to grab addtional fields.

I can see that there's support for it, but it's not clear how to make this work.

Do you have an example of what's needed on the client side to make this work?

Is it just a matter of setting serializedConfiguration to "'ReceivedBy='GuidValue'&Description='DescriptionValue'&Administrative='BoolValue'"?

Thanks in advance for your help.

   - Daniel
Genady Sergeev
Telerik team
 answered on 24 Sep 2010
4 answers
191 views
Hi,

I am getting a javascript error "...has no method 'get_item'" in the following code:

          function InitDocumentsMenu(numberOfItems) {
               var menu = $find("<%= mnuDocuments.ClientID %>");
               var topMenuItem = menu.get_items().get_item(0);
}

I have a menu item with child menus but this javascript is not working.  The get_count() returns fine.  I don't know what can be the problem??

Telerik Q2 2009 - 2009.2.826.35

Thanks
bilal
Top achievements
Rank 2
 answered on 24 Sep 2010
1 answer
155 views
Hi,
I'm using the AsyncUpload control in an MVC.NET project, and want to change the TempTargetFolder (dynamically) in the IAsyncUploadResult method. However, I don't have access to Session variables for the current context. (Either accessed via Session. or context parameter)
Here's an example of my code:

protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
{
  // This will throw an exception even when I've set it in the controller
  configuration.TempTargetFolder = context.Session["MySessionVar"].ToString();
  return base.Process(file, context, configuration, fileName);
}

Any suggestions?
Thanks!
Pete
Genady Sergeev
Telerik team
 answered on 24 Sep 2010
1 answer
241 views
Dear Experts,

i have a question reagrding the export functionality to PPT.
I have a report in HTML fromat. The report display a table with result and a chart.
I am looking for the code to export the chart or table into PPT by clicking on a button.
Could you please help?

Thanks

Pat.
Daniel
Telerik team
 answered on 24 Sep 2010
1 answer
149 views
Hi ,

I am planning to purchase Telerik, if it supports following scenerio.


I have data in  sql ,with 3 columns in a table

(PK)column1 : navigationID
Column2: ParentID
Column3: Description

Rows are as follows:

Row1    1   1   Welcome
Row2   2    1   home
Row3    3   2   subhome1
Row4    4   2  subhome2
Row5    5   1    Contact us


I need to display same  in Front end with context menu(Add nod,edit node, delete node) on each node. and when I add new node it should insert to above table with respect to there parent.

I created one sqldatasource and added above table. and for tree control i reffered above 3 columns . for  DataFieldID = navigationID,DAtaFieldParentID=ParentID  and DataFieldTextField =Description but for some reasons I can not see any results in front end.

* could you please give me example or sample code where I can follow similar scenerio

Thanks and Regards,
Michael




Cori
Top achievements
Rank 2
 answered on 24 Sep 2010
2 answers
239 views
I was watching the TelerikTV's "RadTabStrip and RadPanelBar Overview" while configuring a radtabstrip, radmultipage and radajaxmanger.  Afterwards I discovered I had 4 Warnings stating:  Validation (XHTML 1.0 Transitional):  Element ... is not supported.  The elements included 'telerik.web.ui.ajaxsetting', 'updatedcontrols', and 'telerik.web.ui.ajaxupdatedcontrol' twice.  Here is the page I am working on: 
<%@ Page Title="" Language="VB" MasterPageFile="~/Pages/MasterPages/MasterPage.master" AutoEventWireup="false" CodeFile="ExamRegistration.aspx.vb" Inherits="Pages_ExamRegistration" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">
    <p>
         </p>
 
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik.web.ui.ajaxsetting ajaxcontrolid="RadTabStrip1"><updatedcontrols>
<telerik.web.ui.ajaxupdatedcontrol controlid="RadMultiPage1"></telerik.web.ui.ajaxupdatedcontrol>
<telerik.web.ui.ajaxupdatedcontrol controlid="RadTabStrip1"></telerik.web.ui.ajaxupdatedcontrol>
</updatedcontrols>
</telerik.web.ui.ajaxsetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
 
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">
    <Tabs>
        <telerik:RadTab runat="server" PageViewID="rpvExamRegistration"
            Text="Exam Registration">
        </telerik:RadTab>
        <telerik:RadTab runat="server" PageViewID="rpvRegistrant" Text="Registrant">
        </telerik:RadTab>
        <telerik:RadTab runat="server" PageViewID="rpvConfirmation"
            Text="Confirmation">
        </telerik:RadTab>
    </Tabs>
    </telerik:RadTabStrip>
 
        
    <telerik:RadMultiPage ID="RadMultiPage1" Runat="server">
        <telerik:RadPageView ID="rpvExamRegistration" runat="server">
            Exam Registration<br />
            <asp:Label ID="lblMinRequirements" runat="server" Font-Bold="False"
                Font-Underline="True" Text="*Minimum Requirements"></asp:Label>
            <br />
            <asp:Label ID="lblAge" runat="server"
                Text="Age:  Must be 18 years of age as of January 1st of the licensing year.  Private Applicatiors (Farmers) must be at least 16 years old."
                Width="280px"></asp:Label>
            <br />
            <br />
            <br />
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Underline="False"
                Text="Exam Location"></asp:Label>
        </telerik:RadPageView>
        <telerik:RadPageView ID="rpvRegistrant" runat="server">
            Registrant
        </telerik:RadPageView>
        <telerik:RadPageView ID="rpvConfirmation" runat="server">
            Confiramtion
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView4" runat="server">
        </telerik:RadPageView>
    </telerik:RadMultiPage>
 
</asp:Content>
Any suggestions on getting rid of these warnings would be appreciated.  Thanks.
Alex
Alex
Top achievements
Rank 1
 answered on 24 Sep 2010
2 answers
88 views

Hi,

I had succesfully installed the Telerik toolkit and all was running well.
Not quite sure how - the application has suddenly generated some JS errors and thats stopping the Telerik controls to work.

Any ideas?

Thanks!

Debashis Pyne
Top achievements
Rank 1
 answered on 24 Sep 2010
4 answers
288 views
Hi

Is it possible to refresh the data in a combo..? Kind like... 

RadCombo1.Requery or RadCombo1.Refresh

Thanks

Rudie
Kevin Price
Top achievements
Rank 1
 answered on 24 Sep 2010
3 answers
217 views
I have a Radgrid with scrolling enabled and gouping.
There are some issues I am facing with the grid.

I want to hide or show some columns based on some preferences. I have all the columns in the grid structure and I just make them visible based on the preferences. Howevere I have two columns which I want visible all the time. I have a fixed width specified for those columns in the grid declaration. For the rest of the columns I change the width in the code behind.
The issue I am having is when I have more number of columns to show the width of the first two columns changes and the grid resizes to fit all the columns in the grid width. It does not give me a horizontal scrollbar. I want those two columns to always have the fixed width i specified and have the scrollbar visible when the column count increases.

This is my grid declaration:
<telerik:RadGrid ID="RadGridCalendar" runat="server" GridLines="None" AllowPaging="true" 
                            AllowFilteringByColumn="true" Width="975px" ShowHeader="true" OnColumnCreated="RadGridCalendar_ColumnCreated" 
                            OnItemCreated="RadGridCalendar_ItemCreated" OnItemDataBound="RadGridCalendar_ItemDataBound" 
                            AutoGenerateColumns="False" EnableLinqExpressions="false" ShowGroupPanel="false" 
                            OnItemCommand="RadGridCalendar_ItemCommand" AllowSorting="true" AllowCustomPaging="false" 
                            OnNeedDataSource="RadGridCalendar_NeedDataSource">  
                            <ClientSettings Resizing-AllowColumnResize="true">  
                                <ClientEvents OnGridCreated="GridCreated" /> 
                                <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="2"  ScrollHeight="450px" /> 
                              
                            </ClientSettings> 
                           <MasterTableView TableLayout="Fixed" HierarchyDefaultExpanded="true" ClientDataKeyNames="ActivityID" 
                                CommandItemDisplay="Top" DataKeyNames="ActivityID">  
                                <GroupByExpressions> 
                                    <telerik:GridGroupByExpression> 
                                        <SelectFields> 
                                            <telerik:GridGroupByField FieldName="ActivityDate"></telerik:GridGroupByField> 
                                        </SelectFields> 
                                        <GroupByFields> 
                                            <telerik:GridGroupByField FieldName="Date" FormatString="{0:d}" SortOrder="Descending">  
                                            </telerik:GridGroupByField> 
                                            <telerik:GridGroupByField FieldName="ActivityDate" FormatString="{0:d}" SortOrder="None">  
                                            </telerik:GridGroupByField> 
                                        </GroupByFields> 
                                    </telerik:GridGroupByExpression> 
                                </GroupByExpressions> 
                                <Columns> 
                                    <telerik:GridTemplateColumn UniqueName="TimeColumn" HeaderText="Time">  
                                        <ItemStyle Width="130px" BorderStyle="None"></ItemStyle> 
                                        <HeaderStyle Width="130px" /> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# DataBinder.Eval(Container.DataItem, "StartTime") %> 
                                                <asp:Label ID="Label1" runat="server">-</asp:Label> 
                                                <%# DataBinder.Eval(Container.DataItem, "EndTime") %> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Subject" HeaderText="Subject">  
                                        <ItemStyle BorderStyle="None" Width="250px"></ItemStyle> 
                                        <HeaderStyle Width="250px" /> 
                                        <ItemTemplate> 
                                            <div> 
                                                <asp:LinkButton ID="LinkButtonActivity" runat="server" ForeColor="#73abc9" Font-Size="9pt" 
                                                    CommandName="ShowActivity" Font-Bold="true">  
                                                <%# Eval("Subject")%></asp:LinkButton> 
                                                <asp:Label ID="LabelSubject" runat="server" CssClass="label" Width="1px" Visible="false"><%# Eval("Subject")%></asp:Label> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Location" HeaderText="Location" Display="false">  
                                        <ItemStyle BorderStyle="None" ></ItemStyle>  
                                          
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Location")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="DueDate" HeaderText="Due Date" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("DueDate")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Contact" HeaderText="Contact" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Contact")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Description" HeaderText="Description" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Description")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="ActivityStatus" HeaderText="Status" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("ActivityStatus")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="ActivityType" HeaderText="Type" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("ActivityType")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="ActivitySubType" HeaderText="Sub-Type" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("ActivitySubType")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Keywords" HeaderText="Keywords" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Keyword")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Priority" HeaderText="Priority" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Priority")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="Participants" HeaderText="Participants" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("Participants")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="TimeSpent" HeaderText="TimeSpent" Visible="false" 
                                        Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("TimeSpent")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn UniqueName="PercentComplete" HeaderText="% Complete" 
                                        Visible="false" Display="false">  
                                        <ItemStyle BorderStyle="None"></ItemStyle> 
                                        <ItemTemplate> 
                                            <div> 
                                                <%# Eval("PercentComplete")%> 
                                            </div> 
                                        </ItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridBoundColumn DataField="ActivityID" Visible="false" UniqueName="ActivityID">  
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridDateTimeColumn DataField="Date" AllowFiltering="true" Visible="false" 
                                        DataFormatString="{0:MM/dd/yyyy}" UniqueName="Date">  
                                    </telerik:GridDateTimeColumn> 
                                                                       <telerik:GridBoundColumn DataField="ActivityPrimaryParticipant" AllowFiltering="true" 
                                        Visible="false" UniqueName="ActivityPrimaryParticipant">  
                                    </telerik:GridBoundColumn> 
                                      
                                                                   </Columns> 
                                <CommandItemTemplate> 
                                    <asp:ImageButton ID="ImageButtonAdd" runat="server" ImageUrl="~/App_Themes/MLightning/Layout/plus-icon.png" 
                                        AlternateText="Add" PostBackUrl="~/Calendar/CalendarActivityAddSettings.aspx" />                                </CommandItemTemplate> 
                                <PagerStyle Position="TopAndBottom" PrevPageText="Prev" NextPageText="Next" Mode="NextPrev" /> 
                            </MasterTableView> 
                        </telerik:RadGrid> 

.cs code:
 private void ConfigureGridColumns()  
    {  
        DataTable dtCalendarSettings = LoadCalendarSettings();  
 
        if (dtCalendarSettings.Rows.Count > 0)  
        {              
            foreach (DataRow row in dtCalendarSettings.Rows)  
            {  
                int width = 0;  
                GridTemplateColumn col;  
 
                #region Add Columns For user Settings  
                switch (row["FieldName"].ToString().ToLower())  
                {  
                    case "status":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("ActivityStatus");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "type":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("ActivityType");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "subtype":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("ActivitySubType");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "keywords":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Keywords");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "priority":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Priority");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "contact name":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Contact");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                                        case "location":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Location");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "description":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Description");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "participants":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Participants");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "due date":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("DueDate");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "percentage complete":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("PercentComplete");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                    case "time spent":  
                        col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("TimeSpent");  
                        int.TryParse(row["FieldWidth"].ToString(), out width);  
                        col.HeaderStyle.Width = Unit.Pixel(width);  
                        col.ItemStyle.Width = Unit.Pixel(width);  
                        col.Display = true;  
                        col.Visible = true;  
                        width = 0;  
                        break;  
                }  
                #endregion Add Columns  
            }  
        }  
        else  
        {  
            GridTemplateColumn col;  
            col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Location");  
            col.HeaderStyle.Width = Unit.Pixel(120);  
            col.ItemStyle.Width = Unit.Pixel(120);  
            col.Display = true;  
            col.Visible = true;  
 
            col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("DueDate");  
            col.HeaderStyle.Width = Unit.Pixel(120);  
            col.ItemStyle.Width = Unit.Pixel(120);  
            col.Display = true;  
            col.Visible = true;  
 
            col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Contact");  
            col.HeaderStyle.Width = Unit.Pixel(120);  
            col.ItemStyle.Width = Unit.Pixel(120);  
            col.Display = true;  
            col.Visible = true;  
 
            col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Description");  
            //col.HeaderStyle.Width = Unit.Pixel(200);  
            //col.ItemStyle.Width = Unit.Pixel(200);  
            col.Display = true;  
            col.Visible = true;  
 
            col = (GridTemplateColumn)RadGridCalendar.MasterTableView.GetColumn("Participants");  
            col.HeaderStyle.Width = Unit.Pixel(150);  
            col.ItemStyle.Width = Unit.Pixel(150);  
            col.Display = true;  
            col.Visible = true;  
        }  
    } 


Any thoughts on what I might be doing wrong?

Is it also possible to hide the horizontal scrolling completely?



Pavlina
Telerik team
 answered on 24 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?