Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
100 views
Hi Forum,
Please assist, I am creating the Radgrid programmatically and want to add Radcombox as a filtering item to it. 
 No Clue, and I've tried everything I can find. 
I want the design output like the attached file.

Bali.

 here is sample code i am using.

     rdGrd = new RadGrid();
            rdGrd.AutoGenerateColumns = false;
            rdGrd.AllowPaging = true;           
            rdGrd.AllowSorting = true;
            rdGrd.AllowFilteringByColumn = true;     

            rdGrd.Width = Unit.Pixel(600);
            rdGrd.EnableAJAX = true;
            rdGrd.EnableAJAXLoadingTemplate = true;
            rdGrd.Skin = "None";
                      
            rdGrd.NeedDataSource += new GridNeedDataSourceEventHandler(rdGrd_NeedDataSource);
            rdGrd.ItemDataBound += new GridItemEventHandler(rdGrd_ItemDataBound);
            rdGrd.PageSize = 25;
            rdGrd.ID = "grd";

  GridBoundColumn boundColumn1 = new GridBoundColumn();
                boundColumn1.DataField = "FirmName";
                boundColumn1.UniqueName = "Firm";
                boundColumn1.HeaderText = "Firm";
                boundColumn1.AllowFiltering = true;                
                boundColumn1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                boundColumn1.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                boundColumn1.ItemStyle.VerticalAlign = VerticalAlign.Top;

  GridTemplateColumn templateColumnRank = new GridTemplateColumn();
                templateColumnRank.AllowFiltering = false;
                templateColumnRank.HeaderTemplate = new NColHeaderTemplate(120, "Rank", "cont3", "2009, 2008", "LeaderRank, LeaderRankM1", "cont4, cont5");
                templateColumnRank.ItemTemplate = new NColItemTemplate(120, "LeaderRank, LeaderRankM1", "cont1, cont2");

  HOW CAN I ADD A RADCOBOBOX HERE AS A FILTERING ITEM

  rdGrd.MasterTableView.Columns.Add(templateColumnRank);
                rdGrd.MasterTableView.Columns.Add(boundColumn1);
  
     this.Controls.Add(rdGrd);

 

