PagesSelector events

Posted by Community Admin on 04-Aug-2018 11:48

PagesSelector events

All Replies

Posted by Community Admin on 07-Jun-2011 00:00

The PagesSelector control has 2 buttons - Cancel and Done Selecting.

How can I attach 2 custom javascript functions and in the one attached to Done Selecting to get the selected page guid (if internal selection is used) or the external link / name (if From Other site options is used)

Thank you!

Posted by Community Admin on 10-Jun-2011 00:00

Hello FlR,

We are sorry for the delayed answer. When the Cancel and Done selecting buttons are pressed a javascript event is fired. The event name is doneClientSelection and you can subscribe for it with the add_doneClientSelection method of the PagesSelector client object. The handler for this event should have two parameters: selectedPages - an array with the selected pages and isCanceled - a boolean value holding information whether the Cancel button is clicked. When isCanceled is true then selectedPages is null.
You can use the following code snippet:

_pagesSelector.add_doneClientSelection(doneClientSelectionHandler);
 
function doneClientSelectionHandler (selectedPages, isCanceled)
    if (isCanceled)
        return;
    for (var i = 0, l = selectedPages.length; i < l; i++)
        var page = selectedPages[i];
        if (page.Url) //the page is external
            // you can use page.Url and page page.Title
        else // the page is internal
            // you can use page.Id and page page.Title
    

I hope this helps.

Best wishes,
Ivan Pelovski
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 13-Jun-2011 00:00

Hi Ivan,

Thank you! One last question - How do I get the js reference of PageSelector server side control.

For example - if I have this declaration:
<sf:PagesSelector runat="server" ID="pageSelector" AllowExternalPagesSelection="true"     AllowMultipleSelection="false">

How do I get in js it's reference (in your sample _pageSelector)

Posted by Community Admin on 13-Jun-2011 00:00

Hi FlR,

You can get the script references by overriding GetScriptDescriptors

public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()
       
            var descriptors = new List<ScriptDescriptor>();
            var descriptor = (ScriptControlDescriptor)this.GetBaseScriptDescriptors().Last();            
            descriptors.Add(descriptor);
            return descriptors;

       

        internal virtual IEnumerable<ScriptDescriptor> GetBaseScriptDescriptors()
       
            var scriptDescriptors = new List<ScriptDescriptor>(base.GetScriptDescriptors());
            var scriptControlDescriptor = scriptDescriptors.Where(sd => typeof(ScriptControlDescriptor).IsAssignableFrom(sd.GetType())).First() as ScriptControlDescriptor;
            scriptControlDescriptor.Type = typeof(HtmlField).FullName;
            return scriptDescriptors;
       

        public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
       
            var scripts = new List<ScriptReference>(base.GetScriptReferences());           
            return scripts;
       

Kind regards,
Ivan Dimitrov
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 15-Jun-2011 00:00

I want to use this from a user control (System.Web.UI.UserControl) which is in a admin module page; therefore I cannot override those methods - I'm not using it from a designer view.

Is there another way to access it from javascript?

Posted by Community Admin on 20-Jun-2011 00:00

Hi FlR,

These methods are part of IScriptControl interface, so you should be able to use them.

All the best,
Ivan Dimitrov
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 06-Aug-2011 00:00

Hi Ivan,

I have made my custom designer successfully. I just wanted to know if I can make pages already selected/checked in PagesSelector?

Posted by Community Admin on 09-Aug-2011 00:00

Hi Saad,

You need a function that will select the item again

_pageSelected: function (items)
        if (items == null)
            return;
        var selectedItem = this.get_pageSelector().getSelectedItems()[0];
        if (selectedItem)
         
       
    ,

Best wishes,
Ivan Dimitrov
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