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

Forums / Developing with Sitefinity / RadComboBox for metafield in admin panel

RadComboBox for metafield in admin panel

7 posts, 1 answered
  1. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    13 Oct 2010
    Link to this post
    Hi,
    I added a few metafields to News items and I'm trying to add RadComboBoxes to edit them in the admin panels. I need to add a combobox which allow to either choose an existing value from the dropdown (populated in server code) or enter a new value. Below is how I set up the RadComboBox.
    Problem is when I hit the save button the validation works correctly, but the values entered by the user are not saved, only values picked from the dropdown are saved. Do I need to use a different approach?

    Thank you,
    Alessio

    <li class="catSel clearfix">
        <asp:Label ID="Label2" AssociatedControlID="Ambito" Text="Ambito" runat="server" />
        <telerik:RadComboBox ID="Ambito" EnableEmbeddedSkins="true" Skin="WebBlue" runat="server"
            AllowCustomText="True">
            <Items>
                <telerik:RadComboBoxItem Value="" Text="" />
            </Items>
        </telerik:RadComboBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Ambito"
            Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"
            ValidationGroup="EditNews">
            <strong>È obbligatorio selezionare un ambito.</strong>
        </asp:RequiredFieldValidator>
    </li>

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Oct 2010
    Link to this post
    Hi Alessio,

    By default we persist only controls that implements ITextControl, ICheckBoxControl, RadDateInput and RadDatePicker controls. You need to create a custom or user control that implements ITextControl and inside this control you can add your RadComboBox.

    Another option is persisting the values manually by overriding the views - NewsItemEdit and NewsItemNew and replacing the default views,but this is more complicated way.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    15 Oct 2010
    Link to this post
    RadComboBox already implements ITextControl though. The value entered by the user then is not stored in the Text property?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Oct 2010
    Link to this post
    Hello Alessio ,

    If the control is not added inside ContentMetaFields custom control your values will not be persisted. Could you verify the the control you use is added inside the the default ContentMetaFields control declared into the template.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    15 Oct 2010
    Link to this post
    It's already inside it (see below). I've also added exactly the same empty labels/tags as I see near other persisted controls but no effect, it still saves only values picked from the dropdown.

    <sf:ContentMetaFields ID="MetaFields" runat="server">
        <ItemTemplate>
            ...
        <fieldset class="set">
            <ol class="setIn">
            <li class="catSel clearfix">
                <asp:Label ID="Label9" AssociatedControlID="TipoAgevolazione" runat="server">
                <asp:Literal ID="Literal4" runat="server" Text="Tipo di agevolazione"></asp:Literal>
                <em id="TipoAgevolazioneLabel" runat="server"></em></asp:Label>
                <telerik:RadComboBox ID="TipoAgevolazione" EnableEmbeddedSkins="true" Skin="WebBlue"
                runat="server" AllowCustomText="True" ShowDropDownOnTextboxClick="False">
                <Items>
                    <telerik:RadComboBoxItem Value="" Text="" />
                </Items>
                </telerik:RadComboBox>
                <asp:RequiredFieldValidator ID="TipoAgevolazioneValidator" runat="server" ControlToValidate="TipoAgevolazione"
                Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"
                ValidationGroup="EditNews">
                <strong>È obbligatorio selezionare un tipo di agevolazione.</strong>
                </asp:RequiredFieldValidator>
            </li>
            ...
            </ol>
        </fieldset>
        ...
        </ItemTemplate>
    </sf:ContentMetaFields>

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Oct 2010
    Link to this post
    Hello Alessio,

    You cannot use RadComboBox control. When the control is cast to ITextControl there is not value for the Text property. You need to persist the value or using a user or custom control that implements ITextControl interface. You have to return

    ((Telerik.Web.UI.RadComboBox)(ctrl)).SelectedItem.Text

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  7. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    18 Oct 2010
    Link to this post
    Thank you, I made a UserControl wrapping the box and it works fine.
Register for webinar
7 posts, 1 answered