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

filtering radgrid with dropdown

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 1
Veteran
MBEN asked on 12 Sep 2012, 08:53 PM
I have a radgrid in which I create a table and assign it to the Controls for an item in the Itemdatabound event as below.
I want to filter the PayoutType column based on a given list (ex , Retirement, Termination, Withdrawal). The table cell can any number of these values for one row. But since it is not bound to a database column I am unable to filter it.

Could you tell me how I can fiter in this scenario?

protected void rgPayoutElections_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            int accountID = Int32.Parse(item.GetDataKeyValue("AccountID").ToString());
            DataRow[] dr = PayoutElection.GetPayouts_ByAccount_ListByParticipant(Int32.Parse(Profile.ParticipantID), accountID);
             
            Table tblPayoutType = new Table();
            foreach (DataRow row in dr)
            {
                TableRow trPayoutType = new TableRow();
 
                TableCell cellPayoutType = new TableCell();
                cellPayoutType.Text = row["PayoutType"].ToString();
                cellPayoutType.CssClass = "textRed";
                trPayoutType.Cells.Add(cellPayoutType);
                tblPayoutType.Rows.Add(trPayoutType);           
            }
            item["PayoutType"].Controls.Add(tblPayoutType);
       }
    }

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 17 Sep 2012, 10:55 AM
Hello,

I am not sure that I understand correctly what your requirement is. From the code you have shared I see that you add a Table control to the controls collection of each row in RadGrid. However, in order to filter the Grid you need to use some input control. The Table control is not an input control.

Based on the title of the thread, I assume that you will use dropdown control. Where the dropdown control will be located? You could hook the SelectedIndexChanged event of the dropdown control and in its body you could change the filter expression of the MasterTableView and thus you will achieve your goal.

You could check this online demo application which demonstrates similar approach. Another approach is shown in this online demo application.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
MBEN
Top achievements
Rank 1
Veteran
Answers by
Andrey
Telerik team
Share this question
or