HowTo: Custom sidebar widget

Posted by Community Admin on 04-Aug-2018 01:10

HowTo: Custom sidebar widget

All Replies

Posted by Community Admin on 06-Jan-2013 00:00

I followed these instructions to create custom sidebar widget for products sample module:
http://www.sitefinity.com/blogs/radoslavgeorgiev/posts/radoslav-georgievs-blog/2011/10/24/creating_custom_sidebar_widgets
I double checked that I followed instructions correctly.
But, some reason when I click on "By Categories..." I don't see anything (It is empty).
How can I trouble shoot what is going on there? Is there any detailed log output from sitefinity that I could use to understand what it not working?

I use Sitefinity 5.3.
Thanks,
Denis.

Posted by Community Admin on 07-Jan-2013 00:00

I did some additional investigation and finally made it work.

First of all, I figured out that dataBind command (in CustomDynamicCommandWidgetExtensionScript.js) is ignored if the widget is hidden. To force databinding I added extra line:

01.function OnMasterViewLoaded(sender, args)
02.    if (sender.get_sidebar())
03.        var widgetsInSidebar = sender.get_sidebar()._widgets;
04.        if (widgetsInSidebar)
05.            for (var i = 0; i < widgetsInSidebar.length; i++)
06.                if (Object.getTypeName(widgetsInSidebar[i]) == "ProductCatalogSample.Web.UI.CustomDynamicCommandWidget")
07.                    widgetsInSidebar[i]._hidden = false; //This line was added
08.                    widgetsInSidebar[i].dataBind();
09.                
10.            
11.        
12.    
13.

After that I was able to see categories with check boxes in the widget.

But when I tried to check checkboxes the widget failed with error message about missing get_dataItem() method from client side.
The reason was that command and arguments for command sent bt custom widget were incompatible. Widget was sending filterByCategory and arguments were filterExpression. But filterByCategory expectssingle taxon ID through get_dataItem():

case"filterByCategory":var taxonId=args.get_commandArgument().get_dataItem().Id;

So, after playing around, I found the way to send appropriate command name for supplied filterExpression:

1._binderCommandHandler: function (sender, args)
2.        //var commandEventArgs = new Telerik.Sitefinity.UI.CommandEventArgs(this._commandName, 'filterExpression': this.getCategoriesFilterExpression() );
3.        var commandEventArgs = new Telerik.Sitefinity.UI.CommandEventArgs('filter', 'filterExpression': this.getCategoriesFilterExpression() );
4.        //send a filtering command ot our grid view to fitler by the selected checkboxes
5.        //if there are no selected checkboxes the filtering expression will be empty string showing all items
6.        var h = this.get_events().getHandler('command');
7.        if (h) h(this, commandEventArgs);
8.    ,

In the line #3 you will see that I manually specified 'filter' command.
After this widget started work as expected. But I don't sure if this is the correct way.

Telerik, please confirm that what I've done is the correct way. Also, maybe, you want to update this article, because it is not correct anymore.

Also, please, take a look on the other my post.

Thanks,
Denis.

Posted by Community Admin on 09-Jan-2013 00:00

Hello,

Thank you for sharing with us this information. We will review it and then will make changes to our blog post.

Regards,
Stefani Tacheva
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 10-Jan-2013 00:00

Also, please, let me know if what I've done is correct way.
Also please let me know how I can subscribe to masterGridView.DataBound event (from ExternalClientScripts). So I can rebind widget each time databind occurs for master grid. Do you have any examples of doing this?  

Posted by Community Admin on 15-Jan-2013 00:00

Hi Denis,

The following blog post is created to help clients for their custom modules (modules created by Module Builder). The reason of the problem is coming from the fact that you are using this custom sidebar widget for our Ecommerce module, not for your custom modules. This module is customize and has different Grid and extensions on it. You were encountering problems, because of these different extensions and the only way to use the sample for Ecommerce mode is to modify it. We will not make changes to this blog post, because it was created to work for custom modules, not for the Ecommerce module. It seems that the line that you have added in OnMasterViewLoaded could be mandatory, because the dataBind for this Grid might receiving items that are not hidden. The binderCommandHandler should also be modified if you want your custom slidebar widget to work. We think that after it is working on your side, the changes you have made are correct.

Thank you again for sharing the information with the community.

Kind regards,
Stefani Tacheva
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Jan-2013 00:00

Hello,

As I stated in my fist message, I create custom widget for my custom module that is built based on Products SDK sample. I'm not using Ecommerse. I still believe that this blog post is outdated. I'm just trying to help others like me who is searching information here. And hope my post will help. It is up to you, of course, if you fix the blog post of not.

Posted by Community Admin on 21-Jan-2013 00:00

Hello,

Thank you again for sharing the information with the community.

We think that it might help a lot of people that are working with custom modules that are built based on Products SDK sample.

Kind regards,
Stefani Tacheva
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed