if
(!IsPostBack)
{
//Important: first Add column to the collection, Then set properties
GridBoundColumn boundCol = new GridBoundColumn();
this.RadGrid1.MasterTableView.Columns.Add(boundCol);
boundCol.DataField = "CompanyName";
boundCol.HeaderText = "Company";
}
etc.
This new bound column gets added just fine, however, all of the other columns from the DataTable are added as well.
I've also noticed, that the code I have in my "ColumnCreated" event does not seem to fire on the columns I add dynamically. I have a switch statement that checks the header text to decide what the background color should be set to. This code works just fine on the other columns.
Any ideas what is causing this behavior? Also, if I'm going to long way about either one of these two issues (Setting a specific column order, and conditionally applying a column background color) please let me know. Thank you!
I am inexperienced with Telerik so I apologize if this is just a programmer issue.
Still if someone can easily see the solution please let me know.
My project uses a master page having a layout similar to this Telerik example:
http://www.telerik.com/demos/aspnet/prometheus/Controls/Examples/Integration/FileBrowser/DefaultCS.aspx
I want the menu on top and two panes below. The left pane has a tree view. There is a splitter bar between the left pane and right pane.
It looks like this:
---Menu--------------------------------------
Left-pane-with-tree-view | Right-pane-with-content
Everything worked fine when I used RadControls for Asp.Net Ajax.
But after I installed RadControls for Asp.Net Ajax SP1 (and changed nothing else)
I get a layout like:
---Menu---- Left-pane-with-tree-view | Right-pane-with-content
Where the menu is to the left of the left pane instead of on top.
Included below is the aspx of the master page
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="BalancedFlowSite.Master.cs" Inherits="BalancedFlow.WebSite3._5.MasterPages.BalancedFlowSite" %>
<%@ Register TagPrefix="rad" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Balanced Flow</title>
<link rel="stylesheet" type="text/css" href="../Styles/site.css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body style="background: white url('../images/MenuItemBackground.gif') repeat-x;">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<rad:RadAjaxManager ID="RadAjaxManagerMain" runat="server">
</rad:RadAjaxManager>
<rad:RadAjaxLoadingPanel ID="RadAjaxLoadingPanelMain" runat="server" Height="75px" Width="75px">
<asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/RadControls/Ajax/Skins/Default/Loading.gif" />
</rad:RadAjaxLoadingPanel>
<div class="wrapper1" style="height: 100%">
<script type="text/javascript">
function clickHandler(sender, eventArgs)
{
if (!eventArgs.Item == null)
{
if (eventArgs.Item.Text == "BF Help")
{
radopen(null,"Window1");
//Cancel the postback
return false;
}
}
}
</script>
<rad:RadMenu ID="RadMenuMain" OnClientItemClicking="clickHandler" runat="server"
Skin="Web20" CausesValidation="false">
</rad:RadMenu>
<rad:RadWindowManager ID="RadWindowManager1" runat="server">
<Windows>
<rad:RadWindow ID="Window1" runat="server" NavigateUrl="~/Help/index.html" />
</Windows>
</rad:RadWindowManager>
<rad:RadSplitter ID="RadSplitterMain" runat="server" Height="100%" EnableClientDebug="False"
Width="100%" BorderSize="0" BorderStyle="None">
<rad:RadPane ID="RadPaneLeft" runat="server" Width="100px">
<rad:RadSplitter ID="SplitterTreeView" runat="server" Orientation="Horizontal">
<rad:RadPane ID="RadSlidingPaneSCS" runat="server" Width="263px" Scrolling="Both">
<rad:RadTreeView ID="RadTreeViewSection" runat="server" Height="100%" Skin="Web20"
AutoPostBack="True" CausesValidation="false">
<Nodes>
<rad:RadTreeNode runat="server" Text="Supply Net" />
</Nodes>
</rad:RadTreeView>
</rad:RadPane>
</rad:RadSplitter>
</rad:RadPane>
<rad:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="Forward" />
<rad:RadPane ID="RadPaneMain" runat="server" Width="100%" Scrolling="Y">
<asp:ContentPlaceHolder ID="ContentPlaceHolderMainArea" runat="server">
</asp:ContentPlaceHolder>
</rad:RadPane>
</rad:RadSplitter>
</div>
<asp:Literal ID="labelMessage" runat="server" EnableViewState="false"></asp:Literal>
</form>
</body>
</html>
| <telerik:RadSlidingPane ID="ColumnsSlider" runat="server" Width="200" Scrolling="None" |
| Title="Add Columns" EnableDock="false"> |
| <div id="attributeGrid" runat="server" style="position:absolute; top:19px; left:5px; right:-2px; bottom:32px; overflow:scroll;"> |
| <telerik:RadGrid ID="attributeList" runat="server" Skin="Office2007" GridLines="None" |
| Width="176px" Height="100%" AutoGenerateColumns="false" AllowMultiRowSelection="true"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="CheckBoxSelectColumn"> |
| <ItemTemplate> |
| <asp:CheckBox ID="attributeCheckbox" runat="server" AutoPostBack="true" OnCheckedChanged="attributeCheckbox_CheckChanged" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Name" HeaderStyle-Height="0" |
| DataType="System.String" /> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </div> |
| <div id="attributeBtn" runat="server" style="position:absolute; left:0px; right:0px; bottom:0px; height:32px;"> |
| <center> |
| <asp:ImageButton ID="btnApplyChanges" runat="server" ImageUrl="Images/btnApplyChanges.gif" OnClick="btnApplyChanges_Click" /> |
| </center> |
| </div> |
| </telerik:RadSlidingPane> |
Hi
My tree control handles the NodeExpand event on the server. It also handles the client NodeExpanding event.
If the user clicks the expand icon on a tree node, I thought it would be efficient to check on the client side to see whether I have already got child nodes. If I have child nodes then there is no need to do a postback. However, I do still want the node to expand as the client has all the node data.
My problem is - How do I cancel the postback, but allow the node to expand?
Thanks,
Martin
| function onClientNodeExpanding(sender, args) |
| { |
| var childrencount = args.get_node().get_nodes().get_count(); |
| if (childrencount > 0) |
| { |
| //don't cause a post back as we already have the children. However, we do actually want to expand |
| args.set_cancel(true); |
| } |
| } |