Hi Richard,
Greetings from Syncfusion support.
Since the Blazor WebAssembly does run the .NET code on an interpreter, normally blazor wasm is 20x slower than blazor server side. So, the default selection in server side takes 100ms then it will take 2s in wasm.
Please refer the general link below,
So we suggest you to use the workaround to overcome this default wasm behavior. And we will improve virtualization feature in our upcoming Volume 2, 2020 release.
Please get back to us if you need further assistance.
Regards,Renjith Singh Rajendran
|
private bool shouldRender;
protected override bool ShouldRender() => shouldRender;
List<Order> _orders = Enumerable.Range(0, 500).Select(x => new Order() { Key = $"Key {x}", Name = $"Order name {x}" }).ToList();
public void rowSelected(Syncfusion.Blazor.Grids.RowSelectEventArgs<Order> args)
{
shouldRender = false;
Console.WriteLine($"Row selected: {args.Data.Key}");
//Does absolutely nothing that takes time...
}
|
Hi Richard,
We understand your frustrations.
Query: “It seems to me that a lot of cascading side-effects regarding loads of unneeded round-trips through JS-Interop are happening simply by setting that event-handler causing all sorts of trouble”
We can accept your comments that introduction of RowSelected event causes 3 second delay while selecting a record in Blazor webassembly project. But it is not definitely due to JSInterop call made during the eventCallback function.
During a call back function(in your case EventCallBack<object> RowSelected), component’s StateHasChanged will be triggered for the components and its sub components to apply changes. In DataGrid, we have rendered each cell in a row as individual component. So you have 500 records and 2 columns, then statehaschanged has to called for every components (say 500*2 = 1000 times) before completing the requested action with an event call back. Hence the time delay occur in webassembly project during a event call back function. So the reported issue is not due to JSInterop call.
As a workaround we can overcome the reported issue by override the ShouldRender lifecycle event of Blazor. Refer the below code example.
private bool shouldRender;protected override bool ShouldRender() => shouldRender;List<Order> _orders = Enumerable.Range(0, 500).Select(x => new Order() { Key = $"Key {x}", Name = $"Order name {x}" }).ToList();public void rowSelected(Syncfusion.Blazor.Grids.RowSelectEventArgs<Order> args){shouldRender = false;Console.WriteLine($"Row selected: {args.Data.Key}");//Does absolutely nothing that takes time...}
Kindly download the modified sample from below
Please get back to us if you have further queries.
Regards,Vignesh Natarajan
Hi Christian,
Thanks for your update. Please get back to us if you need further assistance.
Regards,Renjith R
Extreme performance degradation when adding handler for RowSelect event...
I have a very small grid with less then 100 rows and 5 columns.
Working with such a slow grid is very annoying even you navigate with up and down arrow keys !
Do you expect any improvement in the very near future ?
Thank You !
This is my code for the RowSelect Event that tells me the current selected row and the number of grid's total rows :
private async Task RowSelectHandler(RowSelectEventArgs<MYCartModel> args)
{
var_grid_row_is_selected = true;
var RowIndexes_Object = await this.MYCART_GRID.GetSelectedRowIndexes();
var RowIndexes_Array_TMP = Convert.ToInt32(RowIndexes_Object.ToArray().GetValue(0)) + 1;
var_current_selected_record = Convert.ToInt32(RowIndexes_Object.ToArray().GetValue(0)) + 1;
var FilteredRecords_Object = await this.MYCART_GRID.GetFilteredRecords();
var_total_mycart_records = JsonConvert.DeserializeObject<List<object>>(JsonConvert.SerializeObject(FilteredRecords_Object)).Count();
if (var_current_selected_record>0 && var_total_mycart_records > 0)
{ var_grid_row_counter_text = var_current_selected_record.ToString() +'/' + var_total_mycart_records.ToString(); }
else if (var_current_selected_record == 0 && var_total_mycart_records > 0)
{ var_grid_row_counter_text = var_total_mycart_records.ToString(); }
else if (var_current_selected_record == 0 && var_total_mycart_records == 0)
{ var_grid_row_counter_text = ""; }
}
Helo everybody,
I used the PreventRender and it's not helped too much, let I say without this functionality it's takes 3s to update a cell (UpdateCellAsync) and using the PreventRender, I had 2.8s, so is not a great thing at the end of the day.
So I believe that Syncfusion needs to continue the performance's improvements to reach a better results with Blazor WebAssembly
Hi Andre,
We have prepared an simple sample based on your shared reference. But it is taking just 8 to 9 milliseconds to update an cell using UpdateCellAsync. We have printed the milli seconds taken in the browser console. Kindly make a look in to it and revert us the way you have performed calculation.
If possible kindly share us an simple issue reproduceable sample or modify the reported issue on the below mentioned sample and also kindly share us the entire Grid code snippet with video demonstration. It will be very helpful for us to validate the reported issue.
Please let us know if you have any concerns.
Regards,
Monisha