Any way to dynamically toggle dark mode at client side?

1 Answer 91 Views
Grid Styling
gerry
Top achievements
Rank 1
gerry asked on 16 Feb 2025, 11:45 PM | edited on 16 Feb 2025, 11:45 PM

With the R2 2022 release Telerik added this support via a skin (BlackMetroTouch) but it seems it is limited to a server side setting and can't be done via client side? In particular I'm looking to do this for the RadGrid and change it via a user toggle and not have to make a post back to reload the page. Please let me know if there exists a way to do it at client-side.

Thanks,
Gerry

1 Answer, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 17 Feb 2025, 07:57 AM

Hello Gerry,

Due to the way the Controls were created, I am afraid that the only way to change the skin dynamically is from the server-side only and requires a PostBack to load the proper skin. While you can use the below code to change the Skin the way you wish via a button click, it will still refresh the page:

protected void RadButton1_Click(object sender, EventArgs e)
{
    string text = (sender as RadButton).Text;

    if (text.Contains("Dark"))
    {
        RadGrid1.Skin = "BlackMetroTouch";
        RadButton1.Text = "Toggle Default";
    }
    else
    {
        RadGrid1.Skin = "Default";
        RadButton1.Text = "Toggle Dark";
    }
}

    Regards,
    Vasko
    Progress Telerik

    Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
    gerry
    Top achievements
    Rank 1
    commented on 17 Feb 2025, 04:05 PM

    That was my expectation unfortunately. Given the history of these controls and long history with skins it's hard to get away from that. It is pretty wasteful to have to make the round trip to just set that. I guess I don't have a lot of options at this point. We need a lighter weight server control that supports server side setting of data but then lighter on the styling so that we can use modern CSS to easily style if (e.g. via Bootstrap, etc.).

    Thanks,
    Gerry

    Tags
    Grid Styling
    Asked by
    gerry
    Top achievements
    Rank 1
    Answers by
    Vasko
    Telerik team
    Share this question
    or