I have 2 questions on how to do something with the grid component.
Setup
Here are the options I have set for the grid component.
<TelerikGrid @ref="Grid"
Data="Entries"
TItem="ProductEntryModel"
Class="font-size mb-1"
Sortable="true"
SortMode="@Telerik.Blazor.SortMode.Multiple"
FilterMode="@GridFilterMode.FilterMenu"
FilterMenuType="@FilterMenuType.CheckBoxList"
ScrollMode="@GridScrollMode.Virtual"
SelectionMode="@GridSelectionMode.Single"
Height="570px"
Width="100%"
RowHeight="40"
PageSize="@PageSize"
EditMode="@GridEditMode.Incell"
EnableLoaderContainer="@IsLoading"
@bind-SelectedItems="SelectedItems"
OnEdit="OnEditEventHandler"
OnUpdate="OnUpdateEventHandler"
Navigable="true"
Size="sm">
For Context the first cell is a TemplateColumn with a TelerikCombobox Component in it.
On Load
It loads all the entries for the day selected.
It adds a new line automatically at the bottom for adding more. But if the rows are longer than the height the new row will not fully show its whole height and I want it to start in edit of the first cell. The image shows that it is selected but not in edit.
This image is right after load. You can see the row is selected but not in edit and half off-screen. If the rows are further than the height it will not bring it into view either.
I would like it to start in view and the first cell in edit, how to accomplish that?
In Edit
This method below allows the user to keep adding rows to the grid after the PO NU... field loses focus. It works great as long as the grids next row is not out of view. Once it is out of view it will add the line, select it, and bring it to view, but the first cell is now out of edit and the user has to click in to the cell to start entry.
Similar to above, how do I set the focus in the first cell? Some of this code is different attempts to get it to work.
private async Task AddNewRecord(ProductEntryModel? entry = null)
{
if (Entries.Any(x => x.ProductId == 0)) return;
var newLine = new ProductEntryModel
{
EntryDate = EntryDate,
PoNumber = entry != null ? entry.PoNumber : "", // Carry down
Sublet = entry != null && !string.IsNullOrWhiteSpace(entry.PoNumber) ? entry.Sublet : "", // Carry down
};
Entries.Add(newLine); // Add A new line
PageSize = Entries.Count > 15 ? Entries.Count : 15; // increase page size
SelectedItems = new List<ProductEntryModel>() {newLine}; // Select new line
await Task.Delay(100); // Wait for the grid to update - Doesn't help select the next entry
await ProjectCombobox.FocusAsync(); // New Attempt and doesn't work
//Grid.Rebind();
}
Is there a way to open a dialog/window next to the button that opened it?
<GridColumns>
@foreach (DataRow column in gridColumnData.Rows )
{
<GridColumn Field="@nameof(Person.Age)" Title="@column["columnname"].ToString()" />
}
</GridColumns>
how can i make Field properties also dynamic without creating object model
when i display values without creating model i cant use filter mode it throws unhandled exception?
I'm in need for an OnRendered event (or similar) for a TelerikWindow component. Actually, it would be nice to have for all Telerik blazor components. I this particular case I need to know when a specific <div> is avaible to the browser DOM so that I can call some javascript interop on it. In this case I need to show I leaflet map in the modal window.
I solved it for now, using a javascript timeout of 0.1 second, but that is bad coding.
When scrolling up in a virtual grid, the rows "above" seems to not be kept or loaded like when scrolling down, and it takes a while before they gets "loaded" and shown. This behaviour is not very user friendly and should be corrected. I can accept a certain time of delay when doing large scrolls using the scrollbar, but not when doing a scroll-wheen or page-up scroll.
Unless I missed something in the grid properties? I got the PageSize set.
How to set in code the first row of the grid selected?
grdRptCallDetails_SelectedItems = RptResults[0].ToList();
Wont work. So How do I set that to the first row in the grid?
I am using treelist to display an hierarchical dataset that is read from an API using web calls.
I have encounbtered a problem where my source data contained many root items (which was an actual programming error), but by this surfaced a problem that you have to read ALL roots (or all children of an item) in order to make paging work correctly.
As in some cases I may have up to 10K "child" items (whichs unfortunately landed in my root due to the error), I would expect treeview and treelist to handle this without actually having to transfer 10K objects from my API call.
For this, a similar solution like the one used for the grid "OnRead" event would be a good solution as this could tell the treeview how many (root or direct child) objects there actually are and provide the offset to start reading with and how many objects to return.
You could even throw in filtering and sorting for all I care and recycle the DataRequest class for this.
This in turn should help getting the "paging" right for the treelist/treeview.
Regards - Hans
Hi
Is there a better way to add an automated permission than replacing an existing component type?
How else can I automatically check permissions on the base component "TelerikButton" instead of "MyTelerikButton"?
With a large number of thousands of fields, it does not want to fill the Enable/Visible per field.
My question is not only about permissions, but also about the ability to extend TelerikButton with its my additional [Parameter] which is not included in the basic set.
I would be grateful if you could suggest a better solution.
@foreach (var item in ListOfItemNames.Take(200))
{
<div class="row">
<div class="col">
<label for="@item">@item</label>
<MyTelerikButton Id="@item" Form="Device" Icon="SvgIcon.Stop" Title="@item" OnClick="@ButtonAction" ButtonType="ButtonType.Button" />
<MyTelerikTextBox Id="@item" Name="Device" Value="@item"></MyTelerikTextBox>
@* ...<Telerik...> etc *@
</div>
</div>
}
My Component
public class MyTelerikButton: TelerikButton
{
[CascadingParameter (Name = "Privileges")]
public required List<Privilege> Privileges { get; set; } = [];
protected override void OnInitialized()
{
base.OnInitialized();
var buttonName = Form + Id;
Enabled = Privileges.Any(x=>x.Code == buttonName);
}
}
I have a filter on End Date set at start up.
If I filter manual I get the filter indicator. How can I get the same result from code?
This is the code that I am using. Called from event
OnStateInit="@( (GridStateEventArgs<FundFirm> args) => OnFundFirmGridStateInit(args) )"
private async Task OnFundFirmGridStateInit(GridStateEventArgs<FundFirm> args)
{
args.GridState.FilterDescriptors = new List<IFilterDescriptor>
{
new FilterDescriptor
{
Member = "ExcludeDate", Operator = FilterOperator.IsGreaterThanOrEqualTo,
Value = DateTime.Today,
MemberType = typeof(DateTime)
}
};
}