How to visible and invisible the other toolbar items?
For example: When I click the EditDate the other toolbar like Add, Edit, Delete, PDF Export, Excel Export and Archive will be invisible in the toolbar only three toolbar are still visible the EditDate, Update and C
|
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnToolbarClick="ToolbarClicked" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@if(Necessary)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive {
display: none;
}
</style>
}
@code{
SfGrid<Order> GridInstance { get; set; }
public List<Order> Orders { get; set; }
public bool Necessary { get; set; }
private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", new ItemModel() { Text = "EditDate", TooltipText = "EditDate", Id = "editdate" }, "Delete", "Update", "Cancel", "PdfExport", "ExcelExport", new ItemModel() { Text = "Archive", TooltipText = "Archive", Id = "Archive" } };
public async Task ToolbarClicked(Syncfusion.Blazor.Navigations.ClickEventArgs Args)
{
Necessary = false;
if (Args.Item.Id == "Grid_pdfexport") //Id is combination of Grid's ID and itemname
{
await this.GridInstance.PdfExport();
}
if (Args.Item.Id == "Grid_excelexport") //Id is combination of Grid's ID and itemname
{
await this.GridInstance.ExcelExport();
}
if (Args.Item.Id == "editdate")
{
Necessary = true;
await GridInstance.EnableToolbarItemsAsync(new List<string>() { "Grid_update", "Grid_cancel" }, true);
}
}
|
Thank you Vignesh
But how about the Add, Edit and Delete? I want them to visible like the Pdfexport, Excelexport and Archive.
I want to visible the built-in toolbar items like Add, Edit, Delete when I click the EditDate.
|
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnToolbarClick="ToolbarClicked" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> GridInstance { get; set; }
public List<Order> Orders { get; set; }
private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", new ItemModel() { Text = "EditDate", TooltipText = "EditDate", Id = "editdate" }, "Delete", "Update", "Cancel", "PdfExport", "ExcelExport", new ItemModel() { Text = "Archive", TooltipText = "Archive", Id = "Archive" } };
public async Task ToolbarClicked(Syncfusion.Blazor.Navigations.ClickEventArgs Args)
{
if (Args.Item.Id == "editdate")
{
await GridInstance.EnableToolbarItemsAsync(new List<string>() { "Grid_add", "Grid_edit", "Grid_delete" }, true);
}
}
|
The Add, Edit and Delete are still in the toolbar when I click the Edit Date. I want the built-in toolbar items to be visible when I click the EditDate or in other word it just only 3 toolbar items left the EditDate, Update and Cancel
Like This:
|
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
. . . .. . . .
</SfGrid>
@if(Necessary)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive {
display: none;
}
</style>
}
|
|
|
2. Is it possible to have a multiple css on tha same page?
|
<button @onclick="Click">TrashBin</button>
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnToolbarClick="ToolbarClicked" TValue="Order"></GridEvents>
<GridColumns>
. ..
</GridColumns>
</SfGrid>
. ..
@if (HideAllExcept)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive, #editdate, #Grid_update, #Grid_cancel {
display: none;
}
</style>
}
@code{
SfGrid<Order> GridInstance { get; set; }
public List<Order> Orders { get; set; }
public bool Necessary { get; set; }
bool HideAllExcept { get; set; }
private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", new ItemModel() { Text = "EditDate", TooltipText = "EditDate", Id = "editdate" }, "Delete", "Update", "Cancel", "PdfExport", "ExcelExport", new ItemModel() { Text = "Archive", TooltipText = "Archive", Id = "Archive" },
new ItemModel() { Text = "Restore", TooltipText = "Restore", Id = "Restore" }};
public void Click()
{
HideAllExcept = true;
}
. ..
} |
public async void SelectedOtherView(int selectedView) //02/10/22
{
HideAllExcept = true;
foreach (var otherview in OtherViews)
{
otherview.ValueStyle = "#0099d7";
otherview.CountStyle = "#0099d7";
}
OtherViews[selectedView].ValueStyle = "white";
OtherViews[selectedView].CountStyle = "white";
switch (selectedView)
{
case 0: //ViewAll
Necessary = false;
SelectedView = 0;
ViewList();
Necessary = true;
await GridHeader.EnableToolbarItemsAsync(new List<string>() { "GridHeader_recall", "GridHeader_add", "GridHeader_edit", "GridHeader_delete", "GridHeader_update", "GridHeader_cancel", "GridHeader_pdfexport", "GridHeader_excelexport", "Archive", "Restore", "Recall", "Charges", "DepositDate", "FolderDate" }, true);
break;
case 1: //Deposited
Necessary = false;
SelectedView = 1;
ViewList();
Necessary = true;
await GridHeader.EnableToolbarItemsAsync(new List<string>() { "GridHeader_recall" }, true);
break;
case 2: // Trashbin
Necessary = false;
SelectedView = 2;
ViewList();
Necessary = true;
await GridHeader.EnableToolbarItemsAsync(new List<string>() {"GridHeader_restore" }, true);
break;
}
OtherViews[0].Count = ViewAllCount;
OtherViews[1].Count = DepositCount;
OtherViews[2].Count = TrashbinCount;
StateHasChanged();
}
@if (Necessary)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#GridHeader_add, #GridHeader_edit, #GridHeader_delete, #GridHeader_update, #GridHeader_cancel, #GridHeader_pdfexport, #GridHeader_excelexport, #Archive, #Restore, #Charges, #DepositDate, #FolderDate {
display: none;
}
</style>
}
@if (HideAllExcept)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#GridHeader_add, #GridHeader_edit, #GridHeader_delete, #GridHeader_pdfexport, #GridHeader_excelexport, #Archive, #GridHeader_update, #GridHeader_cancel, #Archive, #Charges, #DepositDate, #FolderDate{
display: none;
}
</style>
}
It is not working
Is there any update about my query?
|
<button @onclick="ViewAllClick">ViewAll</button>
<button @onclick="deposit">Deposited</button>
<button @onclick="Click">TrashBin</button>
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnToolbarClick="ToolbarClicked" TValue="Order"></GridEvents>
. . .
</SfGrid>
@if (Necessary)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive {
display: none;
}
</style>
}
@if (HideAllExcept)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive, #editdate, #Grid_update, #Grid_cancel, #Recall {
display: none;
}
</style>
}
@if (isDeposit)
{
<style>
/*Id is combination of Grid's ID and itemname*/
#Grid_add, #Grid_edit, #Grid_delete, #Grid_pdfexport, #Grid_excelexport, #Archive, #editdate, #Grid_update, #Grid_cancel, #Restore {
display: none;
}
</style>
}
@code{
SfGrid<Order> GridInstance { get; set; }
public List<Order> Orders { get; set; }
public bool Necessary { get; set; }
bool HideAllExcept { get; set; }
bool ViewAll { get; set; }
bool isDeposit { get; set; }
private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", new ItemModel() { Text = "EditDate", TooltipText = "EditDate", Id = "editdate" }, "Delete", "Update", "Cancel", "PdfExport", "ExcelExport", new ItemModel() { Text = "Archive", TooltipText = "Archive", Id = "Archive" },
new ItemModel() { Text = "Restore", TooltipText = "Restore", Id = "Restore" },
new ItemModel() { Text = "Recall", TooltipText = "Recall", Id = "Recall" }};
public void Click()
{
HideAllExcept = true;
}
public void ViewAllClick()
{
HideAllExcept = false;
Necessary = false;
isDeposit = false;
}
public void deposit()
{
HideAllExcept = false;
isDeposit = true;
}
. . .
} |
How about the Trashbin? When I clicked Trashbin I want to display restore button only
|
<button @onclick="ViewAllClick">ViewAll</button>
<button @onclick="deposit">Deposited</button>
<button @onclick="Click">TrashBin</button>
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" AllowExcelExport="true" AllowPdfExport="true" Toolbar="@Toolbaritems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
. . .
</SfGrid>
. . .
@code{
SfGrid<Order> GridInstance { get; set; }
. . .
public void Click()
{
isDeposit = false;
HideAllExcept = true;
}
public void ViewAllClick()
{
HideAllExcept = false;
isDeposit = false;
Necessary = false;
}
public void deposit()
{
HideAllExcept = false;
isDeposit = true;
}
. ..
} |