This is a migrated thread and some comments may be shown as answers.

Limit skin choices

4 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 01 Jan 2014, 06:18 AM
Using a radskinmanager with showchooser set to True

Is there a way to limit the choices shown in the dropdown?

I would just like to show Metro Touch and Default

thanks!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jan 2014, 05:58 AM
Hi Mike,

Please try the following code snippet to limit the choice for the skins.

ASPX:
<telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="True" OnPreRender="RadSkinManager1_PreRender" OnSkinChanged="RadSkinManager1_SkinChanged">
</telerik:RadSkinManager>

C#:
static string skin = "Default";
protected void RadSkinManager1_PreRender(object sender, EventArgs e)
{
    RadSkinManager1.Skin = skin;
    RadComboBox skinChooser = RadSkinManager1.FindControl("SkinChooser") as RadComboBox;
    foreach (RadComboBoxItem item in skinChooser.Items)
    {
        if ((item.Text == "MetroTouch") || (item.Text == "Default"))
        {
            item.Visible = true;
        }
        else
        {
            item.Visible = false;
        }
    }
}
  
protected void RadSkinManager1_SkinChanged(object sender, SkinChangedEventArgs e)
{
    RadSkinManager1.Skin = e.Skin;
    skin = e.Skin;
}

Thanks,
Princy
0
Mike
Top achievements
Rank 1
answered on 02 Jan 2014, 11:52 AM
Hi Princy,

Thanks for the quick reply.

Can I see the code in vb? 

I tried the converter but it failed.

Thanks!

Next time I will remember to state the code version in the initial request.
0
Princy
Top achievements
Rank 2
answered on 02 Jan 2014, 12:20 PM
Hi Mike,

Here is the code in VB

VB:
Shared skin As String = "Default"
Protected Sub RadSkinManager1_PreRender(sender As Object, e As EventArgs)
    RadSkinManager1.Skin = skin
    Dim skinChooser As RadComboBox = TryCast(RadSkinManager1.FindControl("SkinChooser"), RadComboBox)
    For Each item As RadComboBoxItem In skinChooser.Items
        If (item.Text = "MetroTouch") OrElse (item.Text = "Default") Then
            item.Visible = True
        Else
            item.Visible = False
        End If
    Next
End Sub
 
Protected Sub RadSkinManager1_SkinChanged(sender As Object, e As SkinChangedEventArgs)
    RadSkinManager1.Skin = e.Skin
    skin = e.Skin
End Sub

Thanks,
Princy
0
Mike
Top achievements
Rank 1
answered on 03 Jan 2014, 09:08 AM
thanks princy. worked well !


note: to any newbie looking at this post,  in the examples the character spacing is off, maybe removed by the text editor...

for example "ForEach" should be "For Each" etc.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or