Im testing the Radzen Grid for Blazor with Visual Studio 2019/IIS. SQL updates appear in the grid. However, the new records show up as the last entry in the grid and not part of the applied sort. Is there a way to make sure new data appears in sort order?
Welcome to the Radzen community!
Indeed the Radzen DataGrid appends newly inserted items at the bottom of the current page. If it applied sorting that record could have ended on a different page and remain invisible. This could lead the user to think inserting the record failed.
Is there a way to force a datagrid refresh? The sort is on a date field. Expecting new items to be first entry.
Have you tried
The DataGrid will update automatically if you change the property which its Data is set to. Calling the Reload() method will just render the DataGrid with the existing data which is probably not what you want. You probably want to fetch the data from database so it is sorted in the required order.
Hi - In the API (based on Visual Studio auto-complete) there is a DataGrid.InsertRow(...) and this is also used in the examples project - and it inserts at the top.
(As an aside, note that this is missing from the documentation completely, https://www.radzen.com/documentation/blazor/datagrid/ )
Question: How to add new row to the end - is there or will be there an 'AddRow(...)' or similar?
(Presumably we could have Insert(intex i), AddRow(...), AddRange(Rows) ...)
This isn't supported.
Thank you, I will work around this, please Add AddRow(...) and/or provide int index to InsertRow(int index, ...) to your backlog if this makes sense at your convenience.
Allow me to say that I LOVE this control ...very powerful, and (on early impression) pretty easy to use!!
To confirm my understanding, I seem to be noticing the following:
- The "Data" Parameter of "RadzenGrid" appears to work as 'initial data' and does not work as 'bound data' (meaning that when myGrid.InsertRow(new myObject()) is called, a row is inserted in the control, but the local Data parameter is NOT changed by this call ... so one has to maintain his own data model in parallel ... no problem)
- Furthermore, you actually don't have to maintain that local Data parameter at all - since it's an initial paramter that will be re-initialized anyway on page reload - so assuming that when you called myGrid.InsertRow(new MyObject()) you also inserted that new object in your data model or data strore,
then a page reload will now initialize the local Data parameter from your somewhere else, and the new row will be there correctly
To answer/correct my own supposition up above:
The "Data" Parameter of RadzenGrid is NOT initial data (but it's also not 'bound' data as mentioned above) - this parameter (and the Collection that it points to) DOES need to be maintained during the life of the control - but to see that affect, you have to call _myGrid.Reload(), where _myGrid is pointed-to by the "@ref = _myGrid" in the grid declaration.
(and of course you also have to maintain your data model and/or storage for whatever go added or deleted etc.)
The only point of confusion that then remains is:
What is DataGrid.InsertRow(...) and similar methods for?
To explain the context: I have confirmed that after adding an object to the local Data collection and calling _myGrid.Reload(), the new row is added correctly without calling _myGrid.InsertRow(...) so what is API for?