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

Include only some CSS styles in dropdown?

3 Answers 119 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Day
Top achievements
Rank 1
Day asked on 21 Dec 2010, 11:29 PM
I have a complex application with hundreds of styles.

I do need them to render in the editor (AJAX version).
I need users to be able to select some of them with the css styles dropdown, but not all of them.

If I include them in CssFiles, then they all go in the dropdown.
If I include them (instead or also) in CssClasses then it only renders the ones I specify.

I DO need users to see their content in context (meaning I need all the styles to be rendered by the editor) but many of them are not appropriate for the dropdown.

Worse, some of the definitions call for styling that look silly within the dropdown (e.g. boxes that have huge dimensions/margins/padding etc). It would be acceptable (but not preferable) for me to include my hundreds of styles in the dropdown as long as they weren't styled in the dropdown.

1) Is there a way to get the editor to render more classes than appear in the dropdown? 

2) If that's not possible, can I get the styles to not render in the dropdown itself?

DK

3 Answers, 1 is accepted

Sort by
0
Day
Top achievements
Rank 1
answered on 22 Dec 2010, 06:52 PM
I'm trying another angle on this. I've broken my big css file into several and am loading the appropriate css file depending on a parameter in the url.

In my codebehind, I have a line like:

Dim cssFile = "http://subdomain.domain.com/css/" + Request.Item("Definition") + ".css"
        TelerikEditor.CssFiles.Add(cssFile)

This works, to a degree.

I DO get my styles rendered, which is great as I've reduced the # of styles loaded drastically, but I do NOT get my styles listed in the dropdown, which was the whole point of my doing this.

It seems like it could have something to do with the fact that I'm loading the stylesheet from another domain (which I absolutely need to do).

Ideas?

ps. I've also used jQuery to also load the stylesheet into the body of the containing page (which seems to be a strategy others have used), to no avail. The stylesheet does seem to load (again) but it hasn't affected the dropdown.

    $(document).ready(function () {
        var cssFile = "http://subdomain.domain.com/css/" + getUrlVars().Definition + ".css";
        $("body").append("<link type='text/css' href='" + cssFile + "' ></link>");
    });
0
Accepted
Stanimir
Telerik team
answered on 24 Dec 2010, 12:13 PM
Hello Day,

Regarding the css files from other domain, this scenario is not supported because due to potential vulnerabilities the browser security does not allow the javascript to read the styles from the different domain. You should always load styles from the same domain or remove the css classes dropdown from the link manager.

Here is the online help article, which regards the Apply Css Class dropdown http://www.telerik.com/help/aspnet-ajax/cssstyles.html. You can find information on the css files collection in the following article: http://www.telerik.com/help/aspnet-ajax/externalcssfiles.html.

If that's not possible, can I get the styles to not render in the dropdown itself? - You can add the following javascript code to the page:
Telerik.Web.UI.Editor.ApplyClassDropDown.prototype._getClassCss = function (oRule)
{
    return "";
}


Regards,
Stanimir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Day
Top achievements
Rank 1
answered on 11 Jan 2011, 01:45 AM
The cross-domain issue is going to make things very sticky for me, as I need the (secure) editor to be on a different subdomain as the site that displays the content. But I guess it is what it is.
Thanks for the script. Works like a charm.
Tags
Editor
Asked by
Day
Top achievements
Rank 1
Answers by
Day
Top achievements
Rank 1
Stanimir
Telerik team
Share this question
or