<telerik:GridTemplateColumn HeaderText="Actions" HeaderStyle-Width="125px" ItemStyle-Width="125px"> <ItemTemplate> <fmh:ActionButton runat="server" CommandArgument='<%# Eval("FieldId") %>' ID="abGridTest" OnMenuItemClicked="abGridTest_OnMenuItemClicked" > <ActionItems>
<fmh:ActionItem Text="Example 1" Icon="save" CommandName="test1" /> <fmh:ActionItem IsSeparator="true" /> <fmh:ActionItem Text="Example 2" Icon="edit" CommandName="test2" /> </ActionItems> </fmh:ActionButton> </ItemTemplate></telerik:GridTemplateColumn>public class ActionItem{ public ActionItem() { Visible = true; } public bool IsSeparator { get; set; } public bool Visible { get; set; } public string CommandName { get; set; } public string Icon { get; set; } public string Text { get; set; }}[ParseChildren(true)]public sealed class ActionButton : DataBoundControl, INamingContainer{ [PersistenceMode(PersistenceMode.InnerProperty)] [TemplateContainer(typeof(ActionButton))] public ITemplate ContentTemplate { get; set; } [Bindable(true), DefaultValue("")] public string CommandArgument { get { object o = ViewState[ClientID + "_CommandArgument"]; return o == null ? "0" : o.ToString(); } set { ViewState[ClientID + "_CommandArgument"] = value; } } [MergableProperty(false), PersistenceMode(PersistenceMode.InnerProperty), DefaultValue((string)null)] public Collection<ActionItem> ActionItems { get; set; } public event CommandEventHandler MenuItemClicked; public RadContextMenu ContextMenu { get; set; } public RadButton Button { get; set; } protected override void CreateChildControls() { base.CreateChildControls(); if (ContentTemplate != null) ContentTemplate.InstantiateIn(this); SetupButtonAndContextMenu(); if (ActionItems != null) { foreach (ActionItem actionItem in ActionItems) { RadMenuItem rmi = new RadMenuItem(); SetupMenuItem(actionItem, rmi); rmi.PostBack = true; rmi.Visible = actionItem.Visible; ContextMenu.Items.Add(rmi); } } Controls.Add(Button); Controls.Add(ContextMenu); } private void ContextMenuOnItemClick(object sender, RadMenuEventArgs radMenuEventArgs) { CommandEventArgs commandEventArgs = new CommandEventArgs(radMenuEventArgs.Item.Attributes["CommandName"], CommandArgument); // This is what I *thought* I would need to do, but this isn't working. Wrong binding flags? //typeof (RadButton).InvokeMember("Click", BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, Button, //new object[] {commandEventArgs});
// This works just fine...because I have a reference to the event already
MenuItemClicked.Invoke(this, new CommandEventArgs(radMenuEventArgs.Item.Attributes["CommandName"], CommandArgument)); } private void SetupButtonAndContextMenu() { Button = new RadButton { ID = "Button", CssClass = "Secondary Utility", EnableSplitButton = true, Text = @"Action", AutoPostBack = false, OnClientClicked = "$F.ActionButton.onClientClicked", EnableEmbeddedSkins = false, Skin = "OurSkin", Width = Width }; Button.Icon.SecondaryIconUrl = "/Common/Images/ButtonIcons/DropDownArrow.png"; ContextMenu = new RadContextMenu { ID = "Button_Menu", ExpandDelay = 0, CollapseDelay = 0, EnableEmbeddedSkins = false, Skin = "OurSkin", OnClientItemClicked = "$F.ActionButton.onClientMenuItemClicked" }; ContextMenu.ItemClick += ContextMenuOnItemClick; } private static void SetupMenuItem(ActionItem actionItem, RadMenuItem rmi) { if (actionItem.IsSeparator) { rmi.IsSeparator = true; return; } if (String.IsNullOrEmpty(actionItem.Text)) { throw new ArgumentNullException("Text", @"ActionItem.Text is a required argument."); } rmi.Text = actionItem.Text; if (!String.IsNullOrEmpty(actionItem.Icon)) rmi.ImageUrl = "/Common/Images/LinkButtonIcons/" + actionItem.Icon + ".png"; rmi.Attributes["CommandName"] = !String.IsNullOrEmpty(actionItem.CommandName) ? actionItem.CommandName : actionItem.Text.RemoveSpaces(); }}$F.ActionButton = { onClientClicked: function (sender, eventArgs) { // Find the context menu and remove animations var contextMenu = window.$find(sender.get_id() + '_Menu'); // Remove the animation so that it shows/hides immediately contextMenu._slide._collapseAnimation.set_type(window.Telerik.Web.UI.AnimationType.None); contextMenu._slide._expandAnimation.set_type(window.Telerik.Web.UI.AnimationType.None); // If it is already visible, just hide it. For some reason the contextMenu.get_visible() returns false, hence the dom check. if (contextMenu.get_contextMenuElement().style.display == 'block') { contextMenu.hide(); return; } // get the position of the Button that was clicked var currentLocation = window.$telerik.getBounds(sender.get_element()); // Calculate position to show the context menu var contextMenuLeft = currentLocation.x; if (contextMenu.get_attributes().getAttribute('RTL') == 't') { var contextMenuWidth = $('#' + contextMenu.get_element().id + '_detached').width(); if (contextMenuWidth == 0) { // reposition off screen so we can calculate the width. Can't do that until it has been rendered once. contextMenu.showAt(-1000, -1000); contextMenuWidth = $('#' + contextMenu.get_element().id + '_detached').width(); } contextMenuLeft = currentLocation.x + currentLocation.width - contextMenuWidth; } var contextMenuTop = currentLocation.y + currentLocation.height; // Show the context menu contextMenu.showAt(contextMenuLeft, contextMenuTop); }, onClientMenuItemClicked: function (sender, eventArgs) { // Is there a function defined? var clientFunction = eventArgs.get_item().get_attributes().getAttribute("ClientFunction"); if (!clientFunction || clientFunction.trim() == '') return; // Is this a real function? var fn = eval(clientFunction); if (!fn) return; // Build arguments to pass including command name and command argument var args = new Object; args.commandName = eventArgs.get_item().get_attributes().getAttribute("CommandName"); args.commandArgument = eventArgs.get_item().get_attributes().getAttribute("CommandArgument"); // Fire off the function passing arguments fn(sender, args); }I have a web part that load user control with the RadScheduler and take a lot time to load the page. Does somebody has any idea why the page take too long?
I did everything in the following documents
Chrome 5 secs
I have expended three days in do everything is in the web.
Regards
HANK
<telerik:GridTemplateColumn DataField="xx" HeaderText="xx" UniqueName="xx">
<ItemTemplate>
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" MaxFileInputsCount="1" />
</ItemTemplate>
</telerik:GridTemplateColumn>
So that when the grid displays 10 rows, it will have 10 asyncupload control on the screen. Then the user can select 10 different files into the 10 asyncupload control. And with a button press (outside of the grid) which will cause post back. And then I would like to somehow have access to the "fileuploaded" event fires and then able to use the .saveas method to save all 10 file (with manipulated filename) to a folder.
I tried to to add onclientFileUploaded="FileUploaded" and then in the code behind
Protected sub FileUploaded(blah)
But when ran, it said it FileUploaded function not exist. I assume that is because the control is in itemtemplate, therefore it can not access it.
Any idea? Or is this not possible?
Thx!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)If Not IsPostBack Then RadAjaxManager.GetCurrent(Me.Page).ClientEvents.OnRequestStart = "onRequestStart"End ifEnd Sub
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server" > <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </telerik:RadAjaxManagerProxy> <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" AutoGenerateColumns="false" Width="1000" GridLines="Both" Skin="Sunset" ShowGroupPanel="true" AllowFilteringByColumn="False" AllowPaging="True" AllowSorting="True" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" Height="500px" OnNeedDataSource="RadGrid1_NeedDataSource"> <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true"> </ExportSettings> <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="True"> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> <Resizing AllowColumnResize="true" AllowRowResize="true" /> </ClientSettings> <MasterTableView DataKeyNames="ClientAlertID" CommandItemDisplay="Top"> <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" ShowAddNewRecordButton=false /> <DetailTables> <telerik:GridTableView Name="Events" Width="100%" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" HierarchyDefaultExpanded="true" > <HeaderStyle CssClass="InnerHeaderStyle" /> <ItemStyle CssClass="InnerItemStyle" /> <AlternatingItemStyle CssClass="InnerAlernatingItemStyle" /> <FilterItemStyle CssClass="InnerHeaderStyle" /> <PagerStyle CssClass="InnerHeaderStyle" /> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="OpenDate" ItemStyle-Width=135 HeaderStyle-Width="135" FilterControlWidth="100" FilterControlAltText="Filter OpenDate column" HeaderText="Open Date" ReadOnly="True" SortExpression="OpenDate" UniqueName="OpenDate" /> <telerik:GridBoundColumn DataField="device_vendor" ItemStyle-Width=75 HeaderStyle-Width="75" FilterControlWidth="45" FilterControlAltText="Filter device_vendor column" HeaderText="Device Vendor" ReadOnly="True" SortExpression="device_vendor" UniqueName="device_vendor" /> <telerik:GridBoundColumn DataField="device_type" ItemStyle-Width="75" HeaderStyle-Width="75" FilterControlWidth="45" FilterControlAltText="Filter device_type column" HeaderText="Device Type" ReadOnly="True" SortExpression="device_type" UniqueName="device_type" /> <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Description" ReadOnly="True" SortExpression="Description" UniqueName="Description" /> <telerik:GridBoundColumn DataField="event_name" ItemStyle-Width="75" HeaderStyle-Width="75" FilterControlWidth="45" FilterControlAltText="Filter event_name column" HeaderText="Correlation Rule" ReadOnly="True" SortExpression="event_name" UniqueName="event_name" /> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> <HeaderStyle BackColor="Brown"></HeaderStyle> </telerik:GridTableView> </DetailTables> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <GroupByExpressions> <telerik:GridGroupByExpression> <SelectFields> <telerik:GridGroupByField FieldAlias="AlertType" FieldName="AlertType"></telerik:GridGroupByField> </SelectFields> <GroupByFields> <telerik:GridGroupByField FieldName="AlertType"></telerik:GridGroupByField> </GroupByFields> </telerik:GridGroupByExpression> </GroupByExpressions> <Columns> <telerik:GridBoundColumn DataField="ClientAlertID" ItemStyle-Width=50 HeaderStyle-Width="50" FilterControlAltText="Filter ClientAlertID column" HeaderText="Alert ID" ReadOnly="True" AllowFiltering="false" SortExpression="ClientAlertID" UniqueName="ClientAlertID" /> <telerik:GridBoundColumn DataField="AlertType" ItemStyle-Width=150 FilterControlWidth="120" HeaderStyle-Width="150" FilterControlAltText="Filter AlertType column" HeaderText="Alert Type" ReadOnly="True" AllowFiltering="false" SortExpression="AlertType" UniqueName="AlertType" /> <telerik:GridBoundColumn DataField="Priority" ItemStyle-Width=75 FilterControlWidth="45" HeaderStyle-Width="75" FilterControlAltText="Filter Priority column" HeaderText="Priority" ReadOnly="True" AllowFiltering="false" SortExpression="Priority" UniqueName="Priority" /> <telerik:GridBoundColumn DataField="CreationTime" ItemStyle-Width=135 FilterControlWidth="100" HeaderStyle-Width="135" FilterControlAltText="Filter CreationTime column" HeaderText="Creation Time" ReadOnly="True" AllowFiltering="false" SortExpression="CreationTime" UniqueName="CreationTime" /> <telerik:GridBoundColumn DataField="Dest" FilterControlAltText="Filter Dest column" HeaderText="Dest IP" ReadOnly="True" AllowFiltering="false" SortExpression="Dest" UniqueName="Dest" /> <telerik:GridBoundColumn DataField="Source" FilterControlAltText="Filter Source column" HeaderText="Source IP" ReadOnly="True" AllowFiltering="false" SortExpression="Source" UniqueName="Source" /> <telerik:GridBoundColumn DataField="EventName" FilterControlAltText="Filter EventName column" HeaderText="Event Name" ReadOnly="True" AllowFiltering="false" SortExpression="EventName" UniqueName="EventName" /> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> </MasterTableView> <GroupingSettings ShowUnGroupButton="true" /> <FilterMenu EnableImageSprites="False"></FilterMenu> </telerik:RadGrid> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" InitialDelayTime="500" > </telerik:RadAjaxLoadingPanel> <script type="text/javascript"> function onRequestStart(sender, args) { if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 || args.get_eventTarget().indexOf("ExportToWordButton") >= 0 || args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) { args.set_enableAjax(false); } }</script></asp:Content>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> <Windows> <telerik:RadWindow runat="server" InitialBehaviors="Maximize" RestrictionZoneID="div1" VisibleStatusbar="false" KeepInScreenBounds="true"> <ContentTemplate> Content Will go herer </ContentTemplate> </telerik:RadWindow> </Windows> </telerik:RadWindowManager><telerik:RadPanelBar runat="server" ID="rpbReconciliationSummaryInquiry" Height="300"
Font-Bold="True" Font-Size="Large" ExpandMode="SingleExpandedItem" OnClientItemExpand="OnClientItemExpand"
Width="300" >
<Items>
<telerik:RadPanelItem Expanded="False" Text="Dept / Class / Vendor / Location" Value="DCVLTop" Font-Bold="True" ForeColor="White">
<Items>
<telerik:RadPanelItem Value="DCVL" Text="">
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="lblDept" runat="server" Text="Dept:" CssClass="label" />
</td>
<td>
<telerik:RadComboBox ID="cmbDeptDCVL" runat="server" OnClientBlur="OnClientBlurHandler"
AllowCustomText="false" EnableLoadOnDemand="true" MarkFirstMatch="true" Width="100"
TabIndex="6" DropDownWidth="350px" AutoPostBack="True" >
<HeaderTemplate>
<table>
<tr>
<td width="80"> Dept </td>
<td width="220">Description </td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr align="left">
<td width="20">
<asp:CheckBox runat="server" ID="chkSingleDeptDCVL" Text="" />
</td>
<td width="80" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptId%> </td>
<td width="220" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptShortDesc%> </td>
</tr>
</table>
</ItemTemplate>
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblClass" runat="server" Text="Class:" CssClass="label" />
</td>
<td>
<telerik:RadComboBox ID="cmbClassDCVL" runat="server" OnClientBlur="OnClientBlurHandler"
AllowCustomText="false" EnableLoadOnDemand="true" MarkFirstMatch="true" Width="100"
TabIndex="6" DropDownWidth="350px">
<HeaderTemplate>
<table>
<tr>
<td width="80"> Class </td>
<td width="250">Description </td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr align="left">
<td width="20">
<asp:CheckBox runat="server" ID="chkSingleClassDCVL" Text="" />
</td>
<td width="80" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplDptClsInfo).ClassId%> </td>
<td width="250" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplDptClsInfo).ClassShortDesc%></td>
</tr>
</table>
</ItemTemplate>
<CollapseAnimation Duration="200" Type="OutQuint" />
</telerik:RadComboBox>
</td>
</tr>
