Hi,
1-I used the Toolbar in the DataGrid component. Is it possible to place the icon instead of the title of the toolbar items?
private List<object> ToolbarItems = new List<object>() { new ToolbarItem() { Type = ItemType.Input, Template = title, Align = ItemAlign.Left }, "ColumnChooser" };
2-In Pager with page size dropdown:
Is it possible for the user to enter his value in dropdown? It is not possible at the moment and the user has to select only the items in the dropdown.
3- In EnablePersistence: Is it possible to allow the user to delete all the current page datagrid settings? For example, in the Toolbar put a button to delete the settings. And the next question is whether it is possible to add content and read data to it? For example, placing a checkbox in the Datagrid toolbar that the user can choose to save the DataGrid settings on each page. The value of this check box is stored in " Persistence" content.
Thank you
Hi Vignesh Natarajan,
1-I used the following code, but unfortunately the desired output is not suitable. I want only the icon to be visible.
new ItemModel() { TooltipText = "Settings", Id = "Click",CssClass="fa fa-cog icon" }
2- I used ResetPersistDataAsync (). After doing this,
2-1 the value in the search toolbar will not be deleted. Is it possible to access the search toolbar text to delete? From myGrid.Search (""); I used it but the problem did not go away.
2-2-The second problem is that the string that displays the filter items at the bottom of the datagrid is not removed.
3-In the following code:
<SfGrid @ref="myGrid" ... />
How can I get all column names, column widths, and column indexes using the myGrid object?
Thank you
|
Toolbaritems.Add(new ItemModel() { TooltipText = "Expand all", Id="ExpandAll", PrefixIcon = "e-expand" }); |
|
|
Hi Monisha Saravanan,
Excellent bug fixed.
I used the following example. Is it possible to display the dialogue exactly to the right of the data grid? It is placed on the left by default.
And is it possible to place the search toolbar on the right?
I only used EnablePersistence = "true"
We can use GetColumnsAsync method to get all the columns in the DataGrid. By using GetColumnIndexByFieldAsync method we can get column index. Currently there is no direct method support which can return column index and width programmatically. Instead we can get width by using GetColumnsAsync method.
Thank you
|
<SfButton OnClick="Show" CssClass="e-primary" IsPrimary="true" Content="Open column chooser"></SfButton>
<SfGrid @ref="DefaultGrid" DataSource="@Employees" ShowColumnChooser="true" Toolbar=@ToolbarItems>
<GridColumns>
...
</GridColumns>
</SfGrid>
@code{
private SfGrid<EmployeeData> DefaultGrid;
public string[] ToolbarItems = new string[] { "ColumnChooser", "Search"};
public void Show()
{
this.DefaultGrid.OpenColumnChooser(700, 50);
}
} |
Hi Monisha Saravanan,
Yes, it is possible to display the column chooser dialog on the right side of the DataGrid. The position of the dialog can be changed by changing the dialog rendering position inside the OpenColumnChooser method. Kindly refer the below code snippet.
I saw the following code in the site documents. Is there another way instead of setting numeric parameters as hard code (for example with style)?
this.DefaultGrid.OpenColumnChooser(700, 50);
Thank you
|
<SfButton @onclick ="Show" CssClass="e-primary" IsPrimary="true" Content="Open column chooser"></SfButton>
<SfGrid @ref="DefaultGrid" DataSource="@Employees" ShowColumnChooser="true" Toolbar=@ToolbarItems>
<GridColumns>
...
</GridColumns>
</SfGrid>
<style>
.e-grid .e-popup.e-ccdlg.e-popup-open.e-dialog {
left : 700px !important;
top : 50px !important;
}
</style>
@code{
private SfGrid<EmployeeData> DefaultGrid;
public string[] ToolbarItems = new string[] { "ColumnChooser" };
public void Show()
{
this.DefaultGrid.OpenColumnChooser();
}
} |
Hi Monisha Saravanan,
Your guidance was excellent and the bug was fixed. In the past we talked about saving user settings. I want to save some user settings manually. For this reason I save some DataGrid settings (column width, column order) in the database. I do not know where to apply these settings. There is no problem in the following link because it did not use AdapterInstance. But I used AdapterInstance and had a problem.
https://www.syncfusion.com/forums/146129/programatically-create-change-columns-on-the-fly
My code:
public class GridCustomAdaptor : DataAdaptor
{
public GridCustomAdaptor() {}
public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null) {
...
Read data from the server & return
}
}
-------------------------------------------------------------------------------------
AllowSorting="true" AllowFiltering="true" AllowResizing="true" AllowSelection="true" AllowReordering="true"
Width="100%"
AllowSorting="true"
HeaderTextAlign="TextAlign.Center" Type="ColumnType.String"
FilterSettings="@(new FilterSettings { Operator = Operator.Contains })">
.....
----------------------------------------------------------------------------------------------
protected async override Task OnInitializedAsync()
{
ReadUserSettings()
}
Hi Monisha Saravanan ,
I've used the Persistence feature in the DataGrid in the past and got excited about it. And these are the things I wanted but there are extras. I do not need. For example, when we enable Persistence and the user uses the Column Filter or uses Search in the toolbar, these are also saved and also the sort of columns are saved, and when the user sees the current page in the future, these items are filtered and searched. And sorting is applied. The existence of these is considered as a problem.
Thank you
Hi Monisha Saravanan,
I checked your answer and deleted the elements I did not need, but it gave an error. Then I added the element without children and it made an error again. The next thing is that in PageSizes the value that the user has selected in the combo box and I do not know where Json is to save (I just want to save the selected value of the user again in Json).
var jsString = await myGrid.GetPersistData();
var o = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(jsString);
o.Property("filterSettings")?.Remove();
o.Property("searchSettings")?.Remove();
o.Property("sortSettings")?.Remove();
o.Property("groupSettings")?.Remove();
o.Property("pageSettings")?.Remove();
o.Add(new JProperty("filterSettings"));
o.Add(new JProperty("searchSettings"));
o.Add(new JProperty("sortSettings"));
o.Add(new JProperty("groupSettings"));
o.Add(new JProperty("pageSettings"));
await myGrid.SetPersistDataAsync(o.ToString()); =>Error
Thank you
|
public async void Save()
{
_state = await Grid.GetPersistData();
dynamic PersistProp = JsonSerializer.Deserialize<Dictionary<string, object>>(_state.ToString());
dynamic _state1 = JsonSerializer.Deserialize<GridSearchSettings>(PersistProp["searchSettings"].ToString());
_state1 = new GridSearchSettings();
PersistProp["searchSettings"] = JsonSerializer.Serialize(_state1).ToString();
dynamic _state2 = JsonSerializer.Deserialize<GridPageSettings>(PersistProp["pageSettings"].ToString());
int page = _state2.PageSize;
_state2 = new GridPageSettings();
_state2.PageSize = page;
PersistProp["pageSettings"] = JsonSerializer.Serialize(_state2).ToString();
_state = JsonSerializer.Serialize(PersistProp);
Service.setGridState(_state);
} |
Hi Monisha Saravanan,
How to save settings for DataGrid columns (IsVisible, order, width)?
Thank you
Hi Monisha Saravanan,
Thanks for your source. I made a small change to your source and set EnablePersistence = "true" for the DataGrid so that I do not save the settings in the database. When we click the clear button, it removes the DataGrid sort filters and grouping, and this is exactly what I want. That is, the settings are saved automatically, but the user can delete the settings. But when I want to always delete the settings and call ClearFilterSortGroupSettings () in OnInitializedAsync (), it does not work properly.
<SfButton @onclick=" ClearFilterSortGroupSettings ">Clear</SfButton>
public async void ClearFilterSortGroupSettings()
{
_state = await Grid.GetPersistData();
dynamic PersistProp = JsonSerializer.Deserialize<Dictionary<string, object>>(_state.ToString());
dynamic columnData = JsonSerializer.Deserialize<List<GridColumn>>(PersistProp["columns"].ToString());
dynamic _state1 = JsonSerializer.Deserialize<GridSearchSettings>(PersistProp["searchSettings"].ToString());
_state1 = new GridSearchSettings();
PersistProp["searchSettings"] = JsonSerializer.Serialize(_state1).ToString();
dynamic _state2 = JsonSerializer.Deserialize<GridPageSettings>(PersistProp["pageSettings"].ToString());
_state2 = new GridPageSettings();
PersistProp["pageSettings"] = JsonSerializer.Serialize(_state2).ToString();
dynamic _state3 = JsonSerializer.Deserialize<GridFilterSettings>(PersistProp["filterSettings"].ToString());
_state3 = new GridFilterSettings();
PersistProp["filterSettings"] = JsonSerializer.Serialize(_state3).ToString();
dynamic _state4 = JsonSerializer.Deserialize<GridSortSettings>(PersistProp["sortSettings"].ToString());
_state4 = new GridSortSettings();
PersistProp["sortSettings"] = JsonSerializer.Serialize(_state4).ToString();
dynamic _state5 = JsonSerializer.Deserialize<GridGroupSettings>(PersistProp["groupSettings"].ToString());
_state5 = new GridGroupSettings();
PersistProp["groupSettings"] = JsonSerializer.Serialize(_state5).ToString();
_state = JsonSerializer.Serialize(PersistProp);
//Service.setGridState(_state);
Grid.SetPersistDataAsync(_state);
}
Thank you
|
<SfButton @onclick=" ClearFilterSortGroupSettings ">Clear</SfButton>
<SfButton @onclick=" Reset ">Reset</SfButton>
<SfGrid ID="Grid8" @ref="Grid" DataSource="@Orders" Height="315" AllowReordering="true" AllowGrouping="true" EnablePersistence="true" AllowPaging="true" AllowFiltering="true" AllowSorting="true">
<GridEvents OnDataBound=DataBound TValue="Order"></GridEvents>
<GridColumns>
...
</GridColumns>
</SfGrid>
@code {
public bool flag = true;
public void DataBound()
{
if (flag)
{
ClearFilterSortGroupSettings();
flag = false;
}
}
} |
Hi Monisha Saravanan,
Thank you for your guidance. The bug was fixed. I am using CustomAdaptor and in this class I am reading data from the API server in the ReadAsync method.
When the page loads, ReadAsync is called first (with column filter information, search, grouping, and sorting), and data is read from the server.
In the next step, DataBound is called and we remove the search, filter and grouping information.
In the next step , ReadAsync is called again in the CustomAdaptor class and the information is read from the server.
Thank you
Hi Sarah,
Query: “The second problem is that the string that displays the filter items at the bottom of the datagrid is not removed”
We are glad to announce that, we have included fix for the “Incorrect Filtered Columns Are Shown After Clicking Reset PersistData” in our release(20.1.0.48). So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the Nuget package for latest fixes and features from below.
Nuget : https://www.nuget.org/packages/Syncfusion.Blazor.Grid
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Monisha
Hi
Monisha Saravanan
Can you provide a link where i can access icon list of Toolbaritems PrefixIcon ?
Hi Dat,
Greetings from Syncfusion support.
Query: “Can you provide a link where i can access icon list of Toolbaritems PrefixIcon ?”
We have checked your query and you can find the icon list from the below mentioned UG location and make use of the icons by using CSS class. Kindly check the below documentation for additional information.
UG: https://blazor.syncfusion.com/documentation/appearance/icons#icons-list
Kindly get back to us if you have further queries.
Regards,
Monisha
Hi,
My Source code:
public async Task OnDataGridDataBound()
{
if (flagDataBound)
{
await DataGridSetting
flagDataBound = false;
}
}
==========================
public static class DataGridSetting
{
public static async Task ResetGridSetting(SfGrid
{
try
{
string _state = await myGrid.GetPersistDataAsync();
dynamic PersistProp = System.Text.Json.JsonSerializer.Deserialize
dynamic columnData = System.Text.Json.JsonSerializer.Deserialize>(PersistProp["columns"].ToString()); /*persist column settings*/
//------------------------------------------------------------------------------------------------------------
dynamic _state1 = System.Text.Json.JsonSerializer.Deserialize
_state1 = new GridSearchSettings();
PersistProp["searchSettings"] = System.Text.Json.JsonSerializer.Serialize(_state1).ToString();
//------------------------------------------------------------------------------------------------------------
int intPageSize;
dynamic _state2 = System.Text.Json.JsonSerializer.Deserialize
intPageSize = _state2.PageSize;
_state2 = new GridPageSettings();
_state2.PageSize = intPageSize;
PersistProp["pageSettings"] = System.Text.Json.JsonSerializer.Serialize(_state2).ToString();
dynamic _state3 = System.Text.Json.JsonSerializer.Deserialize
_state3 = new GridFilterSettings();
PersistProp["filterSettings"] = System.Text.Json.JsonSerializer.Serialize(_state3).ToString();
dynamic _state4 = System.Text.Json.JsonSerializer.Deserialize
_state4 = new GridSortSettings();
PersistProp["sortSettings"] = System.Text.Json.JsonSerializer.Serialize(_state4).ToString();
dynamic _state5 = System.Text.Json.JsonSerializer.Deserialize
_state5 = new GridGroupSettings();
PersistProp["groupSettings"] = System.Text.Json.JsonSerializer.Serialize(_state5).ToString();
_state = System.Text.Json.JsonSerializer.Serialize(PersistProp);
await myGrid.SetPersistDataAsync(_state);
}
catch (Exception ex)
{
string st = ex.Message;
}
}
}
=============================================
1-I used the above code and it worked correctly. I upgraded the .NET version from 6 to 7. I upgraded the syncfusion version to 21.1.35. Unfortunately, the code no longer works properly and the Datagrid remains in loading and the data is not displayed.
2-To use syncfusion components, we must add the following items:
By changing the version of syncfusion components, won't the content of these files change and it is not necessary to download these files again on the client side?
Hi Sarah,
Before proceeding with the reporting issue, we
require some additional clarification from your end. Please share the below
details to proceed further at our end.
Above-requested details will be very
helpful in validating the reported query at our end and providing a solution as
early as possible.
Regards,
Prathap S
Hi,
I have attached the source. Data is loaded in this source, but the page hangs.
Hi Sarah,
We could see that in your shared sample the scripts is not rendered properly. So the Grid is not laded initially. To resolve the reported issue we suggest you to refer the scripts externally. Kindly check the below release notes and attached sample for your reference.
In our latest version the Built-in JavaScript isolation feature has been marked as deprecated in 2022 Vol1 release, since loading scripts externally provides better performance over JavaScript isolation approach.
Release notes: https://blazor.syncfusion.com/documentation/release-notes/21.1.35?type=all#breaking-changes
Please get back to us if you face further issues.
Regards,
Monisha
Hi Monisha Saravanan,
I thank you for reviewing the source code with Daft. There is a problem that my website is running on the local network that some systems do not have access to the Internet. Regarding the lack of access to the Internet, what is your suggestion?
Hi Sarah,
We suggest you use our script & CSS references from static
web assets or using CRG. Please refer to the below UG
links.
https://blazor.syncfusion.com/documentation/common/adding-script-references#refer-script-from-static-web-assets
https://blazor.syncfusion.com/documentation/common/custom-resource-generator
Using static web assets:
|
<link rel='nofollow' href="_content/Syncfusion.Blazor/styles/bootstrap5.css" rel="stylesheet" /> <script src="_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js" type="text/javascript"></script> </head>
|
Please let us know if you have any concerns.
Hi Monisha Saravanan,
I used the method you said, but I did not get the result. I attached the project. It is locked when loading the form.
Hi Sarah,
The reported issue is due to the following highlighted line. We have modified the shared sample at our end. Kindly comment out the below highlighted line and check the reported issue at your end. Please check the modified sample and code snippet for additional reference.
|
public async Task OnDataGridDataBound() { if (flagDataBound) { //await DataGridSetting<Order>.ResetGridSetting(myGrid); // Issue occurs due to the following code flagDataBound = false; } } |
Please let us know if you have any concerns.
Regards,
Monisha
Hi Monisha Saravanan,
The problem is exactly here and I knew it. This source used to work correctly in the past, but after updating the Syncfusion version, this bug appeared.
(This is a problem that I have raised in previous posts and you provided a solution and the problem was not solved.)
Hi Sarah,
We could see that the reported issue is due to the DataBound method is calling repeatedly. So we suggest you to set flag variable as false before accessing the ResetGridSetting method. Kindly check the attached sample and code snippet for your reference.
|
<SfGrid @ref="myGrid" DataSource="@Orders" AllowPaging="true" AllowResizing="true" AllowReordering="true">
<GridEvents OnToolbarClick="ToolbarClickHandler" RowSelected="RowSelected" RowDeselected="RowDeSelected" OnDataBound="OnDataGridDataBound" RowSelecting="RowSelectingHandler" ContextMenuOpen="ContextMenuOpened" ContextMenuItemClicked="ContextMenuItemClickedHandler" TValue="Order"></GridEvents> <GridPageSettings PageSize="5"></GridPageSettings> <GridColumns> ... </GridColumns> </SfGrid>
@code{
public bool flagDataBound = true; public static SfGrid<Order> myGrid = new SfGrid<Order>();
public async Task OnDataGridDataBound() { if (flagDataBound) { flagDataBound = false; // Ensure to set the boolen value as false before calling the method. await DataGridSetting<Order>.ResetGridSetting(myGrid);
} } } |
Please let us know if you have any concerns.
Regards,
Monisha
Hi Monisha Saravanan,
The problem was solved. Thank you for your follow up.
Hi Sarah,
Welcome. Kindly get back to us if you face any difficulties. As always we will be happy to assist you.