Telerik Forums
UI for Blazor Forum
1 answer
51 views

Hello
I want to display the desired text in the DatePicker after selecting the date from TelerikDatePicker.
Currently, after selecting the DatePicker, the date is displayed in this field, to which I want to add the desired text.
For example, in the DatePicker field after selecting the date, instead of
07/01/2025
, today is 07/01/2025.

If it is not possible to change the text, at least no text should be displayed in the DatePicker after selecting the date.

Please help me.
Code and image:

 


<TelerikDatePicker @bind-Value="DatePickerValue" >
</TelerikDatePicker>

@code {
	private DateTime DatePickerValue { get; set; } = DateTime.Today;
{

Hristian Stefanov
Telerik team
 answered on 08 Jan 2025
0 answers
57 views
 <TelerikForm EditContext="EditContext" OnValidSubmit="Save" Columns="3" ColumnSpacing="15px">
     <FormValidation>
         <FluentValidationValidator />
     </FormValidation>
     <FormItems>
         <FormItem Id="fiInvoiceFooterElemenName" ColSpan="2">
             <Template>
                 <label class="k-label k-form-label" for="ddlInvoiceFooterElement">@Resources.InvoiceFooterElementName</label>
                 <TelerikDropDownList Id="ddlInvoiceFooterElementName"
                                      TItem="@InvoiceFooterElementCategory"
                                      TValue="@Guid"
                                      TextField="@nameof(InvoiceFooterElementCategory.FullName)"
                                      ValueField="@nameof(InvoiceFooterElementCategory.InvoiceFooterElementCategoryId)"
                                      Data="@invoiceFooterElementCategories"
                                      @bind-Value="@invoiceFooterElementLine.InvoiceFooterElementCategoryId"
                                      OnChange="OnChangeInvoiceFooterElementCategories"
                                    
                                      Width="100%"
                                      DefaultText="@Resources.SelectInvoiceFooterElementCategory">
                     <DropDownListSettings>
                         <DropDownListPopupSettings Height="auto" MaxHeight="250px" Width="auto" />
                     </DropDownListSettings>
                     @* <ItemTemplate>
                         <span>@($"{context.Name} ({context.Code})")</span>
                     </ItemTemplate> *@
                 </TelerikDropDownList>
                 <ValidationMessage For="@(() => invoiceFooterElementLine.InvoiceFooterElementCategoryId)" />
             </Template>
         </FormItem>
     </FormItems>
     <FormButtons>
         <button id="btnSave" type="submit" class="btn btn-sm btnAction btn-action-filled-blue mr-1 mt10">
             @if (saving)
             {
                 <span class="spinner-border spinner-border-sm mr-1"></span>
             }
             @Resources.OK
         </button>
         <button id="btnCancel" type="button" class="btn btn-sm btnAction btn-action-stroke-black mt10" @onclick="@Cancel">
             @Resources.Cancel
         </button>
     </FormButtons>
 </TelerikForm>



i am trying to prevent model close when i changes some text after that press enter key then Model close automatically
Rajkumar
Top achievements
Rank 1
 asked on 08 Jan 2025
2 answers
176 views

I want the Grid to display correctly on different devices like Mobile And Tablet.

In other words, I want to have a Responsive Grid.

In such a way that the Grid is displayed correctly in different dimensions and the remaining columns that do not fit on the page are scrolled horizontally.
Please help me.
Currently, on different devices such as mobile and tablet, the Grid is displayed as small columns, which is not suitable at all.
Thanks

Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 07 Jan 2025
1 answer
46 views

I have a TelerikGrid whose columns is dynamically populated with List<ExpandoObject>.
I need a TelerikProgressBar to display one of the columns. I have used the following code but TelerikProgressBar only displays the value of the first record for all rows and individual rows are not displayed properly in TelerikProgressBar.
Please help me.
Thanks

	
<GridColumns>
@{
	if (GridData != null && GridData.Any())
	{
		var firstDataItem = (IDictionary<string, object>)GridData.First();

		foreach (var item in firstDataItem)
		{
			if (item.Key != "ProgressBar_Num")
			{
				<GridColumn Field="@item.Key" FieldType="@item.Value.GetType()" @key="@item.Key">
					<Template>
						<TelerikProgressBar Class="width-100" Max="100" Value="(double)item.Value">
						</TelerikProgressBar>
					</Template>
											
				</GridColumn>
			}
		}
	}
}
</GridColumns>

Tsvetomir
Telerik team
 answered on 07 Jan 2025
1 answer
72 views

Is there a way to use a Switch control instead of checkbox in a TreeView? I am able to use ItemTemplate to insert a switch next to the checkbox but I need to replace the checkbox and have the switch use CheckChildren and CheckParents.

Any ideas?

Thanks!

<TelerikTreeView OnItemRender="@OnItemRender" CheckBoxMode="TreeViewCheckBoxMode.Multiple" CheckChildren="true" CheckParents="true" Data="@FlatData" @bind-ExpandedItems="@ExpandedItems">
    <TreeViewBindings>
        <TreeViewBinding TextField="Text" IdField="Id" ParentIdField="ParentId" ItemsField="Text" HasChildrenField="HasChildren" IconField="Icon">
            <ItemTemplate>
                @{var treeItem = (TreeItem)context; }
                <div class="treeview-item">
                    <TelerikSwitch @bind-Value="treeItem.IsChecked" />
                    <span>@treeItem.Text</span>
                </div>
            </ItemTemplate>
        </TreeViewBinding>
    </TreeViewBindings>
</TelerikTreeView>
Dimo
Telerik team
 answered on 02 Jan 2025
0 answers
38 views
TelerikEditor custom tool component: Paste any string, bold and italic not working. Could you please me suggest me how to resolve this issue?.
Shahil
Top achievements
Rank 1
 asked on 27 Dec 2024
1 answer
81 views

Couple of questions:

1.  When working Add command for a detail templated grid, the args parameter doesn't provide for the parent model so there is no way to quickly determine values needed from the parent that will populate the child/detail (like primary key values on a composite key).  I guess I can manually track "current parent row" via OnRowClick but that seems a bit tedious?  Surely there is an easier approach?  I was expecting the OnCreate for detail grid to provide parent object/model as part of the event parameters, but that doesn't seem to be the case.

2.  When working EditMode=InCell on a detail grid, my expectations was that when I click on an empty grid it would automatically put me into EditMode (Add) for a new detail row, but that doesn't seem to be the case?  I have to go thru the OnCreate (which doesn't provide for parent model).

I was reading thru your documentation here and here but they weren't useful for is a real world scenario as none of the examples show "Add" case on a detail item that relies on a parent key value to build a composite key when the data is actually saved to a database.

Any clean suggestions other than tracking "current parent row" via OnRowClick?

Rob.

Hristian Stefanov
Telerik team
 answered on 25 Dec 2024
1 answer
56 views
When enabling a GridSearchBox in my Grid, while I'm typing or deleting letters from the search box, I get spammed in my Ouput from Debug with

"Exception thrown: 'System.Threading.Tasks.TaskCanceledExceptuion' in System.Private.CoreLib.dll"

Here is my code:


<TelerikGrid Data=@TestItemsList
             FilterMode="GridFilterMode.FilterRow"
             Sortable="true"
             EditMode="GridEditMode.Inline"
             Height="2000px"
             FilterRowDebounceDelay="300">
    
    <GridToolBarTemplate>
        <GridCommandButton Command="Add" Icon="@SvgIcon.Plus" Enabled="@UserModel.CanEdit()">Add Item</GridCommandButton>
        <GridSearchBox Fields="@SearchableFields" Placeholder="Search..." Width="300px" />
    </GridToolBarTemplate>

    <GridColumns>
        <GridColumn Field="@nameof(TestModel.FileName)"
                    Title="File Name"
                    Editable="false" />

        <GridCommandColumn>
            <GridCommandButton Command="Save"
                               Icon="@SvgIcon.Save"
                               ShowInEdit="true"
                               Enabled="@UserModel.CanEdit()"
                               OnClick="@OnUpdate">
                Update
            </GridCommandButton>

            <GridCommandButton Command="Edit"
                               Icon="@SvgIcon.Pencil"
                               Enabled="@UserModel.CanEdit()">
                Edit
            </GridCommandButton>

            <GridCommandButton Command="Delete"
                               Icon="@SvgIcon.Trash"
                               Enabled="@UserModel.CanEdit()"
                               OnClick="@OnDelete">
                Delete
            </GridCommandButton>

            <GridCommandButton Command="Cancel"
                               Icon="@SvgIcon.Cancel"
                               ShowInEdit="true"
                               Enabled="@UserModel.CanEdit()">
                Cancel
            </GridCommandButton>

        </GridCommandColumn>

    </GridColumns>
</TelerikGrid>

@* Only showing relevent code here *@
@code {

    private List<string> SearchableFields = new List<string> { nameof(SDSModel.Title), nameof(SDSModel.FileName) };

}

Details:
System.Threading.Tasks.TaskCanceledException
  HResult=0x8013153B
  Message=A task was canceled.

Call Stack:
Tsvetomir
Telerik team
 answered on 24 Dec 2024
1 answer
147 views

Hi,

Is there any way to correctly display an HTML-formatted output using the TelerikAIPrompt control? The response I get from the API call is a Markdown string. I converted this to HTML, and all I see is text with the HTML tags printed (listed listed in the sample below). 

It would be nice to have a way to use (MarkupString) to ensure the HTML is correctly shown.

My code is listed below for reference:

@page "/aitest"

@inject Microsoft.Extensions.Options.IOptions<ServerConfig> ServerConfig;

@using Ganss.Xss;
@using Markdig;
@using Newtonsoft.Json.Linq;
@using RestSharp;

<TelerikAIPrompt OnPromptRequest="@HandlePromptRequest" @ref="@AIPromptRef">
</TelerikAIPrompt>

@code {
    private TelerikAIPrompt AIPromptRef { get; set; } = default!;

    private async Task HandlePromptRequest(AIPromptPromptRequestEventArgs args)
    {
        string url = "{url}";

        var options = new RestClientOptions(url);
        var client = new RestClient(options);
        var request = new RestRequest("", Method.Post);

        request.AddHeader("Content-Type", "application/json");
        request.AddJsonBody("{\"api_key\": \"" + ServerConfig.Value.APIKey.ToString() + "\", \"question\": \"" + args.Prompt + "\"}");

        RestResponse response = new();
        response = await client.PostAsync(request);

        JObject data = JObject.Parse(response.Content ?? string.Empty);

        var answer = data["answer"] switch
        {
            null => string.Empty,
            _ => data["answer"]!.ToString()
        };

        // Convert the Markdown in the output to HTML
        var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
        string html = Markdown.ToHtml(answer, pipeline);

        // Sanitize the HTML
        var sanitizer = new HtmlSanitizer();
        string safeHtml = sanitizer.Sanitize(html);

        args.Output = safeHtml;
    }
}
Hristian Stefanov
Telerik team
 answered on 24 Dec 2024
1 answer
107 views
I have a TelerikGrid utilizing the FilterRow for FilterMode. One of the columns is called CurrentVersion where the CurrentVersion could be a copy of multiple other objects but it's Revision is higher. The objects with CurrentVersion = true, I want to be the only initially displayed items. If there is an item that is CurrentVersion = false, I still want it to be accessible by changing the filter to All instead of True, but I need true to be the default. How would I go about this? I've checked documentation and can't find a solution. I've also checked online and other forums posts and can't seem to find a solution. ChatGPT and CoPilot are also no help here.

<TelerikGrid Data=@TestItemsList
             FilterMode="GridFilterMode.FilterRow"
             Sortable="true"
             EditMode="GridEditMode.Inline"
             Height="2000px">

        <GridColumn Field="@nameof(TestModel.CurrentVersion)"
                    Title="Current Version"
                    Editable="true"
                    Filterable="true">

</TelerikGrid>
Hristian Stefanov
Telerik team
 answered on 24 Dec 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?