Bullet list only

2 posts, 0 answers
  1. John
    John avatar
    3 posts
    Member since:
    Sep 2007

    Posted 18 Jul Link to this post

    Is there a way to programmatically set the editor to an unordered list and keep it in that mode, so the user can only enter bullets?
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 21 Jul Link to this post

    Hi John,

    You can implement such a logic by handling the OnClientCommandExecuting event and prevent EnterNewLine to remove a list item. Something like this:

    <telerik:RadEditor runat="server" ID="RadEditor1"
        OnClientCommandExecuting="OnClientCommandExecuting">
        <Content>
            <ul>
                <li></li>
            </ul>
        </Content>
    </telerik:RadEditor>
     
    <script>
        function OnClientCommandExecuting(sender, args) {
            var editorUtils = Telerik.Web.UI.Editor.Utils;
            var command = args.get_commandName();
            var selElm = sender.getSelectedElement();
            var isEmptyLi = selElm.nodeName === "LI" &&
                            editorUtils.isEmptyDom(selElm.firstChild);
     
            if (command === "EnterNewLine" && isEmptyLi) {
                args.set_cancel(true);
            }
        }
    </script>

    If you need to also prevent the backspace key, you should rather do that by using the OnClientLoad event

    Regards,
    Ianko
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top