public class NColHeaderTemplate : ITemplate
    {
        protected LiteralControl lControl0;
        private int iColumnWidth;
        private int nColHeader;
        private string sTopLevelColumnName;
        private string sTopLevelColumnNameUniqueID;
        private string[] sNBottomColumnName;
        private string[] sNBottomColSortCommandArgument;
        private string[] sNBottomColumnNameUniqueID;
        private string sCellHorizontalAlign;

        public NColHeaderTemplate(int ColumnWidth, string TopLevelColumnName, string TopLevelColumnNameUniqueID, string NBottomColumnName, string NBottomColSortCommandArgument, string NBottomColumnNameUniqueID)
        {
            iColumnWidth = ColumnWidth;
            sTopLevelColumnName = TopLevelColumnName.Trim();
            sTopLevelColumnNameUniqueID = TopLevelColumnNameUniqueID.Trim();
            sNBottomColumnName = NBottomColumnName.Split(Convert.ToChar(","));
            sNBottomColSortCommandArgument = NBottomColSortCommandArgument.Split(Convert.ToChar(","));
            sNBottomColumnNameUniqueID = NBottomColumnNameUniqueID.Split(Convert.ToChar(","));
            //ColHeaderParam = nColHeaderParam.Split(Convert.ToChar(","));
            nColHeader = sNBottomColumnName.Length;
            sCellHorizontalAlign = "Center";
        }

       
        public void InstantiateIn(System.Web.UI.Control container)
        {
            lControl0 = new LiteralControl();
            lControl0.ID = sTopLevelColumnNameUniqueID;
            lControl0.Text = sTopLevelColumnName;

            Table table = new Table();
            table.Width = Unit.Pixel(iColumnWidth);

            TableRow row1 = new TableRow();
            TableRow row2 = new TableRow();

            TableCell cell11 = new TableCell();
           
            cell11.Controls.Add(lControl0);
            cell11.ColumnSpan = nColHeader;

            row1.Cells.Add(cell11);
            table.Rows.Add(row1);

            for (int i = 0; i < nColHeader; i++)
            {

                LinkButton lbControl = new LinkButton();
                lbControl.ID = sNBottomColumnNameUniqueID[i].ToString().Trim();
                lbControl.Text = sNBottomColumnName[i].ToString().Trim();
                lbControl.CommandName = "Sort";
                lbControl.CommandArgument = sNBottomColSortCommandArgument[i].ToString().Trim();

                TableCell cell = new TableCell();
                cell.HorizontalAlign = HorizontalAlign.Center
               
                cell.Controls.Add(lbControl);
                cell.Width = iColumnWidth / nColHeader;
                row2.Cells.Add(cell);

            }

            table.Rows.Add(row2);
            container.Controls.Add(table);
        }
    }

    public class NColItemTemplate : ITemplate
    {

        //protected LiteralControl lControl;
        protected HyperLink lControl;
        private int iColumnWidth;
        private int nColItem;
        private string[] sNBottomDataColumnName;
        private string[] sNBottomDataControlUniqueID;
        private string sBottomDataColumnName;
        private string sCellHorizontalAlign;
       

        public NColItemTemplate(int ColumnWidth, string NBottomDataColumnName, string NBottomDataControlUniqueID)
        {
            sNBottomDataColumnName = NBottomDataColumnName.Split(Convert.ToChar(","));
            sNBottomDataControlUniqueID = NBottomDataControlUniqueID.Split(Convert.ToChar(","));
            nColItem = sNBottomDataColumnName.Length;
            iColumnWidth = ColumnWidth;
            sCellHorizontalAlign = "Center";
        }
       
        public void InstantiateIn(System.Web.UI.Control container)
        {
            Table table = new Table();
            table.Width = Unit.Pixel(iColumnWidth);

            TableRow row1 = new TableRow();
            for (int i = 0; i < nColItem; i++)
            {
                //lControl = new LiteralControl();
                lControl = new HyperLink();
                lControl.ID = sNBottomDataControlUniqueID[i].Trim();
                lControl.Text = sNBottomDataColumnName[i].ToString().Trim();
                lControl.DataBinding += new EventHandler(lControl_DataBinding);

                TableCell cell = new TableCell();
                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.VerticalAlign = VerticalAlign.Top;
               

                cell.Width = iColumnWidth / nColItem;
                cell.Controls.Add(lControl);
                row1.Cells.Add(cell);
            }
            table.Rows.Add(row1);
            container.Controls.Add(table);
            container.Controls.Add(new LiteralControl("<br />"));
        }
        public void lControl_DataBinding(object sender, EventArgs e)
        {
           // LiteralControl l = (LiteralControl)sender;
            HyperLink l = (HyperLink)sender;
            GridDataItem container = (GridDataItem)l.NamingContainer;
            sBottomDataColumnName = l.Text.Trim();
            l.Text = ((DataRowView)container.DataItem)[sBottomDataColumnName].ToString();
            l.Target = "_blank";
            l.NavigateUrl = "http://www.google.com/search?hl=en&q=" + ((DataRowView)container.DataItem)[sBottomDataColumnName].ToString() + "&btnG=Google+Search";

        }

 

    }

Maria Ilieva
Telerik team
 answered on 20 Dec 2010
1 answer
94 views
Hey, i am using Rad Grid containing a column of type string having its AllowFilter="true".
I am facing a weird situation, when i try to write in the filter a specific value (it is the first value for that column in the grid), copy and pasted from grid values on that column and click contains.
The filter returns "no records to be displayed".
Although, if i tried it with any other value also contained in the grid it works fine.
i don't know why this is happening? 
Pavlina
Telerik team
 answered on 20 Dec 2010
1 answer
136 views
Hi,

I have radgrid. which have 170 record. but i have using paging and 15 record per page. when i give code into itemCommand

Radgrid1.items.Count =15 . how to get total count for this grid.

Thanks,
Dhamu.
Princy
Top achievements
Rank 2
 answered on 20 Dec 2010
1 answer
76 views
In my table I have columns named Ques, Answer, ID, etc. If I want to display these question answers on my page using RadTreeView, how do I implement this ? Like I want the parent node in the TreeView to be the question and child node should be the answer. Any sample code for that in here ?
Nikolay Tsenkov
Telerik team
 answered on 20 Dec 2010
3 answers
218 views
Hello,

i am using a RadPanelbar in WebApplication to select a control to load, here is my code:

public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.FindControl("RadPanelBar1") != null)
        {
          if ((RadPanelBar1.SelectedItem != null))
            {
                choiceActivity(RadPanelBar1.SelectedItem.Value);
            }
            else if (Page.FindControl("RadChart1") == null)
            {
                choiceActivity("cockpit");
            }
        }
    }
 
    public void MessageboxAnzeigen(string Inhalt)
    {
        string Script = "<script type=\"text/javascript\">alert('" + Inhalt + "')</script>";
        RegisterClientScriptBlock("WindowOpener", Script);
    }
 
    public void openActivity(String controlName)
    {
        RadAjaxPanel1.Controls.Clear();
        UserControl userControl = (UserControl)this.LoadControl(controlName);
        userControl.ID = "myUC";
        this.RadAjaxPanel1.Controls.Add(userControl);
    }
    protected void RadPanelBar1_ItemClick(object sender, RadPanelBarEventArgs e)
    {
        choiceActivity(e.Item.Value);   
    }
 
    protected void choiceActivity(String itemValue)
    {
        if (Page.FindControl("myUC") == null)
        {
            switch (itemValue)
            {
                case "stammdaten":
                    openActivity("Stammdaten.ascx");
                    break;
 
                case "kundenverwaltung":
                    openActivity("StammdatenCockpit.ascx");
                    break;
                     
                case "abrechnung":
                    openActivity("abrechnung.ascx");
                    break;
 
                case "tarife":
                    openActivity("tarife.ascx");
                    break;
 
                case "cockpit":
                    openActivity("cockpit.ascx");
                    break;
            }
        }
    }
    protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
    {
 
    }
}

