Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
261 views

Dear All,

I am very new to RadGrid. So please let me know how I can get the following task done. I need to programmatically create an grid with multiple column types. A few columns need to have mulitple sub-columns inside. So as far as my understanding goes, I need to create template column to do this job. So I did the following code and it seems working. However, i do not know how to get the filtering and sorting working with these columns though. Your help will be highly appreciated!

Here is what I have done. The current problem is the the combombox that I added to the filter control does not keep its value after postback. Please let me know what is missing. Thanks.

//the following is My template column which is extended   
//from the GridTemplateColumn  
 
    public class ComparisonColumn : GridTemplateColumn  
    {  
        private string _VColName;  
        private string _TColName;  
        private string _DColName;  
        private string _HColName;  
        private string _FilterCol;  
        RadComboBox combo;  
 
 
        public ComparisonColumn(string HeaderColName)  
            : base()  
        {  
 
            _HColName = HeaderColName;  
            _VColName = HeaderColName;  
            _TColName = HeaderColName + "_T";  
            _DColName = HeaderColName + "_D";  
            DataField = _VColName;  
        }  
 
         //I added a combobox in the filter control cell. It has 3 items "C", "T"   
        //and "D". Each item represent a sub-column in this column.   
        //So user will select a sub-column to filter on by select a value in  
// this dropdown list and then enter filter value into the filter textbox   
//and do the filtering.  
 
        protected override void SetupFilterControls(TableCell cell)  
        {  
 
            base.SetupFilterControls(cell);  
 
            cell.VerticalAlign = VerticalAlign.Bottom;  
            combo = new RadComboBox();  
            combo.ID = ("RadComboBox1" + this.UniqueName);  
            RadComboBoxItem c = new RadComboBoxItem("C");  
            combo.Items.Add(c);  
            RadComboBoxItem t = new RadComboBoxItem("T");  
            combo.Items.Add(t);  
            RadComboBoxItem d = new RadComboBoxItem("D");  
            combo.Items.Add(d);  
            combo.Width = Unit.Percentage(20);  
 
            TextBox txBox = (TextBox)cell.Controls[0];  
            txBox.TextChanged += this.textBox_TextValueChanged;  
            cell.Controls.AddAt(2, combo);  
            combo.SelectedIndexChanged += this.list_SelectedIndexChanged;  
 
            cell.Wrap = false;  
        }  
 
          
 
 
        private void list_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            RadComboBox o = (RadComboBox)sender;  
            _FilterCol = o.Text;  
            switch (_FilterCol)  
            {  
                case "C": DataField = _VColName; break;  
                case "T": DataField = _TColName; break;  
                case "D": DataField = _DColName; break;  
                default:  
                    DataField = _VColName;  
                    break;  
 
            }  
        }  
 
 
        private void textBox_TextValueChanged(object sender, EventArgs e)  
        {  
 
            GridFilteringItem filterItem = (GridFilteringItem)((TextBox)sender).NamingContainer;  
            _FilterCol = combo.Text;  
            if (_FilterCol == null || _FilterCol == "C" || _FilterCol == "")  
            {  
                DataField = _VColName;  
            }  
            else if (_FilterCol == "T")  
            {  
                DataField = _TColName;  
            }  
            else if (_FilterCol == "D")  
            {  
                DataField = _DColName;  
            }  
        }  
 
   
        //I was hopping to keep the selection in the combo box after postback   
        //(sorting). However, The following attempt does not work  
 
        protected override void SetCurrentFilterValueToControl(TableCell cell)  
        {  
            base.SetCurrentFilterValueToControl(cell);  
            RadComboBox combo = (RadComboBox)cell.Controls[2];  
            if ((_FilterCol != string.Empty))  
            {  
                combo.Text = _FilterCol;  
            }  
        }  
    }  
 
 
