Telerik Forums
UI for ASP.NET MVC Forum
0 answers
1 view

I have review this form discussions but cannot get this working.

How to add a delete button to editor template Grid Popup? in Kendo UI for jQuery | Telerik Forums

 

How can I add an additional update button inside of my grid popup editor template? I have the exact same requirements as discussed in 

Add extra button to Grid popup editor template in UI for ASP.NET MVC | Telerik Forums

Perhaps little different as I am using a custom popup editor template called RecordEdit.cshtml as outlined in  ASP.NET MVC Data Grid Component Use Custom Popup Editors - Telerik UI for ASP.NET MVC
@(Html.Kendo().Grid//....
  //....
 .Events(ev=>ev.Edit("onEdit"))  
 .Editable
  (
      editable => editable.Mode(GridEditMode.PopUp)
      .TemplateName("RecordEdit")
      .Window(e => e.Width(1400).Height(1200))
  )
)
 
function onEdit() {
    $('<a class="k-button k-button-icontext k-grid-delete" href="\\#"><span class="k-icon k-delete"></span>Delete</a>').insertAfter(".k-grid-cancel");
}
Any assistance would be most helpful.
Bermuda
Top achievements
Rank 1
Iron
 asked on 23 Apr 2024
0 answers
3 views

I am unable to use the filter function i.e I am expecting when I click on the funnel to enter a text or something to take place i.e filtering however no option so far?

 


@model ReportViewModel
@using Kendo.Mvc.UI

@{
    ViewBag.Title = "Report";
}


<link href="https://kendo.cdn.telerik.com/themes/6.4.0/default/default-ocean-blue.css" rel="stylesheet" type="text/css" />
<script src="https://kendo.cdn.telerik.com/2024.1.319/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2024.1.319/js/kendo.aspnetmvc.min.js"></script>

<style>

    /* Basic styling for grids */
    .k-grid {
        width: 100%;
        border-collapse: collapse;
    }

    /* Grid header styling */
    .k-grid-header {
        background-color: #f5f5f5;
        border-bottom: 1px solid #ddd;
    }

        /* Grid header cell styling */
        .k-grid-header th {
            padding: 8px;
            font-weight: bold;
            text-align: left;
        }

    /* Grid body styling */
    .k-grid tbody tr {
        border-bottom: 1px solid #ddd;
    }

    /* Grid body cell styling */
    .k-grid tbody td {
        padding: 8px;
    }

    /* Alternate row background color */
    .k-grid tbody tr:nth-child(even) {
        background-color: #f9f9f9;
    }

    /* Hover effect for rows */
    .k-grid tbody tr:hover {
        background-color: #f0f0f0;
    }
</style>

<h2>Employee and Location Report</h2>

<h3>Employees</h3>


@(Html.Kendo().Grid(Model.Employees)
    .Name("gridEmployees")
    .Columns(columns =>
    {
        columns.Bound(e => e.EmployeeId).Title("Employee ID");
        columns.Bound(e => e.FirstName).Title("First Name");
        columns.Bound(e => e.LastName).Title("Last Name");
        columns.Bound(e => e.Department).Title("Department");
        columns.Bound(e => e.Position).Title("Position");
        columns.Bound(e => e.Salary).Title("Salary").Format("{0:C}");
    })
    .Pageable()
    .Sortable()
    .Filterable() // Enable filtering
    )

<h3>Locations</h3>
@(Html.Kendo().Grid(Model.Locations)
        .Name("gridLocations")
        .Columns(columns =>
        {
            columns.Bound(l => l.LocationId).Title("Location ID");
            columns.Bound(l => l.City).Title("City");
            columns.Bound(l => l.Country).Title("Country");
            columns.Bound(l => l.Address).Title("Address");
        })
        .Pageable()
        .Sortable()
        .Filterable()
        )

Sinisa
Top achievements
Rank 1
 updated question on 23 Apr 2024
1 answer
14 views

My problem is that my MVC Grid was working up to Friday April 12, 2024, and now it's not. The Filter is causing my grid to error out. If I remove the Filter, my Grid works fine. If I use .Filterable(ftb => ftb.Mode(GridFilterMode.Row)), the Grid works fine.

What is causing my filtered grid not to work now? Below is my Grid:

@(Html.Kendo().Grid<AL.CC.DataContracts.DTO.Parts>()
.Name("PNGrid")
.Columns(columns =>
{
    columns.Bound(p => p.Id).Hidden();
    columns.Bound(p => p.pn).Width("150").Title("Part").Filterable(true);
    columns.Bound(p => p.name).Width("150").Title("Name").Filterable(true);
    columns.Bound(p => p.year).Width("150").Title("Year").Filterable(true);
})

.Selectable()
.Sortable(sortable => sortable.AllowUnsort(true).InitialDirection(System.ComponentModel.ListSortDirection.Descending).SortMode(GridSortMode.MultipleColumn))
.Scrollable(s => s.Enabled(true).Height("auto"))
.Resizable(resize => resize.Columns(true))
.AutoBind(true)
.HtmlAttributes(new { style = "width:100%; height:675px;" })
.Events(events => events.Change("Grid_OnRowSelect").DataBound("onDataBoundPN"))
.Filterable(filterable => filterable
    .Extra(false)
    .Operators(operators => operators
    .ForString(str => str.Clear()
    .Contains("Contains")
    ))
)
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("GetAll_Read", "Maintenance"))
    .ServerOperation(false)
    .AutoSync(true)
    .Model(model =>
    {
        model.Field(p => p.id).Editable(false);
        model.Field(p => p.name).Editable(false);
        model.Field(p => p.year).Editable(false);
        model.Field(p => p.pn).Editable(false);
    })
)
)

I'm also using the following scripts and css in the following order:

 

    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.20.0/jquery.validate.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/4.0.0/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/kendo/2023.3.1114/jszip.min.js"></script>
    <script src="~/Scripts/kendo/2023.3.1114/kendo.all.min.js"></script>
    <script src="https://cdn.kendostatic.com/2023.3.1114/js/kendo.aspnetmvc.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js" integrity="sha256-lSjKY0/srUM9BE3dPm+c4fBo1dky2v27Gdjm2uoZaL0=" crossorigin="anonymous"></script>
    <link href="https://kendo.cdn.telerik.com/themes/6.4.0/default/default-ocean-blue.css" rel="stylesheet" type="text/css" />
    <link href="https://kendo.cdn.telerik.com/themes/6.4.0/bootstrap/bootstrap-main.css" rel="stylesheet" type="text/css" />

 

Mihaela
Telerik team
 answered on 22 Apr 2024
0 answers
5 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
1 answer
17 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
12 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
1 answer
20 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
15 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
1 answer
16 views

I have a simple MVC Grid

with a column that looks like this

        columns.Bound(c => c.FirstName).Filterable(fi => fi.Cell(ce => ce.Operator("contains").SuggestionOperator(FilterType.Contains)));

the grid is just

        .Filterable()

Searching and GPT told me to do it this way, however when I filter that column I still only get the default filter of Equals

https://imgur.com/FewY7E0

Anton Mironov
Telerik team
 answered on 29 Mar 2024
1 answer
22 views

Hi

How do you enable tabbing on all elements in a Kendo Grid.   I have set  .Navigatable() - but doesn't seem to do anything.

I want the user to tab through the rows, including the page numbers  (items per page) and the filter boxes.

 

thx!@

Viktor Tachev
Telerik team
 answered on 22 Mar 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?