In VS it works fine, but deployed on the Server (IIS 7 on Win 2008 R2) it only shows the "cockpit" control and i can't unterstand what could be the different between VS und and the Server. The RadPanelbar seems to loose his state by every click (if i open a item its closed after the automatic reload of the page).

Thank you for any help.

UPDATE: I added a RadMenu and have exactly the same problem.

UPDATE 2: I enabled "PersistStateInCookie" and now the Panelbar keeps expandend after the reload but it still doesn't add the control to the RadAjaxPanel.

Best regards
Patrick
Patrick Gruhn
Top achievements
Rank 1
 answered on 20 Dec 2010
0 answers
90 views
Hi,
I am binding treeview with EF. Datavalue field is NAME and DataTextField value is CATID?When i select note and want to get the value of the selected treeview node in combobox it does not shows me the value.but i use combo.text it gives me the NAME of the treeview..How can i get selected treeview value in combobox?I trided combo.selectedvalue but its not working.
Teoman
Top achievements
Rank 1
 asked on 20 Dec 2010
6 answers
157 views
Dear Sirs!
For RadGrid I want to change some item's attrfibutes. For example, border color width and style if some condition is true.
In ItemDataBound item I write:

 

if (e.Item is GridDataItem)

 

{

 

GridDataItem it = e.Item as GridDataItem;

 

 

try

 

{

 

if (it["track_type"].Text.Trim() == "0")

 

{

it.BorderColor = System.Drawing.

Color.Red;

 

}

}

 

catch { }

 

}

this not works but the it.BackColor = System.Drawing.Color.Red work OK.
What I did wrong?
May be I need to override Grid's Style of my skin?

Thank you very much in advance.

Boris


 

Veli
Telerik team
 answered on 20 Dec 2010
1 answer
87 views
Hello -

I am encountering an issue with a grid inside an EditForm for a parent grid that I cannot seem to correct.

When I choose to edit a row in the parent grid the form comes up and I am able to modify the fields placed directly on the form. On that same form is another grid that also has an edit form that needs to be completed. When I click to add/edit the child grid it simply flashes and the editform does not appear.

I tracked this down to code that I have in the PreRender event for the parent grid to change the editcolumn text from "Edit" to "View" depending on the users selection and then rebind the grid. This event fires when I click the add/edit in the child grid and prevents the form from appearing. If I remove the rebind from the prerender event for the parent the text for the editcolumn no longer changes and the child grid no longer shows any data but the editform does appear when add/edit is selected. Additionally, when I do click the add/edit button and the form comes up, all of the rows that should have been shown the first time also appear.

Is there a way to get around the rebind in prerender so that I can swap the text for the editcolumn?

How can I refresh the child grid to show the records when it is rendered and keep them showing?

Any assistance is greatly appreciated!

Thanks,
Shawn

Iana Tsolova
Telerik team
 answered on 20 Dec 2010
12 answers
195 views
Hi All,

I might be missing something but I've got the RadFormDecorator set up in my project and this is styling all default form items in the desired style (a custom skin). However, any input fields which are using the RadInput aren't picking up the FormDecorator stylesheet and I can't seem to find anything in the documentation to suggest how to do this. Is there something really simple that I'm missing? I've tried setting the Skin path on the RadInput field to an empty string but still no joy.

Thanks in advance for any help,
Tim
Erik
Top achievements
Rank 2
 answered on 20 Dec 2010
2 answers
118 views
Dear Sir,

I am facing the following problem:
I want to add a custom attribute to a RadRotatorItem during databinding, but the method generated by the visual studio (when i double click on the proper event) is:

protected void ItemRotator_DataBound(object sender, EventArgs e) {...}
And I do not know how to get a reference to the specific item. 

I tried this
RadRotatorEventArgs Event = (RadRotatorEventArgs)e;
but I get an error at runtime


Is there a solution to my problem 
Thank you for your time...
Thomas Sarmis.
Thomas
Top achievements
Rank 1
 answered on 20 Dec 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?