Hello
I can not speak English. So I use Google Translate.
Even if the explanation is not natural, I hope for your patience.
I don't like the alignment and localization of the default toolbar, so I'm making a custom toolbar.
However, I ran into some problems.
Question 1. I want to give focus to the second column after AddRecord method.(I use inline editing.)
Question 2. How to cancel after AddRecord?(When canceled, the new row should be deleted.)
Question 3. How can I get the changed value on save?
Question 4. I call the procedure and store it in the database. I want to display a modal dialog when an error occurs in a procedure. What should I do?
Any help to me would be appreciated.
- My source code
<SfGrid @ref="gvList" DataSource="@gvListDataSource.C_RETURN1" Height="100%" GridLines="GridLine.Both"
AllowSelection="true" ShowColumnMenu="true">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ></GridEditSettings>
<GridSelectionSettings CellSelectionMode="CellSelectionMode.Box" Mode="SelectionMode.Cell" Type="SelectionType.Single"></GridSelectionSettings>
<GridEvents OnActionBegin="OnActionBegin" OnToolbarClick="ToolbarClickHandler" TValue="SM11010.System"></GridEvents>
<SfToolbar>
<ToolbarItems>
<ToolbarItem Type="@ItemType.Input">
<Template>
<div class="d-flex align-items-center h-25 border-2">
<h5 class="text-center font-weight-bold mt-1">@(Localizer["SYSTEM_LIST"])</h5>
</div>
</Template>
</ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-filter" Text="@(Localizer["FILTER_ROW"])"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" Type="@ItemType.Separator"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-search" Text="@(Localizer["SEARCH"])" OnClick="gvList_SearchClick"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-plus" Text="@(Localizer["NEW"])" OnClick="gvList_NewClick"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-edit" Text="@(Localizer["EDIT"])" OnClick="gvList_EditClick"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-times" Text="@(Localizer["CANCEL"])" OnClick="gvList_CancelClick"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-save" Text="@(Localizer["SAVE"])" OnClick="gvList_SaveClick"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" Type="@ItemType.Separator"></ToolbarItem>
<ToolbarItem Align="@ItemAlign.Right" PrefixIcon="fas fa-file-excel" Text="@(Localizer["EXCEL"])" OnClick="gvList_ExcelClick"></ToolbarItem>
</ToolbarItems>
</SfToolbar>
<GridColumns>
<GridColumn Field=@nameof(SM11010.System.SYS_CD) HeaderText="@(Localizer[nameof(SM11010.System.SYS_CD)])" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.CD_NM_KR) HeaderText="@(Localizer[nameof(SM11010.System.CD_NM_KR)])" TextAlign="TextAlign.Left" Width="150"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.CD_NM_EN) HeaderText="@(Localizer[nameof(SM11010.System.CD_NM_EN)])" TextAlign="TextAlign.Left" Width="130"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.CD_NM_CN) HeaderText="@(Localizer[nameof(SM11010.System.CD_NM_CN)])" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.DEFT_LANG) HeaderText="@(Localizer[nameof(SM11010.System.DEFT_LANG)])" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.USE_FLAG) HeaderText="@(Localizer[nameof(SM11010.System.USE_FLAG)])" TextAlign="TextAlign.Left" Width="120"></GridColumn>
<GridColumn Field=@nameof(SM11010.System.REMARKS) HeaderText="@(Localizer[nameof(SM11010.System.REMARKS)])" TextAlign="TextAlign.Left" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
[Inject] IStringLocalizer<App> Localizer { get; set; }
SfGrid<SM11010.System> gvList;
ReturnData<SM11010.System> gvListDataSource = new ReturnData<SM11010.System>();
protected override void OnInitialized()
{
gvListDataSource.C_RETURN1 = new List<SM11010.System>();
}
async Task gvList_SearchClick()
{
gvListDataSource = await repository.GET_SEARCH();
}
async Task gvList_NewClick()
{
SM11010.System system = new SM11010.System()
{
USE_FLAG = "Y"
};
await this.gvList.AddRecord(system);
await this.gvList.StartEdit();
// The function of question 1 is needed here.
}
async Task gvList_EditClick()
{
await this.gvList.StartEdit();
}
async void gvList_CancelClick()
{
// The function of question 2 is needed here.
}
async Task gvList_SaveClick()
{
// The function of question 3 is needed here.
// Error after calling stored procedure
// The function of question 4 is needed here.
}
async Task gvList_ExcelClick()
{
await this.gvList.ExcelExport();
}
public void OnActionBegin(ActionEventArgs<SM11010.System> args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Add)
{
args.Cancel = true;
}
}
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Text == "Expand all")
{
}
if (args.Item.Text == "Collapse all")
{
}
if (args.Item.Id == "Collapse all")
{
}
}
}