//the header template  
    public class ComparisonHeaderTemplate : ITemplate  
    {  
        private string _headerTxt;  
        private string _VColName;  
        private string _TColName;  
        private string _DColName;  
        public ComparisonHeaderTemplate(string headerTxt, string dataFldText)  
        {  
            _headerTxt = headerTxt;  
            _VColName = dataFldText;  
            _TColName = dataFldText + "_T";  
            _DColName = dataFldText + "_D";  
        }  
 
        public void InstantiateIn(System.Web.UI.Control container)  
        {  
            Table table = new Table();  
            TableRow row1 = new TableRow();  
            TableRow row2 = new TableRow();  
            TableCell cell11 = new TableCell();  
            TableCell cell21 = new TableCell();  
            TableCell cell22 = new TableCell();  
            TableCell cell23 = new TableCell();  
            table.Width = Unit.Percentage(100);  
            cell11.ColumnSpan = 3;  
            cell11.Width = Unit.Percentage(100);  
            cell21.Width = Unit.Percentage(33.3);  
            cell22.Width = Unit.Percentage(33.3);  
            cell23.Width = Unit.Percentage(33.4);  
 
            row1.Cells.Add(cell11);  
            row2.Cells.Add(cell21);  
            row2.Cells.Add(cell22);  
            row2.Cells.Add(cell23);  
            table.Rows.Add(row1);  
            table.Rows.Add(row2);  
 
            cell11.Text = _headerTxt;  
            cell21.Text = "Current";  
            cell22.Text = "Threshold";  
            cell23.Text = "Difference";  
            table.HorizontalAlign = HorizontalAlign.Center;  
            table.GridLines = GridLines.None;  
            container.Controls.Add(table);  
            //container.Controls.Add(new LiteralControl("<br />"));  
        }  
 
 
    }  
 
    public class ComparisonItemTemplate : ITemplate  
    {  
        protected LiteralControl lControlV;  
        protected LiteralControl lControlT;  
        protected LiteralControl lControlD;  
        private string colnameV;  
        private string colnameT;  
        private string colnameD;  
 
        public ComparisonItemTemplate(string cName)  
        {  
            colnameV = cName;  
            colnameT = cName + "_T";  
            colnameD = cName + "_D";  
        }  
 
        public void InstantiateIn(System.Web.UI.Control container)  
        {  
            lControlV = new LiteralControl();  
            lControlV.ID = colnameV;  
            lControlV.DataBinding += new EventHandler(lControl_DataBinding);  
            lControlT = new LiteralControl();  
            lControlT.ID = colnameT;  
            lControlT.DataBinding += new EventHandler(lControl_DataBinding);  
            lControlD = new LiteralControl();  
            lControlD.ID = colnameD;  
            lControlD.DataBinding += new EventHandler(lControl_DataBinding);  
            Table table = new Table();  
            TableRow row1 = new TableRow();  
            //TableRow row2 = new TableRow();  
            TableCell cell11 = new TableCell();  
            TableCell cell12 = new TableCell();  
            TableCell cell13 = new TableCell();  
            table.Width = Unit.Percentage(100);  
            table.CellSpacing = 1;  
 
            cell11.Width = Unit.Percentage(33.3);  
            cell12.Width = Unit.Percentage(33.3);  
            cell13.Width = Unit.Percentage(33.4);  
            //TableCell cell22 = new TableCell();  
            cell11.BackColor = Color.BlanchedAlmond;  
            cell12.BackColor = Color.Wheat;  
            cell13.BackColor = Color.LightSalmon;  
            row1.Cells.Add(cell11);  
            row1.Cells.Add(cell12);  
            row1.Cells.Add(cell13);  
            //row2.Cells.Add(cell22);  
            table.Rows.Add(row1);  
            //table.Rows.Add(row2);  
            cell11.Controls.Add(lControlV);  
            cell12.Controls.Add(lControlT);  
            cell13.Controls.Add(lControlD);  
 
            container.Controls.Add(table);  
        }  
 
 
        public void lControl_DataBinding(object sender, EventArgs e)  
        {  
            LiteralControl l = (LiteralControl)sender;  
            GridDataItem container = (GridDataItem)l.NamingContainer;  
            String colName = l.ID;  
            l.Text = ((DataRowView)container.DataItem)[colName].ToString() + "<br />";  
        }  
    }  
 
 
Iana Tsolova
Telerik team
 answered on 11 Jan 2010
1 answer
139 views
I was wondering what is the code of the LinqToSql.TelerikSamplesDataContext ?
It has been used as ContextTypeName in this demo http://demos.telerik.com/aspnet-ajax/grid/examples/performance/linq/defaultcs.aspx

Thanks
El
Top achievements
Rank 1
 answered on 11 Jan 2010
1 answer
103 views
Dear Sir,
    Please see the attached documents, as you will note i am using rad control in right to left application, but the problem that it's getting a missy layout while loading, and also not the expected layout after loading in case od combo box.

Please if you can assist!
Georgi Tunev
Telerik team
 answered on 11 Jan 2010
6 answers
581 views
2009.3.1210.35
I would like the [Remove] button to render the same gray button as [Select] for the Simple skin.

Kamen Bundev
Telerik team
 answered on 11 Jan 2010
2 answers
325 views
I've read all the documents which I've been linked to but I have not come up with the correct syntax yet on how to do this.  I am using ASP.Net AJAX 3rd Quarter 2009 suite and I'm trying to override the text of the default embedded CSS for the combobox.  I look at the default skin for ComboBox and the styles I want to override are as follows:

