Hi,
I am using the HeaderContextMenu in my radgrid to show and hide the columns. I want to save the users preference as to what columns they have visible. I thought that this would be easy and I could just save the GridColumn.Display value. But when I hide a column using the HeaderContextMenu the display value for that column is still true.
Where is the information regarding what columns have been hidden by the user using the HeaderContextMenu?

object iControl =
new RadComboBox();
((RadComboBox)iControl).Width = Unit.Pixel(200);
((RadComboBox)iControl).AllowCustomText = true;
((RadComboBox)iControl).ShowToggleImage = true;
((RadComboBox)iControl).ShowMoreResultsBox = true;
((RadComboBox)iControl).EnableLoadOnDemand = true;
((RadComboBox)iControl).EnableVirtualScrolling = true;
((RadComboBox)iControl).MarkFirstMatch = true;
((RadComboBox)iControl).ItemsRequested += new RadComboBoxItemsRequestedEventHandler(index_create_ItemsRequested);
((RadComboBox)iControl).ID = "~~~" + docFieldDef.FieldTypeName + "~~~fld~" + docFieldDef.FieldDefID.ToString();
tbCell3.Controls.Add((RadComboBox)iControl);
And here is the shell for he event handler, although this code does not get executed at present.
protected void index_create_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
<snip>
}
Please let me know if I have missed something.
Thanks,
Andy
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AjaxProject_1.Default" %><!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 runat="server"> <title>Default page</title></head><body> <form id="form1" runat="server"> <tel:RadScriptManager runat="server" ID="Rsm1"></tel:RadScriptManager> <tel:RadAjaxManager runat="server" ID="Ram1"></tel:RadAjaxManager> <tel:RadScriptBlock runat="server"> <script language="javascript"> function __doXBack(args) { var ram = $find("<%= Ram1.ClientID %>"); if (ram) ram.ajaxRequest(args); } function Refresh1(sender, args) { var value = args.getDataKeyValue("Id"); if (value) __doXBack("1|" + value); } function Refresh2(ddl) { __doXBack("2|" + ddl.options[ddl.selectedIndex].value); } </script> </tel:RadScriptBlock> <tel:RadAjaxPanel runat="server" ID="Rap1"> <asp:DropDownList runat="server" ID="Rcb1" onChange="Refresh2(this)"></asp:DropDownList> </tel:RadAjaxPanel> <hr/> <tel:RadAjaxPanel runat="server" ID="Rap2"> <tel:RadGrid runat="server" ID="Grid1"> <ClientSettings> <Selecting AllowRowSelect="True"></Selecting> <ClientEvents OnRowSelected="Refresh1"></ClientEvents> </ClientSettings> <MasterTableView ClientDataKeyNames="Id"></MasterTableView> </tel:RadGrid> </tel:RadAjaxPanel> </form></body></html>using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Text;using Telerik.Web.UI;namespace AjaxProject_1{ public partial class Default : System.Web.UI.Page { protected override void OnInit(EventArgs e) { base.OnInit(e); Ram1.AjaxRequest += Ram1OnAjaxRequest; } private void Ram1OnAjaxRequest(object sender, AjaxRequestEventArgs e) { if (e == null || string.IsNullOrEmpty(e.Argument)) return; if (e.Argument.StartsWith("1|")) { InitComboBox(e.Argument); Rap1.RaisePostBackEvent(null); } if (e.Argument.StartsWith("2|")) { InitGrid(); Rap2.RaisePostBackEvent(null); } } protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; InitComboBox("0"); InitGrid(); } private void InitComboBox(string id) { Rcb1.Items.Clear(); var list = new List<string> {id}; for (var i = 0; i < 10; i++) list.Add(GetRandomPropertyValue()); Rcb1.DataSource = list; Rcb1.DataBind(); } private static readonly IList<string> Properties = new[] {"Id", "Name"}; private void InitGrid() { var data = new DataTable(); Array.ForEach(Properties.ToArray(), t => data.Columns.Add(new DataColumn(t, typeof(string)))); for (var i = 0; i < 10; i++) { var row = data.NewRow(); row["Id"] = i.ToString(); row["Name"] = GetRandomPropertyValue(); data.Rows.Add(row); } Grid1.DataSource = data; Grid1.DataBind(); } private static IList<char> _chars; private static readonly Random Rnd = new Random(DateTime.Now.Millisecond); private static string GetRandomPropertyValue() { if (_chars == null) { _chars = new List<char> {' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; for (var c = 'a'; c <= 'z'; c++) _chars.Add(c); for (var c = 'A'; c <= 'Z'; c++) _chars.Add(c); } var len = Rnd.Next(10, 15); var sb = new StringBuilder(); for (var i = 0; i < len; i++) sb.Append(_chars[Rnd.Next(0, _chars.Count - 1)]); return sb.ToString(); } }}Hi!
I am new to asp, so please excuse me if I don't express myself correctly.
I have a RadScheduler with a Linq data source. I want to get appointments from the database based on a given id.
In my DataClasses.dbml I have four tables and (for now) two stored procedures, GetProgram() and GetProgramById(int id). The user chooses the id from a checkboxlist, and I want to call the GetProgramById(int id) from codebehind.
In markup I have configured the RadScheduler with DataSourceID="ProgramDataSource". I try to set the data source property to the result of the GetProgramById(int id), but then I get an error saying that both DataSourceID and DataSource properties are set, and that I have to remove one of them. If I remove DataSourceID="ProgramDataSource" from markup I can set DataSource=GetProgrambyID(int id), but then none of the appointments are updated to the database after closing the AdvancedEdit form of the scheduler.
There must be a way to get a subset of the appointments, and to be able to edit them, so I would be greatful if anyone could help me find it.
Thank you!
Regards, Jill-Connie Lorentsen
protected void RadListBoxTmp_ItemCheck(object sender, RadListBoxItemEventArgs e)
{
int id;
bool result = Int32.TryParse( e.Item.Value, out id);
if ( e.Item.Checked && result)
{
var dataContext = new DataClassesDataContext();
ProgramDataManager dataManager =
new ProgramDataManager((SqlConnection)dataContext.Connection);
var program = new List<GetProgramByIDResult>();
program = dataManager.GetProgramByID(id);
RadScheduler1.DataSource = program;
RadScheduler1.Rebind();
}
}
