public void Open(string title, RenderFragment <DialogService> childContent, DialogOptions options = null) { options = options ?? new DialogOptions(); options.ChildContent = childContent; OpenDialog <object>(title, null, options); }
/// <summary> /// Displays a confirmation dialog. /// </summary> /// <param name="message">The message displayed to the user.</param> /// <param name="title">The text displayed in the title bar of the dialog.</param> /// <param name="options">The options.</param> /// <returns><c>true</c> if the user clicked the OK button, <c>false</c> otherwise.</returns> public async Task <bool?> Confirm(string message = "Confirm?", string title = "Confirm", ConfirmOptions options = null) { var dialogOptions = new DialogOptions() { Width = options != null ? !string.IsNullOrEmpty(options.Width) ? options.Width : "355px" : "355px", Height = options != null ? options.Height : null, Left = options != null ? options.Left : null, Top = options != null ? options.Top : null, Bottom = options != null ? options.Bottom : null, ChildContent = options != null ? options.ChildContent : null, ShowTitle = options != null ? options.ShowTitle : true, ShowClose = options != null ? options.ShowClose : true, Resizable = options != null ? options.Resizable : false, Draggable = options != null ? options.Draggable : false, Style = options != null ? options.Style : "", AutoFocusFirstElement = options != null ? options.AutoFocusFirstElement : true, CloseDialogOnOverlayClick = options != null ? options.CloseDialogOnOverlayClick : false, }; await JSRuntime.InvokeAsync <string>("Radzen.openDialog", dialogOptions); return(await OpenAsync(title, ds => { RenderFragment content = b => { var i = 0; b.OpenElement(i++, "div"); b.OpenElement(i++, "p"); b.AddAttribute(i++, "style", "margin-bottom: 20px;"); b.AddContent(i++, message); b.CloseElement(); b.OpenElement(i++, "div"); b.AddAttribute(i++, "class", "row"); b.OpenElement(i++, "div"); b.AddAttribute(i++, "class", "col-md-12"); b.OpenComponent <Blazor.RadzenButton>(i++); b.AddAttribute(i++, "Text", options != null ? options.OkButtonText : "Ok"); b.AddAttribute(i++, "Style", "margin-bottom: 10px; width: 150px"); b.AddAttribute(i++, "Click", EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, () => ds.Close(true))); b.CloseComponent(); b.OpenComponent <Blazor.RadzenButton>(i++); b.AddAttribute(i++, "Text", options != null ? options.CancelButtonText : "Cancel"); b.AddAttribute(i++, "ButtonStyle", ButtonStyle.Secondary); b.AddAttribute(i++, "Style", "margin-bottom: 10px; margin-left: 10px; width: 150px"); b.AddAttribute(i++, "Click", EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, () => ds.Close(false))); b.CloseComponent(); b.CloseElement(); b.CloseElement(); b.CloseElement(); }; return content; }, dialogOptions)); }
private void OpenDialog <T>(string title, Dictionary <string, object> parameters, DialogOptions options) { dialogs.Add(new object()); OnOpen?.Invoke(title, typeof(T), parameters, new DialogOptions() { Width = options != null && !string.IsNullOrEmpty(options.Width) ? options.Width : "600px", Left = options != null && !string.IsNullOrEmpty(options.Left) ? options.Left : "", Top = options != null && !string.IsNullOrEmpty(options.Top) ? options.Top : "", Height = options != null && !string.IsNullOrEmpty(options.Height) ? options.Height : "", ShowTitle = options != null ? options.ShowTitle : true, ShowClose = options != null ? options.ShowClose : true, ChildContent = options?.ChildContent, Style = options != null ? options.Style : "", }); }
public Task <dynamic> OpenAsync(string title, RenderFragment <DialogService> childContent, DialogOptions options = null) { var task = new TaskCompletionSource <dynamic>(); tasks.Add(task); options = options ?? new DialogOptions(); options.ChildContent = childContent; OpenDialog <object>(title, null, options); return(task.Task); }
public Task <dynamic> OpenAsync <T>(string title, Dictionary <string, object> parameters = null, DialogOptions options = null) where T : ComponentBase { var task = new TaskCompletionSource <dynamic>(); tasks.Add(task); OpenDialog <T>(title, parameters, options); return(task.Task); }
public void Open <T>(string title, Dictionary <string, object> parameters = null, DialogOptions options = null) where T : ComponentBase { OpenDialog <T>(title, parameters, options); }
private void OpenDialog <T>(string title, Dictionary <string, object> parameters, DialogOptions options) { dialogs.Add(new object()); OnOpen?.Invoke(title, typeof(T), parameters, new DialogOptions() { Width = options != null && !string.IsNullOrEmpty(options.Width) ? options.Width : "600px", Left = options != null && !string.IsNullOrEmpty(options.Left) ? options.Left : "", Top = options != null && !string.IsNullOrEmpty(options.Top) ? options.Top : "", Bottom = options != null && !string.IsNullOrEmpty(options.Bottom) ? options.Bottom : "", Height = options != null && !string.IsNullOrEmpty(options.Height) ? options.Height : "", ShowTitle = options != null ? options.ShowTitle : true, ShowClose = options != null ? options.ShowClose : true, Resizable = options != null ? options.Resizable : false, Draggable = options != null ? options.Draggable : false, ChildContent = options?.ChildContent, Style = options != null ? options.Style : "", AutoFocusFirstElement = options != null ? options.AutoFocusFirstElement : true, CloseDialogOnOverlayClick = options != null ? options.CloseDialogOnOverlayClick : false, }); }