<MasterTableView TableLayout="Fixed" HierarchyDefaultExpanded="true" CommandItemDisplay="Top" EnableNoRecordsTemplate="true"> <Columns> ...... </Columns> <DetailTables> <telerik:GridTableView DataKeyNames="AccountID" Width="100%" DataMember="FundBalance" HierarchyLoadMode="ServerBind"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="AccountID" MasterKeyField="AccountID" /> </ParentTableRelation> <Columns> <telerik:GridBoundColumn DataField="AccountID" UniqueName="AccountID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FundTypeID" UniqueName="FundTypeID"> </telerik:GridBoundColumn> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="BeginBalanceShares" DataField="BeginBalanceShares"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="BeginPrice" DataField="BeginPrice" > </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="BeginBalanceDollars" DataField="BeginBalanceDollars"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="EndBalanceShares" DataField="EndBalanceShares"> </telerik:GridBoundColumn> </Columns> </telerik:GridTableView> </DetailTables> </MasterTableView>My datasource is defined as:public static DataTable ListByPlanAndDateRange(int planID, DateTime beginDate, DateTime endDate) { DataSet ds = DBRoutines.wusp_PeriodSummaryByFund_ListByPlanAndDateRange(planID, beginDate, endDate); ds.Tables[0].TableName = "FundBalance"; ds.Tables[1].TableName = "SourceContribution"; ds.Relations.Add("BalanceRelation", ds.Tables[0].Columns[Fields.FundID], ds.Tables[1].Columns[Fields.FundID], false); return ds.Tables[0]; }Dear all,
I have a user control with (RadAjaxProxyManager) and the (RadAjaxManager) on the ASP.NET page where the user control lives
I need to put the below JS function isnide .JS file not on the page directly. I want to get rid of the RadCodeBlock tag as well I'm combining JS in files. I dont want to have inline JS functions on ASP.NET pages.
<rad:RadCodeBlock ID="RadCodeBlock1" runat="server"><script type="text/javascript"> function refreshAttachmentGrid(arg) {$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RefreshAttachment");}</script></rad:RadCodeBlock>
The code works fine, all I need is to move it to JS file.
Thanks in advance.
Taiseer
2011.2.712.35 but am still having this issue..It works fine in firefox,chrome but not in IE8...
Can someone please help me with this.
Thanks
Hello everyone and special thanks to Princy!
I am using a Radgrid with a Radwindow on Editing , you can see all about it in “Demo/Asp.Net Ajax/Window/Edit Dialog For RadGrid”
I tried it to customize it in my Project logic and every thing is fine when I use the same structure(DefaultCS.aspx, and code behind and EditForm and its codebehind).
But I am using a UserControl instead of aspx file ,as follow :
Root
.
.
.
Folder :Usercontrols
ChargePanel.ascx(Instead of DefaultCS.aspx)[Inherited from SiteMasterpage]
EditForm.aspx
SiteMasterPage.master
When I click On Edit Button everything is true still, and works fine ,and the Grid will be updated after closing windows with some Java Script Code,after do that if I tend to edit another row when I click the Edit button It will raise an error!
Microsoft JScript runtime error: 'null' is null or not an object
Here is my Code,I have tried to find a solution from Many posts but I didn’t find anything to help me…
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ChargePanelCS.ascx.cs" Inherits="UserControls_ChargePanel" %><telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"> <style type="text/css"> .orderText { font: normal 12px Arial,Verdana; margin-top: 6px; } .expandImage { display: inline-block; background-image: url('<%= Page.ResolveUrl("~/Common/styles09/sprite09.gif")%>'); background-position: -596px -1191px; background-repeat: no-repeat; width: 15px; height: 15px; } * html .expandImage { background-position: -596px -1194px; } * + html .expandImage { background-position: -596px -1194px; } </style></telerik:RadCodeBlock><telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function ShowEditForm(id, rowIndex) { var grid = $find("<%= RadGrid1.ClientID %>"); var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); grid.get_masterTableView().selectItem(rowControl, true); window.radopen("../UserControls/EditFormCS.aspx?PanelId=" + id, "UserListDialog"); return false; } function ShowInsertForm() { window.radopen("../UserControls/EditFormCS.aspx", "UserListDialog"); return false; } function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); } } function RowDblClick(sender, eventArgs) { window.radopen("../UserControls/EditFormCS.aspx?PanelId=" + eventArgs.getDataKeyValue("PanelId"), "UserListDialog"); } </script></telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadGrid ID="RadGrid1" runat="server" CssClass="myRadGrid" AllowPaging="true" AllowSorting="true" OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="10" Font-Names="Tahoma" dir="rtl" AllowFilteringByColumn="true" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCreated="RadGrid1_ItemCreated"> <ExportSettings IgnorePaging="true" OpenInNewWindow="true"> <Pdf PageHeight="297mm" PageWidth="210mm" PageTitle="SushiBar menu" /> </ExportSettings> <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" TableLayout="Auto" Font-Names="Tahoma" DataKeyNames="PanelId" EditMode="PopUp"> <%--<EditFormSettings InsertCaption="ركورد جديد" CaptionFormatString="ويرايش" CaptionDataField="PanelId" PopUpSettings-Modal="true" FormCaptionStyle-Font-Names="Tahoma" EditColumn-HeaderStyle-Font-Names="Tahoma" />--%> <CommandItemTemplate> <div style="padding: 5px 5px;" dir="rtl"> <asp:LinkButton ID="LinkButton4" runat="server" Font-Names="Tahoma" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Icons/Refresh.gif" />به روزآوري اطلاعات</asp:LinkButton> </div> </CommandItemTemplate> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn AllowSorting="true" DataField="PanelName" HeaderText="نام پنل" SortExpression="PanelName" UniqueName="PanelName" ColumnEditorID="GridTextBoxColumn"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="رده بندي ارسال"> <ItemTemplate> <telerik:RadRating dir="rtl" ID="RadRating1" runat="server" AutoPostBack="true" Value='<%# Convert.ToDouble(Eval("Used_Charges_Send"))/100000 %>' OnRate="RadRating1_Rate" ReadOnly="true" Precision="Item" ItemCount="10" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn AllowSorting="true" DataField="N_Charges_Send" HeaderText="شارژ ارسال" SortExpression="N_Charges_Send" UniqueName="N_Charges_Send" ItemStyle-CssClass="grid_txt_NO" ColumnEditorID="GridTextBoxColumn"> </telerik:GridBoundColumn> <telerik:GridBoundColumn AllowSorting="true" DataField="Fake_Charges_Send" HeaderText="شارژ اضطراري" SortExpression="Fake_Charges_Send" UniqueName="Fake_Charges_Send" ItemStyle-CssClass="grid_txt_NO" ColumnEditorID="GridTextBoxColumn"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn UniqueName="TemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLink" runat="server" ToolTip="افزايش شارژ" ImageUrl="../Images/Icons/Credit.png" Text="Charge"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <PagerStyle Mode="NumericPages" /> <EditFormSettings ColumnNumber="3" CaptionDataField="PanelId" CaptionFormatString="ويرايش اطلاعات" InsertCaption="" FormCaptionStyle-Font-Names="Tahoma" FormStyle-Font-Names="Tahoma"> <FormTableItemStyle Wrap="True"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="5" BorderColor="Yellow" CellPadding="3" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" Font-Names="Tahoma" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="ثبت " UpdateText="ويرايش" UniqueName="EditCommandColumn1" CancelText="لغو "> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" OnClientClose="refreshGrid" > <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px" Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> </Windows> </telerik:RadWindowManager> <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumn" runat="server" TextBoxStyle-CssClass="GridTextBoxColumnEditor" /> <asp:Label ID="Label1" runat="server" Width="410px"></asp:Label> </div> <!-- content end --> </form></body></html>protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink"); editLink.Attributes["href"] = "#"; editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PanelId"], e.Item.ItemIndex); } }protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument == "Rebind") { RadGrid1.MasterTableView.SortExpressions.Clear(); RadGrid1.MasterTableView.GroupByExpressions.Clear(); RadGrid1.Rebind(); } else if (e.Argument == "RebindAndNavigate") { RadGrid1.MasterTableView.SortExpressions.Clear(); RadGrid1.MasterTableView.GroupByExpressions.Clear(); RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1; RadGrid1.Rebind(); } }<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditFormCS.aspx.cs" Inherits="UserControls_EditFormCS" %><!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>Edit dialog</title></head><body> <form id="form1" runat="server"> <div> <script type="text/javascript"> function CloseAndRebind(args) { GetRadWindow().BrowserWindow.refreshGrid(args); GetRadWindow().close(); } function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) return oWindow; } function CancelEdit() { GetRadWindow().close(); } function onError(input, args) { var message = "Invalid character: "; message += "accepts only numberic values."; document.getElementById("numInput").innerHTML = args.get_inputText(); document.getElementById("numErrorOut").innerHTML = message; } function onKeyPress(input, args) { document.getElementById("numInput").innerHTML = ""; document.getElementById("numErrorOut").innerHTML = ""; } function Close() { GetRadWindow().Close(); } </script> <asp:ScriptManager ID="ScriptManager2" runat="server" /> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" /> <br /> <br /> <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" Type="Number" NumberFormat-DecimalDigits="0"> <ClientEvents OnError="onError" OnKeyPress="onKeyPress"></ClientEvents> </telerik:RadNumericTextBox> <asp:Button runat="server" Text="Submit" ID="btnSubmit" OnClick="Unnamed1_Click" /> <asp:Button runat="server" Text="Reset" ID="btnReset" OnClick="btnReset_Click" Visible="false" /> </div> <asp:Label ID="Label1" runat="server" Width="410px"></asp:Label> <div class="module" style="width: 448px; clear: both;"> <table cellpadding="4" cellspacing="0" width="100%"> <tbody> <tr> <td> <span id="numInput"></span> </td> <td> <span id="numErrorOut" style="color: Red"></span> </td> </tr> </tbody> </table> </div> </form></body></html>protected override void OnInit(EventArgs e) { base.OnInit(e); this.Page.Title = "Editing record"; }protected void btnSubmit_Click(object sender, EventArgs e) { //Some Code here Label1.Text = "<script type='text/javascript'>Close()</" + "script>"; } } protected void btnReset_Click(object sender, EventArgs e) { /SomeCode here }<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm9.aspx.cs" Inherits="WebApplication3.WebForm9" Trace="false" %><%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %><!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></title></head><body class="BODY"> <form runat="server" id="mainForm" method="post"> <telerik:RadScriptManager ID="RadScriptManager" runat="server"></telerik:RadScriptManager> <!-- content start --> <!-- Rad Ajax Manager --> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <div id="menu" style="height:30px; margin-top:10px;"> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem>customers</asp:ListItem> <asp:ListItem>orders</asp:ListItem> </asp:DropDownList> </div> <br /> <div id="DivGrid1" style="height:200px; margin-top:10px;" > <telerik:RadGrid ID="RadGrid1" runat="server" > </telerik:RadGrid> </div> <!-- content end --> </form></body></html>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Configuration;using System.Data.SqlClient;using Telerik.Web.UI;namespace WebApplication3{ public partial class WebForm9 : System.Web.UI.Page { myListview pageGrid = new myListview(); List<myListviewColumn> gridColumn = new List<myListviewColumn>(); protected void Page_Init(object sender, System.EventArgs e) { Grid1_PageInit(); } private void Grid1_PageInit() { RadGrid1.Skin = "Office2010Blue"; this.RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource); RadGrid1.Width = Unit.Percentage(100); RadGrid1.AllowPaging = true; RadGrid1.GroupingEnabled = false; RadGrid1.ShowGroupPanel = false; RadGrid1.ShowStatusBar = true; RadGrid1.AllowMultiRowSelection = true; RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; RadGrid1.PagerStyle.AlwaysVisible = true; RadGrid1.ClientSettings.AllowDragToGroup = true; RadGrid1.ClientSettings.Selecting.AllowRowSelect = true; RadGrid1.ClientSettings.AllowColumnsReorder = true; RadGrid1.ClientSettings.AllowKeyboardNavigation = true; RadGrid1.ClientSettings.Scrolling.AllowScroll = true; RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = true; RadGrid1.ClientSettings.Scrolling.ScrollHeight = Unit.Percentage(100); RadGrid1.ClientSettings.Resizing.AllowColumnResize = true; RadGrid1.ClientSettings.Resizing.EnableRealTimeResize = true; RadGrid1.ClientSettings.Resizing.ResizeGridOnColumnResize = true; RadGrid1.ClientSettings.Resizing.AllowResizeToFit = true; // Add Master Table RadGrid1.MasterTableView.PageSize = 20; RadGrid1.MasterTableView.AllowSorting = true; RadGrid1.AutoGenerateColumns = false; RadGrid1.MasterTableView.EnableColumnsViewState = false; string ddlValue = Request.Form.Get("DropDownList1"); switch (ddlValue) { case "customers": goto default; case "orders": pageGrid.gridDbConnection = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; pageGrid.gridQuery = "SELECT OrderID, OrderDate, ShipName, ShipAddress FROM Orders"; gridColumn.Clear(); gridColumn.Add(new myListviewColumn(0, "orderid", "Order", AttributeType.String, 100)); gridColumn.Add(new myListviewColumn(1, "orderdate", "Orderdatum", AttributeType.String, 100)); gridColumn.Add(new myListviewColumn(2, "shipname", "Bedrijf", AttributeType.String, 100)); gridColumn.Add(new myListviewColumn(3, "shipaddress", "Adres", AttributeType.String, 100)); break; default: pageGrid.gridDbConnection = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; pageGrid.gridQuery = "SELECT CompanyName, ContactName, Address, City FROM Customers"; gridColumn.Clear(); gridColumn.Add(new myListviewColumn(0, "companyname", "Bedrijf", AttributeType.String, 200)); gridColumn.Add(new myListviewColumn(1, "contactname", "Contactpersoon", AttributeType.String, 200)); gridColumn.Add(new myListviewColumn(2, "address", "Adres", AttributeType.String, 200)); gridColumn.Add(new myListviewColumn(3, "city", "Plaats", AttributeType.String, 200)); break; } CreateListlayout(); } private void CreateListlayout() { GridClientSelectColumn selectColumn; selectColumn = new GridClientSelectColumn(); selectColumn.UniqueName = "ClientSelectColumn"; selectColumn.HeaderStyle.Width = Unit.Pixel(35); selectColumn.Resizable = false; RadGrid1.MasterTableView.Columns.Add(selectColumn); GridBoundColumn boundColumn; for (int i = 0; i < gridColumn.Count; i++) { boundColumn = new GridBoundColumn(); boundColumn.DataField = gridColumn[i].AttributeName; boundColumn.HeaderText = gridColumn[i].Name; boundColumn.ItemStyle.Wrap = false; if (i < gridColumn.Count - 1) { boundColumn.HeaderStyle.Width = Unit.Pixel(gridColumn[i].Width); } RadGrid1.MasterTableView.Columns.Add(boundColumn); } } protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { SqlDataReader dr; dr = SqlRetrieve(pageGrid.gridQuery, pageGrid.gridDbConnection); RadGrid1.DataSource = dr; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { RadGrid1.CurrentPageIndex = 0; RadGrid1.MasterTableView.SortExpressions.Clear(); RadGrid1.Rebind(); } // Retrieve data using a SQL Query public static SqlDataReader SqlRetrieve(string sql, string connectionString) { // Create the database connection SqlConnection dbConnection = new SqlConnection(connectionString); // Prepare the SQL command execution SqlCommand cmd = new SqlCommand(sql, dbConnection); cmd.CommandType = CommandType.Text; // Retrieve data with sqlDataReader try { dbConnection.Open(); // Make sure the database connection is closed when the datareader is closed. return cmd.ExecuteReader(CommandBehavior.CloseConnection); } catch (SqlException dbex) { return null; } catch (Exception ex) { return null; } } public class myListview { public string gridQuery { get; set; } public string gridDbConnection { get; set; } } public class myListviewColumn { public int Index { get; set; } public string Name { get; set; } public string AttributeName { get; set; } public int Type { get; set; } public int Width { get; set; } public myListviewColumn(int index, string attributename, string name, int type, int width) { Index = index; Name = name; Type = type; Width = width; AttributeName = attributename; } } }}