.RadComboBox_Default,
.RadComboBox_Default .rcbInput,
.RadComboBoxDropDown_Default
{
 font: 12px "Segoe UI", Arial, sans-serif;
 color: #333;
}

I've tried puttig a div in front of them and putting them in my own CSS but it does not override the default.  Can someone tell me how I'd need to write the css to override the above?  Please help!!  Thank you.
Kamen Bundev
Telerik team
 answered on 11 Jan 2010
1 answer
118 views
Hi,
 
I have a pristine, vs 2008 environment, fully patched.  I had problems installing your assemblies and ran gacutil to install the assemblies found in C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2009\Bin35> and C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2009\Bin>. 

The error that I am getting is attached.  A couple of potential issues that I see are that the assemblies in the bin35 and the bin directories have different version numbers.  The project is configured as a .net 3.5 project, however the assembly that vs/telerik is expecting to find is the assembly from the bin directory.

Installation shouldn't be this difficult, I have spent 2 days trying to get this to work.....
Pavlina
Telerik team
 answered on 11 Jan 2010
1 answer
85 views
Hello,

I think I encountered a bug.
I use a Scheduler populated with a web service on client side.
The RadSchduler component is initialized as following:
<telerik:RadScheduler runat="server" ID="RadScheduler" Skin="Sunset" MinutesPerRow="60">  
         <WebServiceSettings Path="SchedulerWebService.asmx" ResourcePopulationMode="ServerSide"  /> 
</telerik:RadScheduler>    

In my GetAppointments(RadSchduler owner) method, the value of the MinutesPerRow property is always "30".
public class SchedulerDbProvider : SchedulerProviderBase  
{  
        public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)  
        {  
            int mpr = owner.MinutesPerRow;    /* MinutesPerRow always = 30 */ 
 
            /* ... */ 
        }  

Did I miss something?
T. Tsonev
Telerik team
 answered on 11 Jan 2010
5 answers
201 views

I have a form with a RadNumeric Textbox on it and here are the following results…

 

34.5 = 35 (rounding away from zero)

34.6 = 35 (rounding away from zero)

 

**** -34.5 = -34 (rounding closer to zero) ****

-34.6 = -35 (rounding away from zero)

 

The question I have, is why does .5 round closer to zero when it is a negative number?  Is there a way to achieve the expected results…

 

34.5 = 35 (rounding away from zero)

34.6 = 35 (rounding away from zero)

 

****  -34.5 = -35 (rounding away from zero) ****

-34.6 = -35 (rounding away from zero)

Thanks,
Steve

Dimo
Telerik team
 answered on 11 Jan 2010
2 answers
155 views
I've an aspx page with inside a <RadWindow ...><ContentTemplate><telerik:RadSlider id="rl" ...></ContenTemplate></RadWindow> .
The RadWindow is set with VisibleOnPageLoad="true".
In the RadWindow I can see all the controls except the RadSliders that remains not visible: why?
I've tried to call a javascript function on the OnClientShow of the RadWindow to repaint the sliders as suggested in an anwser in these forums as follows:

function

 

OnClientShow(sender, eventArgs) {
var wnd = $find("<%= rl.ClientID %>");

 

slider.repaint();}

Unfortunately it does not compile since the "rl" control is inside a ContentTemplate and I do not know how to access this element from javscript.
Any help?

Marco Miccini
Top achievements
Rank 1
 answered on 11 Jan 2010
1 answer
416 views
HI ,

I have a RadGrid with a column of type GridDateTimeColumn :

  <telerik:RadGrid ID="RadGrid1 > 
       <Columns> 
                  <telerik:GridDateTimeColumn DataField="CreationDate" DataType="System.DateTime " />  
       <Columns> 
  </telerik:RadGrid> 

On this column I have a DateTime picker which allows me to select some date and then I want to apply a filter , for example "GreaterThan" . I am expecting that the result will be all rows with a date CreationDate greater than selected.

In my code I am sending a filter expression generated by a grid to dynamic linq query like this : 
//data is IEnumerable collection of data objects 
// filter is a filter expression generated by grid , which is converted to string like this :  
//string filter  = string.format("{0}.{1}(\"{2}\")",item.FieldName, item.FilterFunction, item.FieldValue) 
  IQueryable query = data.AsQueryable(); 
  queryquery = query.Where(filter); 

At this point I am getting an exception : 
No applicable method 'GreaterThan' exists in dataObjectType 'DateTime'

Is there any way to make it work with dynamic linq ? it will be work with most cases when column type is string, but I need to make it work with INT and DateTime column types .

Any suggestion ? ? ?
Thanks  . 

Nikolay Rusev
Telerik team
 answered on 11 Jan 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?