Want to newly added record on top of the grid insted of last row.

Hello,


Is this possible that, if I added any new record and that appeared top in the grid once I clicked on the update button? Right now if I add any new record and click on the update button the data showing on the bottom of the grid.

Please find attached the source code and image for your reference. Capture.PNG


Attachment: BlazorAppSample487298779_19df6a58.7z

1 Reply

JP Jeevakanth Palaniappan Syncfusion Team August 9, 2021 07:32 AM UTC

Hi Karan, 

Greetings from Syncfusion support. 

We have validated your query and we suggest you to achieve your requirement by using the Custom adaptor feature of the grid in which you can able to customize the grid CRUD and data operations based on your requirement. Please refer the below code snippet, documentation and sample for your reference. 


Documentation: 


        // Performs BatchUpdate operation 
        public override object BatchUpdate(DataManager dm, object Changed, object Added, object Deleted, string KeyField, string Key, int? dropIndex) 
        { 
            if (Changed != null) 
            { 
                foreach (var rec in (IEnumerable<Order>)Changed) 
                { 
                    Order val = Orders.Where(or => or.OrderID == rec.OrderID).FirstOrDefault(); 
                    val.OrderID = rec.OrderID; 
                    val.CustomerID = rec.CustomerID; 
                    val.Freight = rec.Freight; 
                } 
 
            } 
            if (Added != null) 
            { 
                int Index = 0; 
                foreach (var rec in (IEnumerable<Order>)Added) 
                { 
                    //Orders.Add(rec); 
                    Orders.Insert(Index, rec); 
                    Index++; 
                } 
            } 
            if (Deleted != null) 
            { 
                foreach (var rec in (IEnumerable<Order>)Deleted) 
                { 
                    Orders.Remove(Orders.Where(or => or.OrderID == rec.OrderID).FirstOrDefault()); 
                } 
 
            } 
            return Orders; 
        } 

Please get back to us If you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon