This is a migrated thread and some comments may be shown as answers.

Grid in Combobox

12 Answers 105 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Siddharth
Top achievements
Rank 1
Siddharth asked on 17 Oct 2008, 02:58 PM
Hi,

I am trying to have Grid in Rad Combo Box. I am able to show grid in Combo Box but what i want to do is user should be able to filter items using grid filters. Only when he clicks on some row in grid then the information in that grid should be displayed in Combo box, the id which is hidden for any column should be accessible from Code behind.

Following is sample code that i am using.

Aspx Page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ 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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <telerik:radcombobox id="RadComboBox1" runat="server" skin="Office2007" width="100%"
                nowrap="True">
            <ItemTemplate>
                <div>
                    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None"
                        AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" OnNeedDataSource="RadGrid1_NeedDataSource"
                        EnableLinqExpressions="false" PageSize="100">
                        <MasterTableView AllowFilteringByColumn="true">
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                                    UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="false"
                                    Display="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Subject1" HeaderText="Subject" SortExpression="Subject1"
                                    UniqueName="Subject1" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="false"
                                    Display="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="RollNumber" HeaderText="Roll Number" SortExpression="RollNumber"
                                    UniqueName="RollNumber" CurrentFilterFunction="GreaterThan" AutoPostBackOnFilter="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Score" HeaderText="Score" SortExpression="Score"
                                    UniqueName="Score" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="false">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowColumnHide="True">
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                            <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" />
                        </ClientSettings>
                    </telerik:RadGrid>
                </div>
            </ItemTemplate>
            <Items>
                <telerik:RadComboBoxItem />
            </Items>
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </telerik:radcombobox>
        </div>
    </form>
</body>
</html>

Code Behind

using System;
using System.Web.UI;
using Telerik.Web.UI;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Marks m = new Marks(1, "sad", 221);
            ((RadGrid)RadComboBox1.Items[0].FindControl("RadGrid1")).DataSource = m.GetMarks();
            ((RadGrid)RadComboBox1.Items[0].FindControl("RadGrid1")).DataBind();
        }
    }

    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        Marks m = new Marks(1, "sad", 221);
        ((RadGrid)RadComboBox1.Items[0].FindControl("RadGrid1")).DataSource = m.GetMarks();
    }
}

Marks Class

using System.Collections.Generic;
using System.Web.Caching;

/// <summary>
/// Summary description for Marks
/// </summary>
public class Marks
{
    private int rollNumber;

    public int RollNumber
    {
        get { return rollNumber; }
        set { rollNumber = value; }
    }
    private string Subject;

    public string Subject1
    {
        get { return Subject; }
        set { Subject = value; }
    }
    private int score;

    public int Score
    {
        get { return score; }
        set { score = value; }
    }


    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }


    public Marks(int rNo, string Sub, int sc)
    {
        rollNumber = rNo;
        Subject = Sub;
        score = sc;
    }

    public Marks(int rNo, string Sub, int sc, string name)
    {
        rollNumber = rNo;
        Subject = Sub;
        score = sc;
        Name = name;
    }

    public List<Marks> GetMarks()
    {
        List<Marks> lstMarks = new List<Marks>();
        if (System.Web.HttpContext.Current.Cache["Values"] == null)
        {
            for (int i = 1; i <= 200; i++)
            {
                for (int j = 1; j < 4; j++)
                {
                    lstMarks.Add(new Marks(i, "Subject " + i.ToString(), i * j, "Name" + (i * j / i).ToString() + i.ToString() + j.ToString()));
                }
            }
            System.Web.HttpContext.Current.Cache["Values"] = lstMarks;
        }
        else
        {
            lstMarks = ( List<Marks>)System.Web.HttpContext.Current.Cache["Values"];
        }
        return lstMarks;
    }

}




12 Answers, 1 is accepted

Sort by
0
Siddharth
Top achievements
Rank 1
answered on 17 Oct 2008, 02:59 PM
How to apply Zip file in a forum :)
0
Simon
Telerik team
answered on 20 Oct 2008, 08:29 AM
Hello Siddharth,

File uploads are not allowed in the Forums. Please open a Support Ticket and send us the files there.

Note: Support Tickets are available after you have some downloads from your account.

All the best,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Siddharth
Top achievements
Rank 1
answered on 20 Oct 2008, 08:38 AM
Hi,

Currently i have copy pasted the Sample code here. Can you please answer the query looking at the code.
0
Simon
Telerik team
answered on 23 Oct 2008, 12:45 PM
Hello Siddharth,

Please see the attached page for details on the desired implementation.

Best wishes,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Siddharth
Top achievements
Rank 1
answered on 23 Oct 2008, 12:58 PM
Hi.

In the given example the combo Box does not minimize after clicling in filter, the filter menu doesnot show up. Secondly if i try to select dome value it give me an error

Line 57
Char 17
Object doesn't support this property or method.
0
Simon
Telerik team
answered on 24 Oct 2008, 02:58 PM
Hi Siddharth,

What do you mean by selecting a dome value? I tried to reproduce this error but unsuccessfully.

Additionally, the filter menu showed up correctly and the ComboBox minimized properly.

Please provide me with instructions on how to reproduce these issue at my side.

Best wishes,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Siddharth
Top achievements
Rank 1
answered on 27 Oct 2008, 04:41 AM
Hi.

In the given example the combo Box does not minimize after clicling in filter, the filter menu doesnot show up. Secondly if i try to select Some value from drop down then it gives me an error as below.

Line 57
Char 17
Object doesn't support this property or method.
0
Simon
Telerik team
answered on 29 Oct 2008, 03:40 PM
Hi Siddharth,

I tried once again to reproduce the issues at my side but to no avail.

Please open a formal support ticket and send us a page/project where the issues can be reproduced. We will inspect them thoroughly and hopefully will provide you with a solution/workaround.

Thank you in advance for you co-operation.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Siddharth
Top achievements
Rank 1
answered on 30 Oct 2008, 05:39 AM
Hi Simon,

I have logged it as a Bug in Support tickets. 

Ticket ID is: 170786

Hope i get a quick reply. Thanks in Advance.

Regards,
Siddharth Sathe

0
Siddharth
Top achievements
Rank 1
answered on 31 Oct 2008, 06:37 AM
Hi Simon,

I downloaded the latest version and the Javascript error is no longer present. But as soon as i filter the items from Grid or Sort items in Grid Dropdown closes which is not expected behavior. Any work around for this?
0
Accepted
Rosi
Telerik team
answered on 31 Oct 2008, 12:39 PM
Hi Siddharth,

Please find the attached modified project and try it.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Siddharth
Top achievements
Rank 1
answered on 31 Oct 2008, 01:05 PM
Hi,

The support give by Telerik team is awesome. Thanks a lot.
Tags
ComboBox
Asked by
Siddharth
Top achievements
Rank 1
Answers by
Siddharth
Top achievements
Rank 1
Simon
Telerik team
Rosi
Telerik team
Share this question
or