Completed
Last Updated: 22 Jun 2023 11:17 by ADMIN
Release 4.4.0 (07/19/2023) (R3 PI1)
Aleksandr
Created on: 29 Aug 2021 10:00
Category: Dialog
Type: Feature Request
13
Default Text parameter for Prompt dialog

I want to fill the textbox of the prompt with predefined text, can we have that same behavior like in kendo https://docs.telerik.com/kendo-ui/api/javascript/kendo/methods/prompt?

 

---------

ADMIN EDIT

Here is a workaround

 

@inject IJSRuntime _js

<TelerikButton OnClick="@PromptWithText">Workaround</TelerikButton>

@code{
    [CascadingParameter]
    public DialogFactory Dialogs { get; set; }

    async Task PromptWithText()
    {
        // the workaround - invoke a script that will set the input value with a delay
        await _js.InvokeVoidAsync("setPromptDefaultText", "predefined prompt value");

        // do the prompts as usual
        string prompt = await Dialogs.PromptAsync("Enter something");
        Console.WriteLine(prompt);
    }
}

@* move this script to a proper location, this is a hack 
    to put in the blazor component so the workaround is easy to copy and run *@
<script suppress-error="BL9992">
    function setPromptDefaultText(defText) {
        setTimeout(function(){
            var promptInput = document.querySelector(".k-prompt-container .k-textbox .k-input-inner");
            if(promptInput) {
                promptInput.value = defText;
                promptInput.dispatchEvent(new Event('input', {bubbles: true} ));
            }
        }, 50); // a timeout so the prompt can render first
    }
</script>

 

---------

0 comments