Unplanned
Last Updated: 02 May 2024 08:47 by ADMIN
Bo
Created on: 23 Apr 2024 06:57
Category: TreeList
Type: Feature Request
0
Ability to provide custom css classes

I would like to be able to apply custom css classes to all your controls.

 

Whenever I want to i.e. set the width of a control, I find it's a hassle to figure out which of your css classes I have to override.

It would be much better and easier for me to work with, if I could just apply a custom css class.

 

Thanks,

Bo Johansen

3 comments
ADMIN
Alexander
Posted on: 02 May 2024 08:47

Hi Bo Johansen,

I indeed agree with you that there are some TagHelper that are currently lacking the "html-attributes" configuration. This would be a fairly large initiative in order to assess whether the majority of component could employ this configuration and there are no potential drawbacks.

Your feedback here is indeed valid, and I personally agree with you that such a feature would indeed be helpful to the community.

We will monitor this item in order to see the community's interest.

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Bo
Posted on: 01 May 2024 08:33

I use your taghelpers when creating i.e. a form.

In kendo-form I can use a textbox-editor and as far as I can see in IntelliSense, there's no "html-attributes" attribute, so I don't know how to set the width of such an editor.

In this case it would be great if I was able to assign a custom css class to a specific element instead of figuring out how to override one of your css classes.

 

Thanks,

Bo Johansen

 

ADMIN
Alexander
Posted on: 30 Apr 2024 05:00

Hi Bo Johansen,

I hope you are doing well!

Generally, the majority of our controls expose their own .HtmlAttributes() API configuration which allows you to deliberately place arbitrary HTML attributes to the elements that wrap together the component. In the context of the TreeList, this would look something like the following:

<style>
    .smallTreeList {
        width: 50%;
    }
</style>   
 
@(Html.Kendo().TreeList<EmployeeDirectoryModel>()
    .Name("treelist")
    .Columns(columns =>
    {
        ...
    })
    .HtmlAttributes(new {@class = "smallTreeList"})
     ...
)

In cases in which the style rules are not applied, there may be some selectors coming from the themes with higher specificity. This can be circumvented by explicitly placing the !important property. I personally use this as a rule of thumb when I try to override existing classes.

That being said some of the controls offer setting HtmlAttributes through other configurations as well. Thus, my personal recommendation here would be to use the server-side API as a navigator, so to speak.

Additionally, I would also recommend the following blog post when it comes to inspecting existing elements in the DOM:

Here is a Telerik REPL example that showcases the aforementioned snippet:

I hope this proves helpful.

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.