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

drop down filter created but no data

5 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 Aug 2008, 02:23 PM
I have almost got this implemented.  The samples with the country drop down list did not give a complete class for myCustomFilteringColumn, but I found it in other posts .  It successfully changes the control to a drop down list and fills it with data, but it requeries every time I run it.

Can this class be hooked to a sqldatasource in the main .aspx page ?

Or Any any idea how I would pass parameters to it so I can re-use the class ?

I have several different grids I want to add drop down filters to for "status" fields with limited choices and as this stands I would have to copy the class multiple times.





5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 Aug 2008, 08:10 AM
Hello David,

Please try the attached solution I've created for your convenience. I hope this helps!

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David
Top achievements
Rank 1
answered on 19 Aug 2008, 01:49 PM
Thank you very much for creating a sample for me, however, is a piece missing ?

A custom tag is registered and called

<%

@ Register TagPrefix="custom" Namespace="Filtering" Assembly="FilteringWithDDL" %>

But there is no class or dll called  FilteringWithDDL

Parser Error Message: Could not load file or assembly 'FilteringWithDDL' or one of its dependencies. The system cannot find the file specified.


I do have this running with a custom tag and a seperate mycustomfiltering class now, but to load the data I have to create a datatable every time the page posts back. I am hoping your example uses a datasource on the .aspx page

0
Nikita Gourme
Top achievements
Rank 1
answered on 22 Aug 2008, 12:57 PM
I suppose that the example the telerik guy posted uses a custom class for the column with dropdown list filter similar to the one shown here. Most probably you can set data source control for the combobox inside the overriden SetUpFilterControls method if you prefer.

Nikita
0
David
Top achievements
Rank 1
answered on 22 Aug 2008, 01:41 PM
I am setting the datasource inside a custom class.  But the problem with that is that if I have more than one drop down filter on a grid, I can't reuse the same control.

<custom:MyCustomFilteringColumn DataField="status" HeaderText="Status" UniqueName="TemplateColumn" SortExpression ="status">

<itemtemplate>

<%

#Eval("status")%>

</itemtemplate>

</custom:MyCustomFilteringColumn>

And since it is an over ride that adds properties, the only time it is referencedd is when it builds the .aspx page  ,

<custom:MyCustomFilteringColumn DataField="status" HeaderText="Status" UniqueName="TemplateColumn" SortExpression ="status">

<itemtemplate>

<%

#Eval("status")%>

</itemtemplate>

</custom:MyCustomFilteringColumn>



so I can not pass in parameters like a data source, or a variable control name.

Next version maybe they can cast filters as different controls and get a date range search back with the date picker  :)




0
Daniel
Telerik team
answered on 22 Aug 2008, 03:49 PM
Hello David,

The most important item in the project I sent you was the Filtering.cs itself. You can easily put this file in App_Code when you create new web page.

The above mentioned code was intended to give you general directions and help you create your own class by adapting the existing one.

You can use the exposed property ListDataSource in order to bind your column with the desired data.

foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns) 
    if (column is GridBoundColumnExtension) 
    { 
        if (column.UniqueName == "CustomerIDList") 
        { 
            DataTable dt = new DataTable(); 
            dt.Columns.Add("CompanyName"); 
            for (int i = 0; i < 5; i++) 
                dt.Rows.Add("CompanyName" + i); 
            (column as GridBoundColumnExtension).ListDataSource = dt
        } 
    } 
}  

If this example covers your expectations you may need to clean up the unnecessary code from the .cs file.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Daniel
Telerik team
David
Top achievements
Rank 1
Nikita Gourme
Top achievements
Rank 1
Share this question
or