We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

default Grid column width ,column order

Hi, 


In the DataGrid, I use AllowResizing, AllowReordering and EnablePersistence. How can I set default values for column order and column width for the first time when the user runs the page?


thank you


3 Replies

NP Naveen Palanivel Syncfusion Team January 5, 2023 01:48 AM UTC


Hi Sarah,


Based on your query, we suspect you want clear persistence when grid is created. We have ResetPersistDataAsync used inside the grid created event. Please refer the code snippet and documentation for more information.


public void CreatedHandler(object args)

    {

        Grid.ResetPersistDataAsync();

    }

 


Documentation ; https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_ResetPersistDataAsync
                            https://blazor.syncfusion.com/documentation/datagrid/state-management#handling-grid-state-manually
                    https://blazor.syncfusion.com/documentation/datagrid/events#created


Please let us know if you have any concerns.


Regards,

Naveen Palanivel



SA Sarah replied to Naveen Palanivel March 28, 2023 12:23 PM UTC

Hi,

I don't want to reset all user settings. Suppose we have columns A, B, C, D. I hide column C by default in the source code. The first time the user opens the page, there is a hidden C that can be removed from the hidden state. The next time the user opens the page, I want the same settings that the user set last time to be displayed, and I don't want to reset the settings.


I want the following items to be removed from the data grid settings on page load:

1-Grid_Column_HeaderFilter



2-Grid_ToolbarItem_Search_content



3-Grid_Column_Sort




MS Monisha Saravanan Syncfusion Team April 14, 2023 06:39 AM UTC


Hi Sarah,


Thanks for the patience.


Query: “I want the following items to be removed from the data grid settings on page load”


Yes we can achieve your requirement by clearing the unwanted settings in the persist properties and we suggest you to set new properties in Grid settings.


We have discussed the similar query on the below tread. So kindly refer the attached thread for your reference.


Reference: https://www.syncfusion.com/forums/172940/datagrid-toolbar-items-icon?reply=S2Jkb8


Also please find the attached sample using latest Nuget version for additional information and let us know if you face any difficulties.


Attachment: DataGrid_8fed2d8d.zip

Loader.
Live Chat Icon For mobile
Up arrow icon