Telerik Forums
UI for ASP.NET Core Forum
1 answer
220 views

I am using kendo grid popup editor with a template.

.Editable(c => { c.TemplateName("_CustomTemplate").Mode(GridEditMode.PopUp); })

This is the _CustomTemplate i am using

@model Models.CustomViewModel
<div id="popupeditor">
    @Html.HiddenFor(model => model.Id)
    <button type="button" id="NewEmailButton">Add New Email</button>
</div>

And the template model is

public class CustomViewModel 
{
    public string Name { get; set; }
    public List<string> EmailList { get; set; } = new List<string>();
}

User can add new input for email by clicking the "Add New Email" button. I am adding the input to PopUp container with javascript.

function AddEmail() 
{
    let index = 0;
    let input = '<input name="EmailList[index]" type="text"/>'
    $(input).appendTo('#popupeditor');
}
The problem is when i click save on the popup editor it doesn't bind to my model. It doesn't even go to my save method. If i edit the Name it goes to the Save method but Emails list stays empty.
Stoyan
Telerik team
 answered on 10 May 2022
1 answer
388 views

I need to make jquery repeater work inside the popup editor.

I need to show repeater for customer email.

public class CustomerViewModel {

public string Name {get; set;}

public List<CustomerRepeatedModel> CustomersRepeatedValues{ get; set; } = new List<CustomerRepeatedModel>(); public class CustomerRepeatedModel {

// this should be added and removed with repeater public string Email { get; set; } } }

The kendo grid

@(Html.Kendo().Grid<CustomerViewModel>
                                ().Name("customerGrid")
                                .Sortable()
                                .Scrollable()
                                .ToolBar(c => {
                                    c.Create().Text("Create Customer");
                                })
                                .Columns(columns =>
                                {
                                    columns.Bound(c => c.Id).Title("Customer ID").Filterable(false).Visible(false);
                                    columns.Bound(c => c.CustomerRepeatedValue).Visible(false);
                                    columns.Bound(c => c.Name).Title("Customer Name");

                                    columns.Command(column =>
                                    {
                                        column.Edit();
                                        column.Destroy();
                                    });
                                })
                                .Editable(c =>
                                {
                                    c.TemplateName("_CustomerTemplate")
                                        .Mode(GridEditMode.PopUp);
                                })
                                .DataSource(ds => ds.Ajax()
                                .Read(r => r.Url("/Customer/Index?handler=Read"))
                                .Update(u => u.Url("/Customer/Index?handler=Update"))
                                .Create(c => c.Url("/Customer/Index?handler=Create"))
                                .Destroy(d => d.Url("/Customer/Index?handler=Destroy"))
                                .Model(m =>
                                    {
                                    m.Id(model => model.Id);
                                    m.Field(model => model.Id).Editable(false);
                                    m.Field(model => model.Name);
                                    m.Field(model => model.IsDeleted).Editable(false);
                                    m.Field(model => model.CustomerRepeatedValues);
                                    })
                                )
                                .Events(e => e.Edit("grid_edit")@*.Save("grid_save")*@)


The _CustomerTemplate

In the popup template i can't access to Model. It is always null. So as i found on the forum i populated the repeater in the edit event. But if it is posibble to access Model inside the template i would like to know how.

@model WebUI.Pages.CustomerViewModel

<div>
    @Html.HiddenFor(model => model.Id)
    <div>
        <div class="col-4 mb-2">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="col-8 mb-2">
            @Html.TextBoxFor(model => model.Name)
        </div>
        <div class="repeater">
            <div data-repeater-list="CustomerRepeatedValues">
                <div class="col-4 mb-2">
                    Customer Emails
                </div>
                @*@for (var index = 0; index < Model.CustomerRepeatedValues.Count; index++)
                {
                    <div data-repeater-item>
                        <input type="text" name="Email" value="@(Model.CustomersRepeatedValues[index].Email)"/>
                        <button data-repeater-delete type="button">
                            Remove
                        </button>
                    </div>
                }*@
            </div>
            <div>
                <button data-repeater-create type="button">
                    <i class="fa fa-plus"></i>
                </button>
            </div>
        </div>
    </div>
</div>

When i open the popup editor it shows the repeater, i can add or remove items. But when i click save it doesn't save it, it doesn't even go to save method. But if i change the name on the popup editor and click save it does go to save method but the changed emails are not bounded to model only the name is updated.

If there is better way to do this i would like to get your help

Aleksandar
Telerik team
 answered on 10 May 2022
1 answer
238 views

Hello,

I load content to a tabstrip dynamically via ContentUrl and Ajax.

Most of them have the same height (might differ slightly). 

When I click a tab item the first time, the content is collapsed and expanded, which leads to flickering. After the content of a tab is loaded once, it is fine.

I tried to set a fixed height and switched off animation -> did not solve the problem.

Are there any workarounds to pre-initialise the height of unloaded contents with the height of the selected item and adjust them dynamically  to the required height?

Any chance to avoid collapsing when loading the content dynamically?

Thanks,

Christine

Aleksandar
Telerik team
 answered on 10 May 2022
1 answer
161 views

I have been trying to get the instance of a radiogroup, using kendo.widgetInstance("#radiogroup"), but the call always returns null. Has anyone experienced this issue?

See the example below...


<ul data-role="group" id="radiogroup" name="radiogroupName" class="k-radio-list k-list-horizontal" role="radiogroup"></ul>

...

<script>kendo.syncReady(function(){jQuery("#radiogroup").kendoRadioGroup({items: {...}, value: "...", layout: "horizontal"});});</script>

<script>
...some other script activated by an event...
const widget = kendo.widgetInstance($("#radiogroup"));
...
</script>
Stoyan
Telerik team
 answered on 09 May 2022
1 answer
168 views

I've been struggling with the Captcha audio not playing on my page. I think I've figured it out but would like to confirm if this is the correct method.

I had been using the AudioHandler method with a URL to the audio source. This results in the wav data getting passed to _playAudio which gets passed to "new Audio()". This does not seem to be correct based on the Audio constructor. The examples all use AudioHandlerFunction which returns a URL, so I expected the two similar methods to produce the same results.

Instead, AudioHandlerFunction directly configures the URL for the audio. AudioHandler configures a URL that is fetched that contains a URL to where the audio is. This seems counterintuitive as the AudioHandler adds the captcha ID to the URL request.

Could a helper method be added to link directly to the audio source? Something like:

Html.Kendo().Captcha()
            .Name("captcha")
            .CaptchaId((string)ViewData["CaptchaId"])
            .Handler(handler => handler.Action("Reset", "Captcha"))
            .ValidationHandler(handler => handler.Action("Validate", "Captcha"))
            .CaptchaAudio(handler => handler.Action("Audio", "Captcha"))

This would bypass the need to have javascript to process the url:

        function audioHandler(args) {
            var url = '@Url.Action("Audio", "Captcha")';
            args.success(url + "?captchaId=" + args.data.CaptchaId);
        }

Alexander
Telerik team
 answered on 05 May 2022
1 answer
134 views

Instead of showing as much name as can fit into the field, my field shows an ellipsis.  How can I get it to show as much as is possible instead of not even trying.

My template with an icon and the Text Name:

<script id="icon-template" type="text/x-kendo-template">
    <div class='group-icon'
         style='background-image: url(@Url.Content("#: ImageUrl #"));'></div>
    <div class='group-name'
        style='overflow: hidden; white-space: nowrap;'>#: Name #</div>
</script>

My column:

columns.Add().Field(e => e.Name).TemplateId("icon-template").Width(Glossary.Portal.ButtonWidthExtraWide);

Tsvetomir
Telerik team
 answered on 04 May 2022
1 answer
122 views

Hello,

We are using custom grid popup forms for adding/updating records, and some fields have server validations, and are using the solution described here:

https://docs.telerik.com/aspnet-core/knowledge-base/grid-popup-editing-show-server-validation-errors?_ga=2.158091705.2007812860.1650987718-278551097.1647285099

This works great for displaying the validation message, but the problem we are having is that using this method doesn't change the associated control's border to red ("k-invalid") like the automatic client-side validation does for invalid entries. (Screen shots attached to show difference)

Is there a known or relatively easy way to accomplish this?  I realize that some controls, like dropdowns or date pickers, apply the k-invalid class to different html elements within the control, so this might be too tricky to solve. 

At the end of the day, this is not a major issue, although it does add inconsistency and a small level of accessibility concern to the popup forms. Any suggestions are welcome and appreciated!

Thanks!

Tony

Tsvetomir
Telerik team
 answered on 02 May 2022
1 answer
296 views

Hi there,

I am having trouble configuring the Grid sort by group aggregate. I was following the tutorial( https://docs.telerik.com/kendo-ui/knowledge-base/grid-sort-group-by-group-aggregate ) that was done in jQuery, but I didn't manage to configure the grid properly. Can someone share the same configuration in .NET Core?

Thanks.

Georgi
Telerik team
 answered on 02 May 2022
0 answers
143 views

Hello,

I have an existing project where I am trying to use the PDF Viewer control. But in this project I have a JS file callled vendors.bundle.js wich is causing some type of conflict with kendo.all.min.js, making an error of "kendoPDFViewer is not a function" appear at the console.

I have tried putting the scripts references at different points of the application other then the page itself, but that only caused more errors.

I removed the reference to the file vendors.bundle.js, but that made several parts of the project stop working.

So, my question is how do I find out what kind of conflict is this, and how to solve it.

Regards,

Alexandre

Alexandre
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 01 May 2022
1 answer
918 views
               

I need to format the number in Grid as $123.00 or $123.25. The input comes from a modal form.

ViewModel has these values as Double.

Neither format attempts are working, the numbers are displayed as entered.

So if the user entered 1, it should display as $1.00, but instead it displays as 1.

columns.Bound(p => p.MyNumericValue).Title("MyTitle").ClientTemplate("#= kendo.toString(MyNumericValue, '{0:0.00}') #");
 columns.Bound(p => p.MyNumericValue).Title("MyTitle").Format("{0:0.##}");

 

Thanks.

Tsvetomir
Telerik team
 answered on 29 Apr 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
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
Bronze
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?