Custom Filter and the FilteredControl Property

Delford Chaffin asked on July 10, 2014 20:12

Following this guide:

http://devnet.kentico.com/docs/7_0/devguide/index.html

I'm creating a filter that will filter a data source that selects documents of multiple types. So, in the Documents Data Source web part, I set the Document Types to "CMS.MenuItem;Webinar". Currently, in building the drop down list for my filter, I have:

this.ddlResourceType.Items.Add(new ListItem("-select-", ""));
this.ddlResourceType.Items.Add(new ListItem("Page", "3439"));
this.ddlResourceType.Items.Add(new ListItem("Webinar", "3455"));

I would like to move away from this approach of hard-coding those document types like that. I see in the API, there is a FilteredControl property, but it doesn't seem to work. Is there a way to pull the list of Document Types from the Data Source web part while inside the code for my filter?

Thanks!

Recent Answers


Brenden Kehren answered on July 11, 2014 06:44

In your filter control you should be able to use a cms:UniSelector. Set the ObjectType = "cms.class", ReturnColumnName = "ClassID", SelectionMode = "SingleDropDownList" and you will have all the classes in your system listed in that dropdown.

0 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on July 11, 2014 12:02

Hmm ... that's interesting. Thanks! But, I don't really want ALL the types - only the ones specified by the Data Source Web Part.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 11, 2014 21:21

Maybe I'm misunderstanding your question/requirements then. How a filter works is it's connected to a datasource and the datasource is connected to a listing control. The filter generates the WHERE, ORDERBY, TOPN, etc. values it passes them to the datasource before the datasource queries the database.

The FilteredControl property is simply a string for the ID of the "filter" I mentioned above, usually set via the webpart.

0 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on July 18, 2014 17:47

I have a Repeater web part with a Filter attached to it. To populate a drop down list in the filter, I'm currently hard-coding the Document Types in there:

this.ddlResourceType.Items.Add(new ListItem("Webinar", "3455"));

This works for now, but I'd rather pull those types dynamically. In the Repeater control properties, under Content Filter > Document Types, I select the types of items that the repeater shows. This list is what I would like to be able to pull dynamically into the filter.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.