I have used grid control with batch mode for data entry purpose.There is some difficultlies for entering data in grid which is not user friendly to fast data entry.(Enter key Tab index navigation and selecting record in grid combobox).
So I am planning to use external controls (Textbox, combobox etc) for fast data entry with enter key navigation.
So my original question is
1.How to place external control in grid toolbar
2. External controls position should be same position of grid column
For example
Width of External controls should be same as grid column width and left and right margin should be same as grid column.
3.Need Enter key navigation for all external controls.
4.When I press Enter key in last external control,the new row should be added in grid( AddRowasync method).
For example,
The added value in grid should be taken from external control model.
Hope this question is clear.
Please help its my top most urgent task ,without the help of syncfusion support team it will be difficult to complete task.
Thanks and Awaiting for prompt reply...
Ok thanks
Awaiting for prompt reply
|
[Index.razor]
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<SfToolbar>
<ToolbarItems>
<ToolbarItem Type="ItemType.Input">
<Template>
<CustomToolbar></CustomToolbar>
</Template>
</ToolbarItem>
</ToolbarItems>
</SfToolbar>
<GridColumns>
. . .
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid;
. . .
} |
|
[CustomToolbar.razor]
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Inputs
@using WebApplication1.Data
<table>
<colgroup>
@*we suggest you to create and set the width based on your required number of columns and based on your column size*@
<col style="width: 318px" />
<col style="width: 326px" />
<col style="width: 327px" />
<col style="width: 406px" />
</colgroup>
<tbody>
<tr>
<td>
<SfNumericTextBox @ref="IdRef" @bind-Value="@IdValue" TValue="int?"></SfNumericTextBox>
</td>
<td>
<SfTextBox @ref="NameRef" @bind-Value="@NameValue" Placeholder='Customer Name'></SfTextBox>
</td>
<td>
<SfNumericTextBox @ref="FreightRef" @bind-Value="@FreightValue" TValue="double?"></SfNumericTextBox>
</td>
<td>
<SfDropDownList @ref="CountryRef" TValue="string" Placeholder="e.g. Australia" TItem="Countries" @bind-Value="@CountryValue" DataSource="@Country">
<DropDownListFieldSettings Value="Name"></DropDownListFieldSettings>
<DropDownListEvents TItem="Countries" TValue="string" Blur="@BlurHandler"></DropDownListEvents>
</SfDropDownList>
@*add this invisible element to for moving back to first NumericTextBox*@
<div class="form-row" style="width:0px;height:0px">
<div class="form-group col-md-12">
<label class="e-float-text e-label-top">Dummy</label>
<input id="dummy" style="width:0px;height:0px;opacity:0" />
</div>
</div>
</td>
</tr>
</tbody>
</table>
@code {
SfNumericTextBox<int?> IdRef;
SfTextBox NameRef;
SfNumericTextBox<double?> FreightRef;
SfDropDownList<string, Countries> CountryRef;
int? IdValue { get; set; }
string NameValue { get; set; } = "";
double? FreightValue { get; set; } = 0;
public string CountryValue;
[CascadingParameter]
public SfGrid<Order> Grid { get; set; }
. . .
private async Task BlurHandler(Object args)
{
await Grid.AddRecordAsync(new Order() { OrderID = IdValue, CustomerID = NameValue, Freight = FreightValue, ShipCountry = CountryValue }, 0);
IdValue = 0;
NameValue = "";
FreightValue = 0;
CountryValue = "";
StateHasChanged();
await IdRef.FocusAsync(); //for focusing first numeric textbox (OrderID)
}
}
|
Thanks for support
Regarding column width
It should be auto based on screen resolution .
Please check below screencast for you reference. and also I need "enter key navigation " for focusing next control
https://www.screencast.com/t/E7bTe0lcX
|
<div>
<table>
. . .
<tbody>
<tr>
<td>
<SfNumericTextBox @ref="IdRef" @bind-Value="@IdValue" @onkeydown="IdDownHandler" TValue="int?"></SfNumericTextBox>
</td>
<td>
<SfTextBox @ref="NameRef" @bind-Value="@NameValue" @onkeydown="NameDownHandler" Placeholder='Customer Name'></SfTextBox>
</td>
<td>
<SfNumericTextBox @ref="FreightRef" @bind-Value="@FreightValue" @onkeydown="FreightDownHandler" TValue="double?"></SfNumericTextBox>
</td>
<td>
<SfDropDownList @ref="CountryRef" TValue="string" Placeholder="e.g. Australia" TItem="Countries" @bind-Value="@CountryValue" DataSource="@Country">
<DropDownListFieldSettings Value="Name"></DropDownListFieldSettings>
<DropDownListEvents TItem="Countries" TValue="string" ValueChange="@ValueChangeHandler" Blur="@BlurHandler"></DropDownListEvents>
</SfDropDownList>
. . .
</td>
</tr>
</tbody>
</table>
</div>
@code {
SfNumericTextBox<int?> IdRef;
SfTextBox NameRef;
SfNumericTextBox<double?> FreightRef;
SfDropDownList<string, Countries> CountryRef;
int? IdValue { get; set; }
. ..
private async Task BlurHandler(Object args)
{
if(IdValue != 0 && IdValue != null){
await Grid.AddRecordAsync(new Order() { OrderID = IdValue, CustomerID = NameValue, Freight = FreightValue, ShipCountry = CountryValue }, 0);
IdValue = 0;
NameValue = "";
FreightValue = 0;
CountryValue = "";
}
}
private async Task IdDownHandler(KeyboardEventArgs args)
{
if(args.Key == "Enter")
{
await NameRef.FocusAsync();
}
}
private async Task NameDownHandler(KeyboardEventArgs args)
{
if (args.Key == "Enter")
{
await FreightRef.FocusAsync();
}
}
private async Task FreightDownHandler(KeyboardEventArgs args)
{
if(args.Key == "Enter")
{
await CountryRef.FocusAsync();
}
}
. . .
private async Task ValueChangeHandler(ChangeEventArgs<string, Countries> args)
{
await IdRef.FocusAsync(); //for focusing first numeric textbox (OrderID)
}
}
|
For screen resolution, I will check and get back to you
For enter key navigation inside the toolbar, Can I use below code ???
Please advise