1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Manual Array Guid Support

Manual Array Guid Support

5 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    09 Jul 2012
    Link to this post
    If I have a custom control that has a Guid[] field, how can I set that property in a custom designer?  I'm trying to create a clientside array or a JSON string, but neither seem to work

    (I suppose I could store as a JSON string and parse that out in the code back to Guid[], but I was hoping there was a built-in direct method?

    var selectedForms = [];
            var formBox = $find("formsListBox");
            var items = formBox.get_items();
            for (var i = 0; i < items.get_count(); i++) {
               if(formBox.getItem(i).get_selected()){
                   var item = formBox.getItem(i);
                   //Add to array
                   selectedForms.push(item.get_value());
               }
            }
     
            controlData.FormIDs = selectedForms; //Nope
     //       controlData.FormIDs = JSON.stringify(selectedForms); //Nope
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    12 Jul 2012
    Link to this post
    Hello Steve,

    That's a tough one, you can try using Rado's approach from this blog post, which deals with a similar scenario and uses KnockoutJS.

    Regards,
    Boyan Barnev
    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
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    12 Jul 2012
    Link to this post
    I've already done that (one better, Kendo MVVM http://www.screencast.com/t/8qgVeaFOzjq :)

    So is what you're saying that if I have a property defined like this
    public Guid[] GuidItems{get;set;}

    ...then the JS to persist that back is just
    var selectedForms = ["<guid>","<guid>"];
    controlData.SelectedForms = selectedForms;

    What's the underlying type of a "Guid Array" field.... Guid[], List<Guid>, Array?...?
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    13 Jul 2012
    Link to this post
    Hello Steve,

    The field type is Guid[]. Here's a recent example on how we're setting it server side:
    personalInformationItem.SetValue("ProfessionalExperience", new Guid[] { Guid.NewGuid(), Guid.NewGuid() });


    Greetings,
    Boyan Barnev
    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
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    13 Jul 2012
    Link to this post
    What about client though?  Should it be set back with an object array like I posted?

    Like controlData.SelectedForms = selectedForms; should auto-save back from the designer to the backing field right?
5 posts, 0 answered