Telerik Forums
UI for ASP.NET MVC Forum
0 answers
6 views

Hello, 

I can't get the Destroy method to work, I often get a 415 error with the GetListUsersDto object as parameters. 

@(Html.Kendo().Grid<GetListUsersDto>().Name("GetListUsersGrid")
        .Groupable()
        .Sortable()
        .Editable()
        .Scrollable()
        .ToolBar(x => x.Create())
        .Columns(columns =>
        {
            columns.Bound(c => c.ID).Title(@Localizer["Tab_User_Id"].Value);
            columns.Bound(c => c.Surname).Title(@Localizer["Editing_User_Surname"].Value);
            columns.Bound(c => c.Firstname).Title(@Localizer["Editing_User_Firstname"].Value);
            columns.Bound(c => c.RoleName).Title(@Localizer["Editing_User_Role"].Value);
            columns.Bound(c => c.DateDebActif).Title(@Localizer["Editing_User_Start_Date"].Value).Format("{0:M/d/yyyy HH:mm:ss}"); ;
            columns.Bound(c => c.DateFinActif).Title(@Localizer["Editing_User_End_Date"].Value).Format("{0:M/d/yyyy HH:mm:ss}"); ;
            columns.Command(c =>
            {
                c.Edit();
                c.Destroy();
            });
        }).DataSource(dataSource => dataSource.Ajax()
        .Read(r => r.Action("getusers", "admin"))
        .Create(r => r.Action("createuser", "admin"))
        .Destroy(r => r.Action("deleteuser", "admin"))
            .Model(model =>
            {
        model.Id(m => m.ID);
        model.Field(f => f.ID).DefaultValue(Guid.NewGuid());
    }
    )).Pageable())
    [HttpPost]
    [Authorize(PolicyEnum.Administrateur)]
    [Route("deleteuser")]
    public string DeleteUser([DataSourceRequest] DataSourceRequest request, GetListUsersDto dto)
    {
        //var result = adminService.DeleteUser(dto.ID);
        return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
    }
public class GetListUsersDto
{
    public Guid ID { get; set; }
    public string Surname { get; set; }
    public string Firstname { get; set; }
    public string Username { get; set; }
    public bool IsActif { get; set; }
    public int RoleId { get; set; }
    public string RoleName { get; set; }
    public int LangId { get; set; }
    public string LangName { get; set; }
    public DateTime DateDebActif { get; set; }
    public DateTime DateFinActif { get; set; }
}

If I change my GetListUsersDto method to Guid ID, the method works but the Guid is empty.

 [HttpPost]
 [Authorize(PolicyEnum.Administrateur)]
 [Route("deleteuser")]
 public string DeleteUser([DataSourceRequest] DataSourceRequest request, Guid Id)
 {
     //var result = adminService.DeleteUser(Guid.Parse(ID));
     return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
 }

If I only set a DataSourceRequest request, the method works, but doesn't return a usable object for my service.

    [HttpPost]
    [Authorize(PolicyEnum.Administrateur)]
    [Route("deleteuser")]
    public string DeleteUser([DataSourceRequest] DataSourceRequest request)
    {
        //var result = adminService.DeleteUser();
        return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
    }

I don't know what to do. Does anyone have a solution or idea?

Thank you,

Stéphane
Top achievements
Rank 1
 asked on 18 Apr 2024
2 answers
581 views

Hi Telerik,

I got an issue when rendering kendo datepicker. At first time we open the page, the value of Kendo datepicker populated. But then, after refresh (via browser button or f5) the value was gone, and only the format shown like below:

The only way to make it populated is to:

  • Hard reload the page (ctrl+f5)
  • change the browser (tested on chrome).
  • change datepickerfor to datepicker() and add .value(x.FldBirthdate.Value.ToString("MM/dd/yyyy")).
    we have to ToString() it, if it's only x.FldBirthdate, it doesn't work.

Here is how I render the kendo datepicker

@(Html.Kendo()
                    .DatePickerFor(x => x.FldBirthdate)
                    .Max(DateTime.Now)
                    .DateInput()
                    .Format("dd/MM/yyyy")
                    .ParseFormats(new List<string>() { "dd MMM yyyy" })
                    .HtmlAttributes(customAttributes)
                    .Events(x => x.Change("dateOnChange"))
                )

I already tried to remove the max, dateinput(), format, parseformat, htmlattributes but the problem still persist.
There is no error message shown in the console.

Kendo version: 2019.3.1023
Jquery version: 3.4.1

Please advise.
Thank you.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 17 Apr 2024
1 answer
6 views

We have this weird scenario where occasionally we get this, and a refresh and it may go away, its 99% not there and 1% of the time shows.

Happens in

Windows
DropDownList

Anton Mironov
Telerik team
 answered on 17 Apr 2024
1 answer
18 views

