Slow performance when editing cells during a search with highlighting enabled
Steps to reproduce:
- Use a large dataset in an SfDataGrid (100s of rows) with cell values that are changing constantly (for example, live price data)
- Do a search with highlighting and filtering enabled, ensuring the result of the search is also a large dataset.
- Edit a numeric cell within the results.
- The input is sometimes very slow. I am guessing because it is searching for and re-rendering all the highlighted text whenever the row's data is changed.
Thanks,
Hi Zia,
Thank
you for reaching out and providing detailed information.
We tried to replicate the performance issue on our end by creating a sample where data is continuously updated, with search highlighting and filtering enabled. However, we were unable to observe any performance delays. The filtered records were correctly updated and highlighted based on the input search text as expected.
we noticed two additional behaviors when applying a search in this application. Could you please confirm if these align with what you were experiencing?
- Highlighting in Live Data Update Column: When searching for text, the highlighted records in the live data update column do not update in the UI or fail to reflect the changes. However, the remaining filtered records in the live data update column update correctly.
- Editing Values in Live Data Update Column: We noticed that when editing a value in the live data update column, the edited value sometimes gets overridden, particularly when live data continues to update while the edit is being made.
For your reference, I have
attached a sample and a video demonstrating these behaviors. Could you please
review them and confirm if they match the issue you are facing? Additionally,
if you have any specific steps or scenarios where you consistently experience
performance delays, please share those with us. This will help us further
investigate the issue.
Thanks for your cooperation, and we look forward to your response.
Regards,
Santhosh.G
Attachment: Sample_DataGrid_11a95190.zip
Hi,
I think it is important to note that I have LiveDataUpdateMode set to AllowDataShaping which changes the behaviour of the search results. In the sample application you provided, setting the datagrid in this way seems to produce the problems I am experiencing.
Rows will appear and disappear in realtime during the search. Highlighted text will also change in realtime according to the search. It is also very difficult to edit anything during a search in this mode, sometimes it even crashes the sample application.
Perhaps there is a way to disable AllowDataShaping only during the search?
Thank you,
Zia
I think I have resolved this by manually changing the LiveDataUpdateMode to Default during the search and then setting it back to AllowDataShaping when the search is cleared.
Hi Zia,
We
are glad to know that the reported problem has been resolved at your end.
Please let us know if you have any further queries on this. We are happy to
help.
Regards,
Santhosh.G
Unfortunately I am still having this problem. The performance issue is still solved by disabling the search highlighting, but I do need the highlighting.
I have 5 tables on screen, each with 26 columns and about 200 rows each of constantly changing live data.
One thing I've noticed is RowGenerator.RowsArranged is being triggered very often while I'm in a search which seems to be triggering a re-evaluation of all the cells highlighting. I'm wondering if this is maybe what is making it slow during a search.
I only need the highlighting to be shown on the initial search, I do not need the highlighting updated as the data values change.
I will continue to investigate and see if I can find anything else.
Regards,
Manikanda Akash
Attachment: SfDataGrid_Demo_c534065a.zip
I've come up with a bit of a hacky solution. Its not ideal as it uses a timer, but it seems to work in my case. I've created a custom search helper which allows me to suspend updates to the search results. Then after executing a search I manually suspend the updates after a short wait time. Performance has improved significantly.
public class CustomSearchHelper : SearchHelper
{
public CustomSearchHelper(SfDataGrid sfDataGrid) : base(sfDataGrid)
{
}
public bool SuspendSearchUpdates { get; set; }
protected override void SearchRow(DataRowBase row)
{
if (SuspendSearchUpdates) return;
base.SearchRow(row);
}
}
...
public void ApplySearch(string text)
{
var searchHelper = (CustomSearchHelper)MyDataGrid.SearchHelper;
if (string.IsNullOrEmpty(text))
{
searchHelper.SuspendSearchUpdates = false;
MyDataGrid.SearchHelper.ClearSearch();
MyDataGrid.LiveDataUpdateMode = LiveDataUpdateMode.AllowDataShaping;
return;
}
MyDataGrid.LiveDataUpdateMode = LiveDataUpdateMode.Default;
searchHelper.SuspendSearchUpdates = false;
MyDataGrid.SearchHelper.Search(text);
// Block further updates to the search results
Task.Delay(500).ContinueWith(t =>
{
searchHelper.SuspendSearchUpdates = true;
});
}
I managed to reproduce the problem on the example you provided. Doesn't always happen though.
1) Search for '.' . This should give a large number of search results.
2) In the last datagrid, start typing with one of the Symbol cells selected.
I observed that the cell was not showing what I was typing. Pressing enter did not update the cell with what I typed either. This is similar to the behaviour I was experiencing in my own application.
Manikanda Akash