I am using the TelerikUpload component.
Telerik.UI.for.Blazor version 9.0.0
Extra security checks (anti-virus etc.) are triggered in the Controller and depending on what caused an issue, I would like to change the default "File failed to upload" error message. Ideally this message would be set in the OnError handler, or maybe a ChildTemplate exists I am not aware of?
This post talks about changing the message through localization, but that does not allow me to change it at runtime:
public static List<AggregateFunctionsGroup>? DeserializeGroups<TGroupItem>(this List<AggregateFunctionsGroup> groups)
{
if (groups is null) return null;
for (int i = 0; i < groups.Count; i++)
{
var group = groups[i];
// Workaround for JsonElement -> string
if (group.Key is JsonElement elem && elem.ValueKind == JsonValueKind.String)
{
group.Key = elem.GetString();
}
if (group.HasSubgroups)
{
var subGroups = group.Items
.Cast<JsonElement>()
.Select(x => x.Deserialize<AggregateFunctionsGroup>())
.ToList();
group.Items = DeserializeGroups<TGroupItem>(subGroups);
}
else
{
var items = group.Items
.Cast<JsonElement>()
.Select(x => x.Deserialize<TGroupItem>())
.ToList();
group.Items = items;
}
}
return groups;
}
public async Task ReadItems(GridReadEventArgs args)
{
if (!ModelIsReady) return;
if (_readItemsPending) return;
if (string.IsNullOrWhiteSpace(PreparedQuery.Id)) return;
_readItemsPending = true;
try
{
var result = await ApiService.QueryDataSourceAsync<UniversalDSModel>(PreparedQuery.QueryId, args.Request, CancellationToken.None);
if (result is null) return;
if (args.Request.Groups.Count > 0)
{
args.Data = result?.GroupedData.DeserializeGroups<UniversalDSModel>();
}
else
{
args.Data = result?.CurrentPageData.Cast<object>().ToList();
}
if (result?.AggregateResults != null)
{
args.AggregateResults = result.AggregateResults;
}
if (result != null) { args.Total = result.TotalItemCount; }
}
catch (Exception ex)
{
Console.WriteLine($"Error loading data: {ex.Message}");
ApiRequestFailed = true;
}
finally
{
_readItemsPending = false;
LoaderContainerVisible = false;
}
}
so issue was when i uploading file that still in upload phase if i click the cancel button next upload progress bar the file is removes from ui but somewhere is still present
so i have used OnSelectHandler event to handle to duplicate uploading and some extra validation added in OnSelectHandler event but my issue is
when i am uploading file and immediately click [ Before upload process is done ] cancel then it remove from ui but somewhere is present after that remove click again try to add show my validation error that is duplicate message
Clicking Cancel should stop the upload process entirely, and no file should be uploaded or stored.
Please Refer Below Attachment
Step 1 => Select file eg. dummy.pdf and select Note : AutoUpload is true and check below screenshot and i click cancel button
Step 2 => The file removed from UI see below screenshot
Step 3 => If i try to add again same file i.e dummy.pdf the my custom validation msg show that is file is already present see below screenshot
Below is My Code :
I am using the TelerikUpload component with UploadChunkSettings defined.
Telerik.UI.for.Blazor version 9.0.0
When not using a chunked upload I can return a response body a read it in the success handler, however when code was changed to use chunks the response body is always empty.
Is this a bug when using chunked upload, or do I need to return a different response in the Controller?
Code from the save method in Api Controller:
string chunkMetaData = formData["chunkMetaData"].ToString();
ChunkMetaData chunkData = JsonConvert.DeserializeObject<ChunkMetaData>(chunkMetaData);
// Append chunks to file
// ...
if (chunkData.TotalChunks - 1 == chunkData.ChunkIndex)
{
uploadComplete = true;
fs.Flush();
}
// More code omitted ...
if (uploadComplete)
{
Response.StatusCode = StatusCodes.Status200OK;
await Response.WriteAsync(result.ResultId.ToString());
return new EmptyResult();
}
else
{
Response.StatusCode = StatusCodes.Status201Created;
await Response.WriteAsync("Chunk upload successful.");
return new EmptyResult();
}
OnSuccess handler:
protected async Task SuccessHandler(UploadSuccessEventArgs args)
{
int resultid = 0;
if (int.TryParse(args.Request.ResponseText, out resultid))
{
// do something with the resultid
// ...
// args.Request.ResponseText is always empty when using chunked upload
}
}
Documentation says to reset the layout by calling: dockManager.SetState(null);
Doing this via code doesn't seem to do anything. I've tried all combinations of the commented out code below.
<TelerikDockManager Height="100vh" OnStateChanged="OnStateChanged" OnStateInit="OnStateInit" @ref="dockManager">
...
</TelerikDockManager>
<TelerikButton Icon="SvgIcon.ArrowRotateCcw" OnClick="ResetState">Reset page layout</TelerikButton>
@code{
public TelerikDockManager dockManager { get; set; }
public async Task ResetState()
{
dockManager.SetState(null);
//dockManager.GetState();
//dockManager.Refresh();
//StateHasChanged();
await InvokeAsync(() => StateHasChanged());
}
}
public partial class TelerikTest
{
[Inject] public IJSRuntime JsRuntime { get; set; }
[Inject] public NavigationManager Navigation { get; set; }
private TelerikNotification NotificationReference { get; set; }
protected override void OnAfterRender(bool firstRender)
{
if (firstRender && Navigation.Uri.StartsWith("https"))
{
StateHasChanged();
ShowErrorNotification();
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && Navigation.Uri.StartsWith("https"))
{
await JsRuntime.InvokeVoidAsync("console.log", "Component rendered!");
StateHasChanged();
}
}
private void ShowErrorNotification()
{
NotificationReference.Show(new NotificationModel
{
Text = "An error has occurred!",
ThemeColor = ThemeConstants.Notification.ThemeColor.Error,
Closable = true,
CloseAfter = 20000
});
}
}
Hi, i have a grid with row filter.
1. I change filter operator from the relative button
2. I edit the search field column
The grid show me the correct results.
Now if i clear the search field column, the filter operator automatically reset to the default value and not keep the settings i choose in step 1.
You can reply the issue with the first example in grid documentation: https://www.telerik.com/blazor-ui/documentation/components/grid/overview
The filter operator must keep my initial settings
It's a bug? how to solve?
Thanks
I just get a spinning wheel when I bring up NuGet Package Manager and have the source set to Telerik.
If I select other package sources they load and display quickly.
Any suggestions?
I’m trying to build a custom filter for a column in the Telerik Grid. I’d like to have both the custom filter and the default filter available in the column's filter menu. I’ve managed to get the custom filter displaying and working correctly, but the default filter is not appearing in the filter menu for that column. I’ve attached the code — could you please help me figure out what’s missing or incorrect?
Many Thanks
<GridColumn Field="@nameof(StockVehicleRowDTO.PerformanceGrading)"
Title="Grade"
Lockable="true"
TextAlign="@ColumnTextAlign.Center"
Locked="true"
Width="120px"
Filterable="true">
<FilterMenuTemplate Context="context">
<div class="p-2">
<!-- Default Telerik Filter Menu -->
<TelerikGridFilterMenu Context="context" />
<hr />
<!-- Custom Checkbox Filter -->
<div>
<strong>Quick Grade Filter:</strong>
@foreach (var grade in GradeFilterOptions)
{
<div>
<TelerikCheckBox
Value="@(IsGradeChecked(context.FilterDescriptor, grade))"
ValueChanged="@((bool value) => OnGradeFilterChanged(value, grade, context.FilterDescriptor))"
Id="@($"grade_{grade}")">
</TelerikCheckBox>
<label for="@($"grade_{grade}")">@grade</label>
</div>
}
</div>
</div>
</FilterMenuTemplate>
<Template>
@{
var vehicleRow = (context as DDD.Application.Vehicles.ViewModels.StockVehicleRowDTO);
var grade = vehicleRow?.PerformanceGrading;
}
<GradeChip Grade="@grade" />
</Template>
</GridColumn>
Backend code..
// Grade filter options for the filter menu (dynamic from data)