Hi,
I have a multilevel grid and I want to export them out as Excel. I set
ExportSettings.ExportOnlyData = true;
ExportSettings.IgnorePaging = true;
ExportSettings.OpenInNewWindow = true;
It can popup downloading window and export the master grid if I haven't expanded any detail table. However, if I ever expand any detail table, the grid will just display the export table in current page. I checked my code, the OpenInNewWindow is always set to ture before it call ExportToExcel().
However, if I set HierarchyLoadMode="Client" in the MasterTableView, I won't get the above problem even if I expand any detail table.
I want to use server side hierarchy load mode and avoid the above problem. Does any body know this trick??
Thanks a lot,
Joe
| <telerik:RadPane ID="rpTreeView" Runat="server" Width="300px" Height="100%" |
| OnClientResized="ResizeTabStrip" CssClass="treeview" Scrolling="Both"> |
| <telerik:RadMultiPage ID="rmpTabStrip" Runat="server" RadControlsDir="~/Img/Skins/" |
| SelectedIndex="0" CssClass="treeview" Width="100%" Height="100%"> |
| <telerik:RadPageView ID="Operational" runat="server" Height="100%" Width="100%"> |
| <telerik:RadPanelbar ID="rpbOperational" Runat="server" |
| Width="100%" Height="96%" |
| ExpandMode="FullExpandedItem" |
| SkinsPath="~/Img/Skins/Panelbar/Skins/" |
| RadControlsDir="~/Img/Skins/" |
| Skin="Office2007" style="background-color:#f0f0f0"> |
| <Items> |
| <telerik:RadPanelItem Value="Geo" runat="server" meta:resourcekey="panel_geographic" Expanded="True" CssClass="treeview"> |
| <Items> |
| <telerik:RadPanelItem Value="GeoTree" runat="server" CssClass="treeview"> |
| <ItemTemplate> |
| <telerik:RadTreeView ID="rtGeographic" Runat="server" |
| Skin="Vista" CssClass="treeview" |
| MultipleSelect="true" |
| onnodeexpand="rtGeographic_NodeExpand" |
| onClientNodeClicking="onClientNodeClick" |
| OnContextMenuItemClick="rtGeographic_ContextMenuItemClick" |
| meta:resourcekey="radTreeView" |
| OnClientContextMenuItemClicked="onClientCtxmOperationalClicked" |
| OnClientContextMenuShowing="onClientCtxmOperationalShowing"> |
| <contextmenus> |
| ASP: |
| <telerik:GridBoundColumn DataField="TaskKey" UniqueName="colTaskKey" ReadOnly="true" Display="true" /> |
| C#: |
| protected void grdAssign_UpdateCommand(object sender, GridCommandEventArgs e) |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| int taskKey = Int32.Parse(item["colTaskKey"].Text); |
| if (e.Item is GridGroupHeaderItem) |
| { |
| GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; |
| string grpIndx = item.GroupIndex.ToString(); |
| if (grpIndx.Length >= 5) |
| { |
| if (grpIndx.Substring(grpIndx.Length - 2) == "_0") |
| { |
| DataRowView groupDataRow = (DataRowView)e.Item.DataItem; |
| // Make sure a project exists by checking the Project Id group value |
| if (string.IsNullOrEmpty(groupDataRow.Row["ProjectId"].ToString())) |
| { |
| // Hide the Project grouping |
| item.Visible = false; |
| } |
| else |
| { |
| if (groupDataRow.Row["ReleasedByProject"].ToString().ToUpper() != "TRUE") // (!ois.ReleasedByProject) |
| { |
| HyperLink lnk = new HyperLink(); |
| lnk.ID = "btnProjRelease"; |
| lnk.Text = "Click To Release"; |
| lnk.ToolTip = "Project Release"; |
| lnk.NavigateUrl = "#"; |
| lnk.Attributes["onclick"] = string.Format("return RunProjectRelease('{0}');", groupDataRow.Row["ProductId"].ToString()); |
| lnk.Enabled = _isReleasedByAccounting && _canCompleteSteps; |
| Label lbl = new Label(); |
| lbl.Text = string.Format("Project: {0}: ", groupDataRow.Row["ProjectName"].ToString()); |
| item.DataCell.Controls.Add(lbl); |
| item.DataCell.Controls.Add(lnk); |
| } |
| } |
| } |
| } |
| } |
I have used Telerik's example http://demos.telerik.com/aspnet-ajax/menu/examples/programming/showpath/defaultcs.aspx method to include a hyperlinked showpath / breadcrumb and wish to apply css styling to eg the last item
these are in the last row of a repeater
root > sub1 > sub2 > sub3
Protected void BreadCrumbRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)
{
this.ItemCount.Text = Convert.ToString(this.BreadCrumbRepeater.Items.Count); //show item count in a label on asp page
HyperLink BreadCrumbHyperLink = ((HyperLink)(e.Item.FindControl("BreadCrumbHyperLink")));
if (e.Item.ItemIndex == BreadCrumbRepeater.Items.Count) // I found the item count returns the correct index so need for -1
{
BreadCrumbHyperLink.CssClass = "last";
}
else
{
BreadCrumbHyperLink.CssClass = "middle";
}
}
}
Which dosn't work, if I manually set if (e.Item.ItemIndex == 1) then this will show 0 and 2 as css middle and 1 as css last.
I then thought ok I'll never have more than 5-10 levels deep so I can just manually set it in a nested if statement.
Something along the lines of
if (BreadCrumbRepeater.Items.Count == 2)
{
if (e.Item.ItemIndex == 2)
{
BreadCrumbHyperLink.CssClass = "last";
}
else
{
BreadCrumbHyperLink.CssClass = "middle";
}
}
else if (BreadCrumbRepeater.Items.Count == 1)
{
if (e.Item.ItemIndex == 1)
{
BreadCrumbHyperLink.CssClass = "last";
}
else
{
BreadCrumbHyperLink.CssClass = "middle";
}
}
else if (BreadCrumbRepeater.Items.Count == 0)
{
if (e.Item.ItemIndex == 0)
{
BreadCrumbHyperLink.CssClass = "last";
}
}
Which again didn't work
I then look ed at using a switch case statment
switch (Convert.ToString(BreadCrumbRepeater.Items.Count))
{
case "2":
gredy.Text = "two";
if (e.Item.ItemIndex == 0)
{
BreadCrumbHyperLink.CssClass = "middle";
}
else if (e.Item.ItemIndex == 1)
{
BreadCrumbHyperLink.CssClass = "middle";
}
else if (e.Item.ItemIndex == 2)
{
BreadCrumbHyperLink.CssClass = "last";
}
break;
case "1":
if (e.Item.ItemIndex == 1)
{
BreadCrumbHyperLink.CssClass = "last";
}
else if (e.Item.ItemIndex == 0)
{
BreadCrumbHyperLink.CssClass = "middle";
}
break;
case "0":
if (e.Item.ItemIndex == 0)
{
BreadCrumbHyperLink.CssClass = "last";
}
break;
Which again doesn’t work I know the logic for the switch if statements works because I can use it to set labels values for a test.
So the problem seems to be just applying the style to the correct hyperlink item.
Any suggestions would be helpful
| RadGrid oGrid = new RadGrid(); |
| oGrid.ID = "ProjectGrid"; |
| oGrid.Skin = "WebBlue"; |
| //oGrid.Width = new Unit(100, UnitType.Percentage); |
| oGrid.AutoGenerateColumns = false; |
| oGrid.AllowPaging = true; |
| oGrid.AllowSorting = true; |
| oGrid.ClientSettings.Resizing.AllowColumnResize = true; |
| oGrid.ClientSettings.AllowColumnsReorder = true; |
| //oGrid.MasterTableView.allow |
| oGrid.NeedDataSource += new GridNeedDataSourceEventHandler(oGrid_NeedDataSource); |
| oGrid.MasterTableView.Columns.Clear(); |
| GridButtonColumn Print = new GridButtonColumn(); |
| Print.ButtonType = GridButtonColumnType.ImageButton; |
| Print.ImageUrl = @"\_layouts\wpresources\images\print.gif"; |
| Print.UniqueName = "Print"; |
| Print.CommandName = "Print"; |
| Print.ItemStyle.Width = new Unit(10, UnitType.Pixel); |
| oGrid.MasterTableView.Columns.Add(Print); |
| oGrid.ItemCommand += new GridCommandEventHandler(oGrid_ItemCommand); |
| oGrid.ItemCreated += new GridItemEventHandler(oGrid_ItemCreated); |
| void oGrid_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem dataItem = e.Item as GridDataItem; |
| ImageButton imgbtn1 = dataItem["Print"].Controls[0] as ImageButton; |
| ImageButton imgbtn2 = dataItem["CreateNew"].Controls[0] as ImageButton; |
| ImageButton imgbtn3 = dataItem["MakeActive"].Controls[0] as ImageButton; |
| ImageButton imgbtn4 = dataItem["CopyToClipboard"].Controls[0] as ImageButton; |
| imgbtn1.OnClientClick = String.Format(@"{0}.__doPostBack(""{1}"",""{2}"");return false;", ((RadAjaxManager)FindControl("RadAjaxManager1")), imgbtn1.UniqueID, imgbtn1.CommandArgument); |
| } |
| } |
| Partial Class usercontrols_mainNav |
| Inherits System.Web.UI.UserControl |
| Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| If System.IO.Path.GetDirectoryName(HttpContext.Current.Request.FilePath).ToLower = "score_selector/Default.aspx" Then |
| RadTabStrip1.SelectedIndex = 1 |
| Else |
| RadTabStrip1.SelectedIndex = 0 |
| End If |
| End Sub |
| End Class |