I am trying to open a rad window by selecting an option in the context menu that should be displayed on the right click of rad grid row. I tried opening rad window from code behind but it didnt worked so tried opening it from javascript. What is happening that it didnt show for the first time when i right click the context menu item. However it opens after every next click.Also i m passing the title and id from the grid to the window,i obsered that it shows the title of the previous clicked row and not the current row on show.
here is the code behind:
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
{
int radGridClickedRowIndex;
Label labeltitle;
radGridClickedRowIndex =
Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);
string SignpostId= RadGrid1.Items[radGridClickedRowIndex].Cells[4].Text;
GridDataItem current =RadGrid1.Items[radGridClickedRowIndex];
labeltitle = (
Label)current["Ref"].FindControl("Label4");
string STitle = labeltitle.Text;
if (e.Item.Text == "Add Criteria")
{
string arg1 = "AwardId=" + ParentPage.iaward_id;
string arg2 = "&SignpostId=" + SignpostId;
string arg3 = "&STitle=" + STitle;
e.Item.Attributes[
"onclick"] = "return AddCriteria('" + arg1 + "','" + arg2 + "','" + arg3 + "')";
}
if (e.Item.Text == "Edit Criteria")
{
string arg1 = "AwardId=" + ParentPage.iaward_id;
string arg2 = "&SignpostId=" + SignpostId;
string arg3 = "&STitle=" + STitle;
e.Item.Attributes[
"onclick"] = "EditCriteria('" + arg1 + "','" + arg2 + "','" + arg3 + "')";
}
}
and the aspx page for this is:
<%
@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%
@ Control Language="c#" AutoEventWireup="false" Codebehind="signposts.ascx.cs" Inherits="ecms.custom.cmatters.learningportal.awards.controls.signposts" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<
asp:Label Runat="server" ID="Label1" />
<
asp:label id="SignpostID" Visible="False" runat="server"></asp:label>
<
asp:label id="uiSignpostID" Visible="False" runat="server"></asp:label>
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
<script type="text/javascript">
function RowContextMenu(sender, eventArgs)
{
var menu = $find("<%=RadMenu1.ClientID %>");
var evt = eventArgs.get_domEvent();
if(evt.target.tagName == "INPUT" || evt.target.tagName == "A")
{
return;
}
var index = eventArgs.get_itemIndexHierarchical();
document.getElementById(
"radGridClickedRowIndex").value = index;
sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(),
true);
menu.show(evt);
evt.cancelBubble =
true;
evt.returnValue =
false;
if (evt.stopPropagation)
{
evt.stopPropagation();
evt.preventDefault();
}
return true;
}
function AddCriteria(msgId1,msgid2,msgid3)
{
var oWnd = radopen("SelectCriteria.aspx/?" + msgId1 + msgid2 + msgid3, "RadWindow1");
oWnd.visibleonpageload =
true;
oWnd.setSize(800,800);
}
function EditCriteria(msgId1,msgid2,msgid3)
{
var oWnd = radopen("EditCriteria.aspx/?" + msgId1 + msgid2 + msgid3, "RadWindow1");
oWnd.VisibleOnPageLoad =
true;
oWnd.setSize(800,800);
}
</script>
</telerik:RadScriptBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="AjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadMenu1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadMenu1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="AjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadMenu1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<Telerik:RadWindowManager VisibleOnPageLoad="true" DestroyOnClose="true" Modal ="true" ID="RadWindowManager1" runat="server" />
<input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
<telerik:RadGrid id="RadGrid1" width="595" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection=true
Gridlines="None" AllowPaging="True" ShowFooter="False" PageSize="10" EnableAJAX="True" AutoGenerateColumns="False"
EnableAJAXLoadingTemplate="False" LoadingTemplateTransparency="50" AllowAutomaticDeletes="True"
OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" ShowStatusBar="false">
<PagerStyle Mode="NextPrevAndNumeric" CssClass="RadListPager"></PagerStyle>
<ClientSettings>
<ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
<SELECTING AllowRowSelect="true" />
</ClientSettings>
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" DataKeyNames="signpost_id">
<CommandItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# IsEditable() %>'><img style="border:0px" alt="" src="<%# ParentPage.CMSThemeFolder%>/gridskin/AddRecord.gif" /> Add Signpost </asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid" Visible='<%# IsEditable() %>'><img style="border:0px" alt="" src="<%# ParentPage.CMSThemeFolder%>/gridskin/Refresh.gif" /> Refresh </asp:LinkButton>
<br />
</Columns>
</CommandItemTemplate>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UpdateImageUrl="img/Update.gif" EditImageUrl="img/Edit.gif" InsertImageUrl="img/Insert.gif" CancelImageUrl="img/Cancel.gif" UniqueName="EditCommandColumn">
<ItemStyle HorizontalAlign="Center" />
</telerik:GridEditCommandColumn>
<telerik:GridClientDeleteColumn ConfirmText="Delete this item?" ButtonType="ImageButton" ImageUrl="img/Delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" />
</telerik:GridClientDeleteColumn>
<telerik:GridBoundColumn HeaderText="ID" Groupable="False" DataField="signpost_id" ReadOnly="True" Visible="False" Resizable="True" AllowFiltering="False" UniqueName="signpost_id" Reorderable="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Ref" Groupable="False" DataField="signpost_ref" ReadOnly="True" Visible="True" Resizable="True" AllowFiltering="False" UniqueName="signpostref" Reorderable="False"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Title" UniqueName="Ref" EditFormColumnIndex="1">
<ItemTemplate>
<asp:Label runat="server" ID="Label4" Text='<%# DataBinder.Eval(Container.DataItem,"signpost_title") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn2" HeaderText="Enabled">
<HeaderStyle ></HeaderStyle>
<ItemStyle Height="25px" HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<img src="<%# GetEnabledImage(DataBinder.Eval(Container.DataItem, "enabled")) %>">
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings UserControlName="controls/signpostdetail.ascx" EditFormType="WebUserControl">
</EditFormSettings>
<ExpandCollapseColumn ButtonType="ImageButton" Visible="False" UniqueName="ExpandColumn">
<HeaderStyle Width="19px"></HeaderStyle>
</ExpandCollapseColumn>
</MasterTableView>
</telerik:RadGrid>
<telerik:radcontextmenu ID="RadMenu1" runat="server" Skin="Vista"
OnItemClick="RadMenu1_ItemClick" style="top: 415px; left: 10px">
<Items>
<telerik:RadMenuItem Text="Add Criteria" />
<telerik:RadMenuItem IsSeparator="true"/>
<telerik:RadMenuItem Text="Edit Criteria" />
</Items>
</telerik:radcontextmenu>
<
asp:Literal id="DBConnectionString" runat="server" Visible="False" />
Kindly help on how to open rad window on the click of context menu by passing paramaters to the rad window. I am new to teleik and have tried all combinations that i know.
Also wanted to share that i am able to open the rad window from code behind on the rad tree view context menu click. The code behind for the code its working fine in tree view is :
protected void ContextClicked(object sender, RadTreeViewContextMenuEventArgs e)
{
string s = String.Format("You clicked the <b>'{0}'</b> context item for node <b>'{1}'</b>", e.Node.ContextMenuID, e.Node.Text);
string sSelectedText = e.MenuItem.Text;
ParentPage.GeneralFunctions.AssignLabelText(Page.Controls,
"StatusText", s);
ViewUnitsPanel.Visible =
false;
if (sSelectedText == "Add Units")
{
string arg1 = "AwardBodyId=" + ParentPage.iawardbody_id + "&GroupId= " + e.Node.Value + "&Title= " + e.Node.Text + "&Action=Add";
Telerik.Web.UI.
RadWindow newwindow = new Telerik.Web.UI.RadWindow();
newwindow.ID = "SearchWnd";
newwindow.VisibleOnPageLoad = true;
newwindow.Width = 1100;
newwindow.Height = 800;
newwindow.NavigateUrl = "~/custom/cmatters/learningportal/awards/GroupUnits.aspx?" + arg1;
RadWindowManager1.Windows.Add(newwindow);
ViewUnitsPanel.Visible =
true;
}
.}
However when i use the above code to open window on the context click of rad grid from code behind nothing happens. The ASP.Net version is 2.0 and Telerik version is :RadControls for ASPNET AJAX Q1 2008
Kindly help.Many thanks.
Best Regards
Ash