dynamically populated repeater

kyle shapiro asked on February 6, 2015 23:27

I want to have a repeater change depending on what is selected in a dropdownlist. A where condition in the repeater properties like CONTENT_MyOffice.OfficeState = 'TX' works great for showing the repeater items (they are offices) that have 'TX' as the OfficeState property. But this is not dynamic. The only way that I know of to add a dropdownlist in kentico is through a form. Is there something I can add like {% myDropDownList.selected @%} that would replace the 'TX' in that where condition that will grab the value of a selected value of a dropdown list? Is there a way to add a dropdownlist without creating a form object? I don't need to submit anything. I use the Portal engine.

Recent Answers


Virgil Carroll answered on February 9, 2015 15:49

You should look at developing a custom filter, you can learn more about it here: https://docs.kentico.com/display/K8/Developing+custom+filters

With a custom filter you can easily tie it to a datasource (which would run the repeater connection) and filter using any type of control you want.

Hope that helps.

0 votesVote for this answer Mark as a Correct answer

kyle shapiro answered on February 9, 2015 19:38

Thank you Virgil Carroll, however I was unable to follow the guide https://docs.kentico.com/display/K8/Developing+custom+filters successfully. My filter web-part is not working. Here is a run through of what I have done:

  • Create a folder CMSGlobalFiles in C:\inetpub\wwwroot\Kentico82\CMS
  • Create files CustomProductFilter.ascx and CustomProductFilter.ascx.cs within CMSGlobalFiles folder
  • Paste into CustomProductFilter.ascx the filter control markup.
  • Paste into CustomProductFilter.ascx.cs the first two chunks of code.
  • Paste into CustomProductFilter.ascx.cs the remaining chunks of code (within the {} of class CMSGlobalFiles_CustomProductFilter)
  • On the corporate site, add a new blank page under Products "Filtered Products"
  • Add a Pages Data Source webpart to zoneA with a path of /Products/% and a page type of CMS.Product and a filter name of CustomProductFilter
  • Add a filter webpart to zoneA with a filter name of CustomProductFilter a filter control path of ~/CMSGlobalFiles/CustomProductFilter.ascx
  • Add a Basic Repeater webpart to zoneA with a Transformation name of CMS.Product.CorporateSite and a Data source name of PagesDataSource

The filter does not display anything on the design tab while web part content is checked. I feel like the table with dropdown lists from CustomProductFilter.ascx should at least display, even if the content is not being loaded properly. The repeater repeats the 7 pages of type product. Please let me know if you have any advice or suggestions.

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on February 9, 2015 20:41

Kyle,

The link I sent was really more of an example than a working model from the documentation. If you don't actually have the ecommerce side set-up then it would not display anything. The InitializeOrder() is creating a list itself, but the InitializeDepartments() is actually pulling from the ecommerce system.

In Kentico there is a lot of internal error handling where you won't necessarily get your traditional .NET error page all the time. I have often found that when one part errors out, sometimes it will not even display. It could be the case in this instance. I would also take a look at the Event Logs and see if you see something through there. You can also deploy the code as demonstrated, attach a debugger and step through to see where it is erred out. Lastly I would make sure you have the right path to the filter ASCX you created. The path can sometimes be tricky depending on where you deployed it in your solution.

Overall I would use it as a framework for how you should build yours, not try to duplicate exactly.

1 votesVote for this answer Mark as a Correct answer

kyle shapiro answered on February 9, 2015 21:13

Thank you Virgil. I will try your advice, and post here if I figure it out.

0 votesVote for this answer Mark as a Correct answer

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