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

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
0 answers
6 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
I3next
Top achievements
Rank 1
 asked on 12 Apr 2024
1 answer
16 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
13 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
13 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
19 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
0 answers
22 views

Hello,

I'm encountering an issue with the autocomplete functionality in Kendo UI Grid. While the data selected through autocomplete is correctly added to hidden fields, it does not appear in the Grid.

Specifically, after using the autocomplete functionality, I checked whether the correct data was added to the respective hidden fields and found that the values I expected were indeed present in those fields. However, I noticed that these values were not visible in the Grid. This implies that the data selected by users is not being properly reflected within the Grid.

In summary, I am unable to display the data received through the autocomplete functionality within the Grid. I would appreciate any suggestions to resolve this issue.

The code structure related to the problem I mentioned above is as follows.

@(Html.Kendo().Grid(Model.Lines)
    .Name("OrderLines")
    .ToolBar(tools => tools.Create().Text("Add new product"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
    .Events(events => events
    .Change("onChange"))
    .Columns(columns =>
    {
        columns.Bound(p => p.Title)
        .ClientTemplate("#= Title #" +
        "<input type='hidden' name='Lines[#= index(data)#].Title' value='#= Title #' />")
        .EditorTemplateName("ProductTitleAutoComplete");

        columns.Bound(p => p.Title).Hidden().ClientTemplate("#= Title #" +
        "<input type='hidden' name='Lines[#= index(data)#].Title' value='#= Title #' />"
        );

        columns.Bound(p => p.Description).ClientTemplate("#= Description #" +
        "<input type='hidden' name='Lines[#= index(data)#].Description' value='#= Description #' />"
        );

        columns.Bound(p => p.Quantity).ClientTemplate("#= Quantity #" +
        "<input type='hidden' name='Lines[#= index(data)#].Quantity' value='#= Quantity #' />"
        );

        columns.Bound(p => p.UnitPrice).ClientTemplate("#= UnitPrice #" +
        "<input type='hidden' name='Lines[#= index(data)#].UnitPrice' value='#= UnitPrice #' />"
        );

        columns.Bound(p => p.TaxRate).ClientTemplate("#= TaxRate #" +
        "<input type='hidden' name='Lines[#= index(data)#].TaxRate' value='#= TaxRate #' />"
        );

        columns.Bound(p => p.DiscountRate).ClientTemplate("#= DiscountRate #" +
        "<input type='hidden' name='Lines[#= index(data)#].DiscountRate' value='#= DiscountRate #' />"
        );

        columns.Bound(p => p.PurchaseOrderId).Hidden().ClientTemplate("#= PurchaseOrderId #" +
        "<input type='hidden' name='Lines[#= index(data)#].PurchaseOrderId' value='#= PurchaseOrderId #' />"
        );

        columns.Bound(p => p.ProductId).Hidden().ClientTemplate("#= ProductId #" +
        "<input type='hidden' name='Lines[#= index(data)#].ProductId' value='#= ProductId #' />"
        );

        columns.Bound(p => p.Id).Hidden().ClientTemplate("#= Id #" +
        "<input type='hidden' name='Lines[#= index(data)#].Id' value='#= Id #' />"
        );

        columns.Bound(p => p.MeasureWeightId).ClientTemplate("#= MeasureWeightId #" +
        "<input type='hidden' name='Lines[#= index(data)#].MeasureWeightId' value='#= MeasureWeightId #' />"
        );

        columns.Command(command => command.Destroy()).Width(100);
    })
    .DataSource(dataSource => dataSource.Ajax()
    .Model(model =>
    {
        model.Id(p => p.ProductId);
        model.Field(p => p.ProductId).Editable(false);
    })
    .ServerOperation(false)
    ))

function onChange_ProductAutoComplete(e) {
    var dataItem = e.sender.dataItem(0);

    var grid = $("#OrderLines").data("kendoGrid");

    if (dataItem) {
        var el = $(e.sender.element[0]);
        const parent = el.closest("td");
        const inputs = parent.siblings().find('input');

        $(inputs).each(function () {
            var name = $(this).attr('name');
            if (name.endsWith("Description")) {
                $(this).val(dataItem.Notes);
            } else if (name.endsWith("ProductId")) {
                $(this).val(dataItem.Id);
            }
            else if (name.endsWith("Title")) {
                $(this).attr({ value: dataItem.Title });
                $(this).val(dataItem.Title);
            }
            else if (name.endsWith("MeasureWeightId")) {
                $(this).val(dataItem.MeasureWeightId);
            }
        });
    }
}

function onReadDataOnGrid_ProductAutoComplete(e) {
    let data = {
        title: $('#Title_ProductAutoComplete').val()
    };

    return data;
}

Thank you in advance for your support.

Selman
Top achievements
Rank 1
 asked on 18 Mar 2024
0 answers
18 views

I had a request to change the filtering of a certain column from "Starts With" to use a multi-select checkbox type filter to facilitate selecting 5-10 random items.  Then of course some other users prefer the "Starts With" type of filtering.  My solution is to have dual columns for that particular field, one with each filter type.  

Since my grids save user preferences in local storage between sessions, the users can hide whichever column has the filtering they don't prefer and just use the other one.  When they reload the page, their choice of column persists and their filtering is how they like it.

Darron

 

 

Darron
Top achievements
Rank 1
 asked on 18 Mar 2024
1 answer
26 views

Is it possible to extend the Telerik MVC Grid toolbar to include custom commands? I'm looking to add my own functionality to the toolbar, and I'm wondering if there's a way to create a method within the toolbar command factory to generate buttons with specific functionality that I want to apply across all grids in my application.

For example, I have these three methods I have added using the toolbar template.


instead of using the template every time I would like to add custom command like save or excel.

Anton Mironov
Telerik team
 answered on 11 Mar 2024
0 answers
17 views

I'm trying to export a grid to Excel, and I have followed the Telerik example:

https://demos.telerik.com/aspnet-mvc/grid/excel-export?autoRun=true&theme=default-main

But what I cannot manage to do is to prevent a call to excel_export_read when clicking the Export to Excel button. In Chrome Devtools I can see that also the official Telerik example calls this method a second time when clicking, but I was under the impression that the component would try to create the excel file client side. Is this not possible?

Here is my code:

 

@(Html.Kendo().Grid<CampaignSimulationResult>()
    .Name("SimulateResult")
    .ToolBar(tools => tools.Excel())
    .DefaultSettings()
    .Columns(column =>
        {
            column.Bound(m => m.Region).HeaderHtmlAttributes(new { style = "text-align:center" })
                .HtmlAttributes(new { style = "text-align: center" });
            column.Bound(m => m.ParameterID).Format("{0:##,#}").HtmlAttributes(new { style = "text-align: right" }).HeaderHtmlAttributes(new { style = "text-align:center" });
            column.Bound(m => m.Parameter).HtmlAttributes(new { style = "white-space: nowrap;" }).HeaderHtmlAttributes(new { style = "text-align:center" });
        }
    ).Excel(excel => excel
        .FileName("Kendo UI Grid Export.xlsx")
        .Filterable(true)
    )
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("ExcelExportRead", "Campaign", new RouteValueDictionary { { "area", "Admin" } }))
    )
)


Snorre Garmann
Top achievements
Rank 1
 asked on 05 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?