or

window.radopen=
function(b,a){var c=GetRadWindowManager();
return
c.open(b,a)
};
Where c is returned as undefined. My values have been passed in b and a correctly.
This is almost working, but I'm not sure whether it's because of the Master Page issue.
David Penny.
| <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="SandboxWebApp._Default" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> |
| <%--<telerik:RadWindowManager ID="RadWindowManager1" runat="server" />--%> |
| <div> |
| <asp:Login ID="Login1" runat="server"> |
| </asp:Login> |
| <asp:LoginStatus ID="LoginStatus1" runat="server" /> |
| </div> |
| </form> |
| </body> |
| </html> |
| <telerik:RadGrid ID="radgridList" runat="server" AllowSorting="False" AutoGenerateColumns="False" |
| GridLines="none" OnNeedDataSource="radgridList_NeedDataSource"> |
| <MasterTableView Width="100%"> |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression> |
| <SelectFields> |
| <telerik:GridGroupByField FieldAlias="Catergory" FieldName="Title"></telerik:GridGroupByField> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="Title" SortOrder="Descending"></telerik:GridGroupByField> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="QuestionId" DataField="QuestionId" UniqueName="QuestionId" |
| Visible="False"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Body" DataField="Body" UniqueName="Body"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Weighting" DataField="Weighting" UniqueName="Weighting"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn HeaderText="True" UniqueName="TrueSelection"> |
| <ItemTemplate> |
| <asp:RadioButton ID="rbTrue" runat="server" GroupName="Selection" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="False" UniqueName="FalseSelection"> |
| <ItemTemplate> |
| <asp:RadioButton ID="rbFalse" runat="server" GroupName="Selection" Checked="True" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Notes" UniqueName="Notes"> |
| <ItemTemplate> |
| <telerik:RadTextBox ID="txtNotes" runat="server" Width="250px"> |
| </telerik:RadTextBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting></Selecting> |
| <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True" |
| ResizeGridOnColumnResize="False"></Resizing> |
| </ClientSettings> |
| <GroupingSettings ShowUnGroupButton="true" /> |
| </telerik:RadGrid> |
| <div id="bottom" style="float:right; padding-top:10px;"> |
| <asp:Button ID="btnSave" Text="Save" runat="server" CausesValidation="True" onclick="btnSave_Click" /></div> |
| private void buildGrid() |
| { |
| this.ResultRadGrid.MasterTableView.Columns.Clear(); |
| if (SelectedRadGrigColList.Items.Count != 0) |
| { |
| this.ResultRadGrid.MasterTableView.Columns.Clear(); |
| Hashtable ddlColumnTable = new Hashtable(); |
| Hashtable lblColumnTable = new Hashtable(); |
| foreach (RadListBoxItem rlbi in SelectedRadGrigColList.Items) |
| { |
| switch (rlbi.Value) |
| { |
| case "Pk_Contribution": |
| { |
| DataTable dt = ContributionFactory.GetAllContributionDataTable(); |
| MyCustomFilteringDDLColumnCS templateColumn = new MyCustomFilteringDDLColumnCS(rlbi.Value, "Pk_Contribution", "Title", dt); |
| templateColumn.HeaderText = "Contribution Relationship"; |
| templateColumn.DataField = rlbi.Value; |
| templateColumn.UniqueName = rlbi.Value; |
| ResultRadGrid.MasterTableView.Columns.Add(templateColumn); |
| ddlColumnTable.Add(ResultRadGrid.MasterTableView.Columns.Count - 1, rlbi.Value); |
| break; |
| } |
| case "Fk_Enum_ContributionStatus": |
| { |
| MyCustomFilteringLabelColumnCS templateColumn = new MyCustomFilteringLabelColumnCS(rlbi.Value, rlbi.Value); |
| ResultRadGrid.MasterTableView.Columns.Add(templateColumn); |
| templateColumn.HeaderText = "Contribution Status"; |
| templateColumn.DataField = rlbi.Value; |
| templateColumn.UniqueName = rlbi.Value; |
| lblColumnTable.Add(ResultRadGrid.MasterTableView.Columns.Count - 1, rlbi.Value); |
| break; |
| } |
| default: |
| { |
| MyCustomFilteringColumnCS gridColumn = new MyCustomFilteringColumnCS(); |
| this.ResultRadGrid.MasterTableView.Columns.Add(gridColumn); |
| gridColumn.DataField = rlbi.Value; |
| gridColumn.HeaderText = rlbi.Text; |
| break; |
| } |
| } |
| } |
| Session.Add("DDLGRIDCOLUMNSINDEX", ddlColumnTable); |
| Session.Add("LBLGRIDCOLUMNSINDEX", lblColumnTable); |
| } |
| } |
| protected void ResultRadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| List<CustomParam> parameterList = new List<CustomParam>(); |
| List<Contribution> ContribList = new List<Contribution>(); |
| ////TODO apply filter |
| DbParameterManager dph = new DbParameterManager(DbParameterManager.ProviderType.SqlClient); |
| CustomParam param1 = new CustomParam(dph.CreateDataParameter("@Pk_Contribution", DbType.Int32)); |
| param1.Value = 11; |
| CustomParam param2 = new CustomParam(dph.CreateDataParameter("@MeetingNotes", DbType.String)); |
| param2.Value = "comment"; |
| parameterList.Add(param1); |
| parameterList.Add(param2); |
| MyContribClient = new ChannelFactory<IContribution>("IContribution"); |
| IContribution MyServices = MyContribClient.CreateChannel(); |
| if (MyContribClient.State == CommunicationState.Opened) |
| { |
| ((IContextChannel)MyServices).OperationTimeout = new TimeSpan(0, 0, 240); |
| ContribList = MyServices.GetContributionUsingSQLQuery("select * from Contribution where Pk_Contribution >= @Pk_Contribution and MeetingNotes = @MeetingNotes", parameterList); |
| } |
| else |
| { |
| MyContribClient.Open(); |
| ((IContextChannel)MyServices).OperationTimeout = new TimeSpan(0, 0, 240); |
| ContribList = MyServices.GetContributionUsingSQLQuery("select * from Contribution where Pk_Contribution >= @Pk_Contribution and MeetingNotes = @MeetingNotes", parameterList); |
| } |
| MyContribClient.Close(); |
| this.ResultRadGrid.DataSource = ContribList; |
| } |
| protected void ResultRadGrid_ColumnCreating(object sender, GridColumnCreatingEventArgs e) |
| { |
| if ((e.ColumnType == typeof(MyCustomFilteringColumnCS).Name)) |
| { |
| e.Column = new MyCustomFilteringColumnCS(); |
| } |
| if ((e.ColumnType == typeof(MyCustomFilteringDDLColumnCS).Name)) |
| { |
| GridDataItem dataItem = (GridDataItem)((Control)sender).NamingContainer; |
| e.Column = new MyCustomFilteringDDLColumnCS(); |
| } |
| if ((e.ColumnType == typeof(MyCustomFilteringLabelColumnCS).Name)) |
| { |
| e.Column = new MyCustomFilteringLabelColumnCS(); |
| } |
| } |
| protected void ResultRadGrid_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if ((e.CommandName == "Filter")) |
| { |
| foreach (GridColumn column in e.Item.OwnerTableView.Columns) |
| { |
| column.CurrentFilterValue = string.Empty; |
| column.CurrentFilterFunction = GridKnownFunction.NoFilter; |
| } |
| } |
| } |
| protected void ResultRadGrid_ItemDataBound(object sender, GridItemEventArgs e) // similar to RowDataBound event in GridView |
| { |
| if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem))// gets the row collection |
| { |
| RadGrid dg = (RadGrid)sender; |
| int cnt = e.Item.ItemIndex + (dg.PageSize * dg.CurrentPageIndex); |
| List<Contribution> dtBound = (List<Contribution>)dg.DataSource; |
| GridDataItem dataitem = (GridDataItem)e.Item; |
| try |
| { |
| if (Session["DDLGRIDCOLUMNSINDEX"] != null) |
| { |
| Hashtable colIndexTable = (Hashtable)Session["DDLGRIDCOLUMNSINDEX"]; |
| IEnumerator iter = colIndexTable.Keys.GetEnumerator(); |
| while (iter.MoveNext()) |
| { |
| int i = (int)iter.Current; |
| string colName = colIndexTable[i].ToString(); |
| DropDownList ddl = (DropDownList)e.Item.Cells[i].FindControl(colName); |
| if (ddl != null) |
| { |
| int index = 0; |
| if (dtBound[cnt] != null) |
| { |
| ddl.SelectedValue = dtBound[cnt].Pk_Contribution.ToString(); |
| } |
| } |
| } |
| } |
| } |
| catch (Exception ee) { } |
| } |
| } |
| public class MyCustomFilteringDDLColumnCS : GridTemplateColumn |
| { |
| #region Item Template for DropDownList |
| public class CreateItemTemplateDDL : ITemplate |
| { |
| DataTable dtBind; |
| string strddlName; |
| string strDataValueField; |
| string strDataTextField; |
| public MyCustomFilteringDDLColumnCS Column = null; |
| public CreateItemTemplateDDL(string DDLName, string DataValueField, string DataTextField, DataTable DDLSource) |
| { |
| this.dtBind = DDLSource; |
| this.strDataValueField = DataValueField; |
| this.strDataTextField = DataTextField; |
| this.strddlName = DDLName; |
| } |
| public CreateItemTemplateDDL() |
| { |
| } |
| public void InstantiateIn(Control objContainer) |
| { |
| DropDownList ddl = new DropDownList(); |
| ddl.DataBinding += new EventHandler(ddl_DataBinding); |
| objContainer.Controls.Add(ddl); |
| } |
| private void ddl_DataBinding(object sender, EventArgs e) |
| { |
| DropDownList ddl = (DropDownList)sender; |
| GridDataItem dataItem = (GridDataItem)((Control)sender).NamingContainer; |
| if(dataItem!=null){ |
| try { |
| Contribution ctb = (Contribution)dataItem.DataItem; |
| if (ctb != null) |
| { |
| string test = this.Column.DataField; |
| //todo use reflection |
| if (test != null) { |
| ddl.ID = test; |
| DataTable dt = ContributionFactory.GetAllContributionDataTable(); |
| ddl.DataSource = dt; |
| ddl.DataValueField = test; |
| ddl.DataTextField = "Title"; |
| } |
| } |
| else { |
| ddl.ID = strddlName; |
| ddl.DataSource = dtBind; |
| ddl.DataValueField = strDataValueField; |
| ddl.DataTextField = strDataTextField; |
| } |
| } |
| catch (Exception ee) { |
| } |
| } |
| //ddl.DataBind(); |
| } |
| } |
| #endregion Item Template for DropDownList |
| public MyCustomFilteringDDLColumnCS() { |
| CreateItemTemplateDDL template = new CreateItemTemplateDDL(); |
| template.Column = this; |
| this.ItemTemplate = template; |
| } |
| public MyCustomFilteringDDLColumnCS(string DDLName, string DataValueField, string DataTextField, DataTable DDLSource) |
| { |
| CreateItemTemplateDDL template = new CreateItemTemplateDDL(DDLName,DataValueField,DataTextField,DDLSource); |
| template.Column = this; |
| this.ItemTemplate = template; |
| } |
| public string DataField |
| { |
| get |
| { |
| object res = this.ViewState["_df"]; |
| if (res != null) |
| { |
| return (string)res; |
| } |
| return String.Empty; |
| } |
| set |
| { |
| this.ViewState["_df"] = value; |
| } |
| } |
| protected override string GetFilterDataField() |
| { |
| return this.DataField; |
| } |
| //RadGrid will call this method when it initializes the controls inside the filtering item cells |
| protected override void SetupFilterControls(TableCell cell) |
| { |
| base.SetupFilterControls(cell); |
| cell.Controls.RemoveAt(0); |
| RadComboBox combo = new RadComboBox(); |
| combo.ID = ("RadComboBox1" + this.UniqueName); |
| combo.ShowToggleImage = false; |
| combo.Skin = "Office2007"; |
| combo.EnableLoadOnDemand = true; |
| combo.AutoPostBack = true; |
| combo.MarkFirstMatch = true; |
| combo.Height = Unit.Pixel(100); |
| combo.ItemsRequested += this.list_ItemsRequested; |
| combo.SelectedIndexChanged += this.list_SelectedIndexChanged; |
| cell.Controls.AddAt(0, combo); |
| cell.Controls.RemoveAt(1); |
| } |
| //RadGrid will cal this method when the value should be set to the filtering input control(s) |
| protected override void SetCurrentFilterValueToControl(TableCell cell) |
| { |
| base.SetCurrentFilterValueToControl(cell); |
| RadComboBox combo = (RadComboBox)cell.Controls[0]; |
| if ((this.CurrentFilterValue != string.Empty)) |
| { |
| combo.Text = this.CurrentFilterValue; |
| } |
| } |
| //RadGrid will cal this method when the filtering value should be extracted from the filtering input control(s) |
| protected override string GetCurrentFilterValueFromControl(TableCell cell) |
| { |
| RadComboBox combo = (RadComboBox)cell.Controls[0]; |
| return combo.Text; |
| } |
| private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) |
| { |
| //TODo ; use reflection and custom attributes |
| switch (this.UniqueName) { |
| case "Fk_Enum_ContributionStatus": |
| { |
| ((RadComboBox)o).DataSource = GetDataTable(this.UniqueName, e.Text); |
| ((RadComboBox)o).DataTextField = "Enum_Value"; |
| ((RadComboBox)o).DataValueField = "Pk_Enum_ContributionStatus"; |
| break; |
| } |
| default: { |
| ((RadComboBox)o).DataSource = GetContributionTable(this.UniqueName, e.Text); |
| ((RadComboBox)o).DataTextField = this.UniqueName; |
| ((RadComboBox)o).DataValueField = this.UniqueName; |
| break; |
| } |
| } |
| ((RadComboBox)o).DataBind(); |
| } |
| private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer; |
| if ((this.UniqueName == "Index")) |
| { |
| //this is filtering for integer column type |
| filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName)); |
| } |
| //filtering for string column type |
| filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName)); |
| } |
| public static List<Contribution> GetContributionTable(string col, string value) |
| { |
| List<Contribution> ContribList = new List<Contribution>(); |
| List<CustomParam> parameterList = new List<CustomParam>(); |
| String tablename = string.Empty; |
| String column = string.Empty; |
| ////TODO apply filter |
| DbParameterManager dph = new DbParameterManager(DbParameterManager.ProviderType.SqlClient); |
| CustomParam param1 = new CustomParam(dph.CreateDataParameter("@" + col, DbType.String)); |
| param1.Value = "%" + value + "%"; |
| parameterList.Add(param1); |
| ContribList = ContributionFactory.getCustomQueryList("select * from Contribution where " + col + " like @" + col, parameterList); |
| return ContribList; |
| } |
| public static DataTable GetDataTable(string col, string value) { |
| return Enum_ContributionStatusFactory.GetAllEnum_ContributionStatusDataTable(); |
| } |
| public DataTable SelectDistinct(string TableName, DataTable SourceTable, string FieldName) |
| { |
| DataSet ds = new DataSet(); |
| DataTable dt = new DataTable(TableName); |
| dt.Columns.Add(FieldName, SourceTable.Columns[FieldName].DataType); |
| object LastValue = null; |
| foreach (DataRow dr in SourceTable.Select("", FieldName)) |
| { |
| if (LastValue == null || !(ColumnEqual(LastValue, dr[FieldName]))) |
| { |
| LastValue = dr[FieldName]; |
| dt.Rows.Add(new object[] { LastValue }); |
| } |
| } |
| if (ds != null) |
| ds.Tables.Add(dt); |
| return dt; |
| } |
| private bool ColumnEqual(object A, object B) |
| { |
| // Compares two values to see if they are equal. Also compares DBNULL.Value. |
| // Note: If your DataTable contains object fields, then you must extend this |
| // function to handle them in a meaningful way if you intend to group on them. |
| if (A == DBNull.Value && B == DBNull.Value) // both are DBNull.Value |
| return true; |
| if (A == DBNull.Value || B == DBNull.Value) // only one is DBNull.Value |
| return false; |
| return (A.Equals(B)); // value type standard comparison |
| } |
| public override bool SupportsFiltering() |
| { |
| return true; |
| } |
| } |