Is anyone else having any issues trying to download packages using NuGet? I am trying to get the Telerik.UI.for.AspNet.Mvc4 package (latest version) and am getting this error:

Error downloading 'Telerik.UI.for.AspNet.Mvc4.2022.2.802' from  'https://nuget.telerik.com/v3/package/telerik.ui.for.aspnet.mvc4/2022.2.802/telerik.ui.for.aspnet.mvc4.2022.2.802.nupkg'.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host

I am also pursuing this with our internal help desk, but wanted to see if the problem was larger than just me.

 

Thanks!


Eyup
Telerik team
 answered on 17 Apr 2024
1 answer
21 views
Good morning,
 
I’m attempting to implement a ASP.NET MVC grid with custom filter functionality that’s integrated with my grid filters. However, I’m struggling with filter values getting overwritten when performing search filter functionality.
 
In my grid I have inline grid row filtering:
                          .Filterable(filterable => filterable
                               .Extra(false)
                              .Operators(operators => operators
                                  .ForString(str => str.Clear()
                                      .IsEqualTo("Is equal to")
                                      .IsNotEqualTo("Is not equal to")
                                      .StartsWith("Starts with")
                                      .Contains("Contains")
                                      .DoesNotContain("Does not contain")
                                      .EndsWith("Ends with")
                                      .IsNull("Is null")
                                      .IsNotNull("Is not null")
                                      .IsEmpty("Is empty")
                                      .IsNotEmpty("Is not empty")
                               ))
                           )
I also make use of inline grid search as filtering. This search functionality is defined in my grid toolbar:
                       toolbar.Search();
Lastly, for my mentioned custom filter functionality, I have defined two multiselects in my grid toolbar. These multiselects make use of a JavaScript onchange event that gets fired upon changing the multiselect value. This JavaScript function calls grid.dataSource.filter() to apply the filtering and then automatically call the grid read event. The set-up for this code is comparable to the example for the grid toolbar template: https://demos.telerik.com/aspnet-mvc/grid/toolbar-template
To retrieve my results, I make use of a datasource with .webApi() configuration, making use of a controller method that gets called with my read event. This controller method contains a DataSourceRequest that contains the set filters. The problem I’m facing is that when I input text into my search filter, that the set multiselects filters get overwritten.
Is there a way I can perform search and column filter functionality without it overwriting my multiselect filters?
ASP.NET MVC Grid Toolbar Template Demo | Telerik UI for ASP.NET MVC
This Telerik ASP.NET MVC Grid example shows how you can add custom toolbars to the grid and create toolbar templates.

https://demos.telerik.com/aspnet-mvc/grid/toolbar-template
Ivan Danchev
Telerik team
 answered on 17 Apr 2024
0 answers
14 views

Hi all,

I have a grid with multiple cascading dropdown columns, each dropdown gets filtered calling a method in my controller.

What I want now it is simply populate a non editable text column based on the value from one of my previous dropdowns calling a filter method on my controller.

Thank you

LnZ

 

Lorenzo
Top achievements
Rank 1
 asked on 16 Apr 2024
2 answers
22 views

Hi,

We are using the current culture fr-BE which uses dd-MM-yyyy format but when using the DatePicker and inspecting the HTML, we see the following.

As you can see in the screenshot below, the culture is correctly set. 

This happens only with fr-BE, we can see no problems when switching between nl-NL, en-GB, nl-BE, etc.

When we add .Format("d") the component works correctly but that's not what I would expect, since "d" is the default.

And to be honest, I don't want to add that manually everywhere. It should take the correct one as a default.

Our current version is 2022.3.913 but updating is not possible at the moment.

Any help would be appreciated

Kind regards

 

 

Ken
Top achievements
Rank 1
Iron
 answered on 09 Apr 2024
1 answer
20 views

Hi I'm attempting to repeat a vehicle (year/make/model) set of cascading dropdown lists in a component that would result in up to 3 vehicle selectors on the same form. Running into issues as the ddls have the same ids. I've been playing around with appending counters to the name etc but running into the issue where the last set of ddls gets the data. Wondering

1. If there is a working example of this scenario

2. If it is possible to pass a value to the filter function

 

Thanks.

Anton Mironov
Telerik team
 answered on 09 Apr 2024
1 answer
24 views

I'm having an issue with a Grid component.  I have 2 custom editors for 2 small dropdown lists.  Anytime I select anything other than the default options for either (or both) dropdown lists, the default still gets assigned to the field for some reason.  I've tried debugging but it seems that it's getting changed before anything is sent to the controller (defaults are already present in the post action).

I set the custom editors up using the instructions here.

This is the component itself

