Filter on categories
Hi all,
I've a question on how to filter my products module by categories.
I have created a page which has the ProductView control from the Products Sample. This shows products.
On the left of the page I have a RadPanelBar which shows Categories with subcategories. (HierarchicalTaxon). Now what I like is that when you click on a category, the products view gets filtered by the category and all the subcategories that belong to this category. The URL should contain the category.
If I click on a subcategory, the products view should be filtered also.
I tried to build the URL using the TaxonomyEvaluator.BuilUrl, but it generates a URL which isn't of much use:
localhost/.../CategoriesTest
Is this scenario possible?
Thanks,
Daniel
Hello Daniel,
To apply filtering you need to subscribe for a command thrown by DynamicCommandWidgetElement- filterByResortl. You should build a filter of a dynamic LINQ and applies it on the MasterGridView. Here is a sample based on products module.
// called by the MasterGridView when it is loaded
function OnMasterViewLoaded(sender, args)
// the sender here is MasterGridView
var itemsGrid = sender.get_itemsGrid();
itemsGrid.add_command(handleItemsGridCommand);
function handleItemsGridCommand(sender, args)
switch
(args.get_commandName())
case
"filterByResort"
:
var id = args.get_commandArgument().get_dataItem().Id;
// here Colors is the filtered custom taxonomy
var filter =
"Colors.Contains("
+
'"'
+ id +
'"'
+
")"
;
sender.applyFilter(filter);
break
;
default
:
break
;
Colors.Contains
sender.applyFilter
you will clear the filtering.