CheckBoxes Custom Field in Documents & Files Module

Posted by Community Admin on 03-Aug-2018 09:14

CheckBoxes Custom Field in Documents & Files Module

All Replies

Posted by Community Admin on 19-May-2011 00:00

Hello

I want to create a custom filed of checkboxes in the document & files, Where I can check multiple values.

To do this I wrote some code and I got the check boxes list but i am unable to select multiple values or more than one values. On selecting more than one product I am getting this error on popup.
There was an error deserializing the object of type Telerik.Sitefinity.Web.Services.ContentItemContext`1[[Telerik.Sitefinity.Libraries.Model.Document, Telerik.Sitefinity.Model, Version=4.1.1339.0, Culture=neutral, PublicKeyToken=b28c218413bdf563]]. End element 'TEEST' from namespace '' expected. Found element 'item' from namespace ''.
I created a number of classes and a desinger(User control which I inherited from ChoiceField)


Images and Code is attached for the guidance.. Please help me as soon as posssible.

Thanks Alot.

Posted by Community Admin on 19-May-2011 00:00

I am unable to upload my code thats why writing it here.
I created 3 classes and a control.

ProductCheckList.ascx
ProductCheckList.cs
SimplechklstFieldDefinition.cs
SimplechklstFieldElement.cs



ProductCheckList.ascx code is below

<%@ Control Language="C#" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
    TagPrefix="sf" %>
<sf:ConditionalTemplateContainer ID="conditionalTemplate" runat="server">
    <Templates>
        <sf:ConditionalTemplate ID="ConditionalTemplate2" Left="RenderChoicesAs" Operator="Equal"
            Right="CheckBoxes" runat="server">
            <sf:SitefinityLabel ID="titleLabel" runat="server" WrapperTagName="div" HideIfNoText="true"
                CssClass="sfTxtLbl" />
            <asp:CheckBoxList ID="checkBoxes" runat="server" RepeatLayout="Flow" CssClass="sfCheckListBox sfFieldWrp">
            </asp:CheckBoxList>
        </sf:ConditionalTemplate>
    </Templates>
</sf:ConditionalTemplateContainer>
<sf:SitefinityLabel ID="descriptionLabel" runat="server" WrapperTagName="div" HideIfNoText="true"
    CssClass="sfDescription" />
<sf:SitefinityLabel ID="exampleLabel" runat="server" WrapperTagName="div" HideIfNoText="true"
    CssClass="sfExample" />



ProductCheckList.cs code is below

namespace JPC.Common.Controls.OtherControls

    [FieldDefinitionElement(typeof(JPC.Common.Controls.OtherControls.SimplechklstFieldElement))]
    public class ChoiceCheckListFieldCustom : ChoiceField
   
        public ChoiceCheckListFieldCustom()
       
            this.RenderChoicesAs = Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.CheckBoxes;
       


        protected override void CreateChildControls()
       
            Telerik.Sitefinity.Lists.Model.List Lst = App.WorkWith().Lists().Where(L => L.Title == "Product Lists").Get().FirstOrDefault();
            var IE = Lst.ListItems.Where(l => l.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).OrderBy(o => o.Ordinal);
            string UrlProductList = string.Empty;
            ChoiceItem cii = new ChoiceItem() Text = "Please Select", Value = Guid.Empty.ToString() ;
            this.Choices.Add(cii);
            foreach (Telerik.Sitefinity.Lists.Model.ListItem Items in IE)
           
                var Link_ = GetUrl(Convert.ToString(Telerik.Sitefinity.Model.DataExtensions.GetValue(Items, "Link")));
                PageNode pg = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(p => p.GetUrl() == ("~" + Link_)).Get().FirstOrDefault();
                if (pg != null)
               
                    UrlProductList = pg.GetUrl();
                    foreach (PageNode P in pg.Nodes)
                   
                        if (P.ShowInNavigation)
                       
                            ChoiceItem ci = new ChoiceItem()
                           
                                Text = P.Title.ToString(),
                                Value = P.Id.ToString(),
                            ;
                            this.Choices.Add(ci);
                       
                   
               
           
            base.CreateChildControls();
       


        protected override string LayoutTemplateName
       
            get
           
                return ChoiceCheckListFieldCustom.layoutTempalte;
           
       
        public string GetUrl(string Url)
       
            try
           
                if (!string.IsNullOrEmpty(Url))
               
                    if (Url.Substring(Url.Length - 1, 1) == "/")
                        Url = Url.Substring(0, Url.Length - 1);
                    if (Url.Substring(0, 1) != "/")
                        Url = "/" + Url;
                    return Url;
               
           
            catch (Exception ex)
           
                Classes.BLL.ErrorLogging("Side Nav => " + ex.Message);
           
            return string.Empty;
       




        public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()
       
            var descriptors = base.GetScriptDescriptors();


            var descriptor = (ScriptControlDescriptor)descriptors.Last();
            descriptor.Type = typeof(ChoiceField).FullName;


            return descriptors;
       


        private const string layoutTempalte = "JPC.Common.Controls.OtherControls.ProductCheckList.ascx";


   



SimplechklstFieldDefinition.cs code is below

namespace JPC.Common.Controls.OtherControls

    /// <summary>
    /// A control definition for the simple image field
    /// </summary>
    public class SimplechklstFieldDefinition : Telerik.Sitefinity.Web.UI.Fields.Definitions.ChoiceFieldDefinition
   
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleImageFieldDefinition"/> class.
        /// </summary>
        public SimplechklstFieldDefinition()
            : base()
       
       


        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleImageFieldDefinition"/> class.
        /// </summary>
        /// <param name="element">The configuration element used to persist the control definition.</param>
        public SimplechklstFieldDefinition(ConfigElement element)
            : base(element)
       
       
   



SimplechklstFieldElement.cs code is below

namespace JPC.Common.Controls.OtherControls

    /// <summary>
    /// A configuration element used to persist the properties of <see cref="SimpleImageFieldDefinition"/>
    /// </summary>
    public class SimplechklstFieldElement : Telerik.Sitefinity.Web.UI.Fields.Config.ChoiceFieldElement
   
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleImageFieldElement"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        public SimplechklstFieldElement(ConfigElement parent)
            : base(parent)
        //Telerik.Sitefinity.Web.UI.Fields.Config.
       


        /// <summary>
        /// Gets an instance of the <see cref="SimpleImageFieldDefinition"/> class.
        /// </summary>
        /// <returns></returns>
        public override DefinitionBase GetDefinition()
       
            return new SimplechklstFieldDefinition(this);
       


   



Thanks In Advance! Hepl me plz

Thanks

Posted by Community Admin on 19-May-2011 00:00

Any one plzzzz?

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

hello!......Any one from telerik team?

Tell me if you know the solution otherwise deny me that it is not possible in available release.

Posted by Community Admin on 24-May-2011 00:00

Hi waqar,

We have tested this behavior and identified a bug in our WCF services. The problem is not with the ChoiceField control. I have been looking for a workaround to provide until we fix the issue, however I have been unable to find one. You can track the bug progress from here.

Best wishes,
Radoslav Georgiev
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 24-May-2011 00:00

Thanks for the reply,

Please let me know ASAP about the workaround.
One more thing, Will I get some telerik points for helping in identifying this bug?

Thanks!

Posted by Community Admin on 26-May-2011 00:00

Any workaround?

Posted by Community Admin on 26-May-2011 00:00

Hello waqar,

I have updated your points. Unfortunately we do not have a workaround for this.

Best wishes,
Radoslav Georgiev
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