@(
Html.Kendo().Grid<CHAASAddInsuredsViewModel>()
.Name("AddlInsureds")
.Columns(columns =>
{
columns.Bound(c => c.FirstName).Width(130);
columns.Bound(c => c.MiddleInitial).Width(70);
columns.Bound(c => c.LastName).Width(150);
columns.Bound(c => c.DOB).Format("{0:MM/dd/yyyy}").Width(150);
columns.Bound(c => c.RelationshipType)
.ClientTemplate("#=RelationshipType.RelationshipName#")
.EditorTemplateName("RelationshipTypeEditor").Width(140);
columns.Bound(c => c.Gender)
.ClientTemplate("#=Gender.GenderName#")
.EditorTemplateName("GenderEditor").Width(150);
columns.Bound(c => c.SSN).Width(160)
.HtmlAttributes(new { @class = "text-center" });
@* .EditorTemplateName("SSNEditorTemplate"); *@
@* .ClientTemplate("<h4>XXX-XX-XXXX</h4>"); *@
columns.Command(c => { c.Edit(); c.Destroy(); });
}
)
.ToolBar(toolbar => toolbar.Create().Text("Add Family Member"))
.Editable(editable => editable.Mode(GridEditMode.InLine)
.ConfirmDelete("Continue to delete this record?")
.DisplayDeleteConfirmation("Continue to delete this record?"))
.Sortable()
.Scrollable()
@* .HtmlAttributes(new { style = "height:550px;" }) *@
.DataSource(d => d
.Ajax()
.Model(m =>
{
m.Id(i => i.Id);
m.Field(f => f.RelationshipType)
.DefaultValue(ViewData["defaultRelationshipType"] as HNL_Agents.Models.AddlInsuredRelationshipType);
m.Field(f => f.Gender)
.DefaultValue(ViewData["defaultGender"] as HNL_Agents.Models.AddlInsuredGender);
})
.Events(e => e.Error("error_handler"))
.Create(c => c.Action("Insured_CreateUpdate", "CHAAS", new { modelAppId = Model.AppId }))
.Read(r => r.Action("GetInsureds", "CHAAS", new { modelAppId = Model.AppId}))
.Update(c => c.Action("Insured_CreateUpdate", "CHAAS", new { modelAppId = Model.AppId }))
.Destroy(d => d.Action("RemoveInsureds", "CHAAS"))
)
)

 

My model is as follows.

public class CHAASAddInsuredsViewModel
{

[AllowNull]
[ScaffoldColumn(false)]
[HiddenInput]
public int? Id { get; set; }

[AllowNull]
[ScaffoldColumn(false)]
[HiddenInput]
public int? AppId { get; set; }


[UIHint("RelationshipTypeEditor")]
[Display(Name ="Relationship Type")]
public AddlInsuredRelationshipType RelationshipType { get; set; }

[Required]
[StringLength(35)]
[Display(Name = "Last Name")]
public string LastName { get; set; }

[Required]
[StringLength(35)]
[Display(Name = "First Name")]
public string FirstName { get; set; }

[AllowNull]
[Display(Name = "M.I.")]
[RegularExpression("^[a-zA-Z]$", ErrorMessage = "Middle Initial must be only 1 letter")]
public string? MiddleInitial { get; set; }

//public int Age { get; set; }

[Required]
[Display(Name = "Birth Date")]
[DataType(DataType.Date)]
[CHAASChildMaxAge(26, ErrorMessage = "The maximum age for a child is 26.")]
public DateTime DOB { get; set; }


[UIHint("GenderEditor")]
public AddlInsuredGender Gender { get; set; }

[Required]
[Display(Name = "Social Security #")]
[StringLength(9)]
//[UIHint("SSNEditorTemplate")]
[RegularExpression(@"^\d{9}|[1-9]{2}\d{1}-\d{2}-\d{4}$", ErrorMessage = "Invalid Social Security Number")]
public string SSN { get; set; }
}

 

These are the custom editors for the drop down lists

@(
Html.Kendo().DropDownList()
.Name("RelationshipType")
.DataValueField("RelationshipId")
.DataTextField("RelationshipName")
.BindTo((System.Collections.IEnumerable)ViewData["relationshipTypes"])
)

 

@(
Html.Kendo().DropDownList()
.Name("Gender")
.DataValueField("GenderId")
.DataTextField("GenderName")
.BindTo((System.Collections.IEnumerable)ViewData["genders"])
)

 

 

Please let me know if there is anything I'm missing or if you need any more information.  Thanks for the help!

Anton Mironov
Telerik team
 answered on 04 Apr 2024
0 answers
18 views

Hi,

I am getting extra characters like ÃƒÂ¾ÃƒÂ¿PDF Check in metadata of the exported PDF from Kendo grid. That reflects into the title of the PDF in chrome browser.

Is there any way to remove that extra characters from the metadata using jQuery?

I am attaching screenshot of the PDF file.

 

Trusha
Top achievements
Rank 1
Iron
 asked on 01 Apr 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?