Telerik Forums
UI for ASP.NET MVC Forum
1 answer
14 views

I am trying to preload deafult value that will always exist in this downdownlist no matter when. Then load in another list from the data base behind it base on other factors. See test code below.

 

 


@(Html.Kendo().DropDownList() .Name("groupTypeFilter") .HtmlAttributes(new { @class = "form-select", data_alpa = "filter", onchange = "ApplyFilter(this)" }) .OptionLabel("All") .DataTextField("Text") .DataValueField("Value") .BindTo(new List<SelectListItem> { new SelectListItem { Text = "All", Value = "all" }, new SelectListItem { Text = "All GMS Groups", Value = "allgms" }, new SelectListItem { Text = "All MECCOM Groups", Value = "allmeccom" } }) .DataSource(config => config.Read("GetGroupTypes", "Group")) )

 


 

public JsonResult GetGroupTypes() { var groupTypes = new List<SelectListItem> { new SelectListItem { Text = "All", Value = "ALL" }, new SelectListItem { Text = "GMS", Value = "GMS" }, new SelectListItem { Text = "MEC/COM", Value = "MEC/COM" } }; return Json(groupTypes); }

 

It seems to be only load the data from the data call and not the deafult data that I loaded into it



Eyup
Telerik team
 answered on 29 Sep 2025
1 answer
23 views

Problem:
After enabling Content Security Policy (CSP), Kendo DropDownLists inside a PanelBar fail to initialize. On page load:
• The DropDownList renders as a plain input box.
• PanelBar items appear empty, and data binding does not happen.
• JavaScript access to the DDL fails.

Scenario:
ASP.NET MVC Razor.
• Dropdown Lists inside PanelBar content templates.
• Worked fine before CSP; now initialization and binding fail.

 

Expected Behavior:
• DDL should initialize and bind data on content load even with CSP.
• PanelBar items should display properly.

 

Example:

@(
                     Html.Kendo().PanelBar()
                     .Name("panelbar")
                     .ExpandMode(PanelBarExpandMode.Multiple)
                     .Items(panelbar =>
                     {
                         panelbar.Add().Text("Note : Please fill all the input")
                         .Content(@<text>
        @(Html.Kendo().DropDownList()
                                            .Name("dropdown")
                                            .OptionLabel("Please Select")
                                            .OptionLabelTemplate("<span style='color:dimgrey;font-size:10px;font-weight:bold'>Please Select</span>")
                                            .DataValueField("id")
                                            .DataTextField("Text")
                                            .Template("#:id # - #:datacolumn # - #:datecolumn #")
.DataSource(source=>{source.Read(read=>{read.Action("action","controller");});})
.Events(e=>{e.Select("onselect");})
                                            )
   </text>
   );

 

Thanks,

Anupriya. R

Anton Mironov
Telerik team
 answered on 09 Sep 2025
1 answer
54 views

Hi,

I am using Web app with mvc. We are using Deferred Script File to remediate CSP (content security policy). 

For that reason instead of Client Template i am using Client Template Handler for one of the column which is a dropdownlist.

Whenever Grid is loaded with data, I can see the selected dropdown values in the grid but when i try to update the dropdown value

its opening as a text box and showing value as [object object].

 

  columns.Bound(p => p.Studendetails).ClientTemplateHandler("getname") 

function getname(data) {
     return data.Studendetails ? data.Studendetails.Name : '';
 }

 

Mihaela
Telerik team
 answered on 05 Aug 2025
0 answers
27 views

Good morning,
i am using MVC.ASP net in my project and i'm trying to send the DataSourceRequest to a service , via rabbitmq.

the message should contains all the request filters set in the ui in order to create an excel report. i have tried to use the System.Text.Json serialization but it's not working properly. it serializes only the first level props.
i have found a ".ToJson" extension  but it's returning a Dictionary<string, object>, not usefule here.

can you suggest how to serialize the DataSourceRequest in Json format? with all nested and recursive properties?

the filters can be about dates, strings, combobox, and so on

thanks in advance

1 answer
92 views

Hi,

We are using Kendo controls for MVC. There was a security scan done in our application, it capture few of the security issues.

We are able to fix all of the security issues except one.

CWE 829 - The application contains unsafe Content-Security-Policy (CSP) directives that could allow malicious script code to be included on the page.

So, as a result we have removed all the custom inline javascript and css to an external files and refer those external .js and .css files in our .cshtml page.

But when we use any of the Kendo controls like Kendo grid or Kendo calendar then in the runtime it create some inline scripts and we are getting application contains unsafe Content-Security-Policy (CSP) directives.

How to bypass those runtime inline scripts created by Kendo controls so that we don't get unsafe Content-Security-Policy (CSP) directives

during the security scan of the application.

Please let me know if you need any more information on this.

1 answer
121 views

I have a div  tag which has all three controls within the tag

1. TabStrip as the main container

2. Panel bar inside the tab

3.Dropdown inside the panel bar.

But the code is giving me the error - Inline markup blocks (@<p>Content</p>) cannot be nested.  Only one level of inline markup is allowed.

Can somebody help me to resolve  and  fix it.

Below is my code structure

        <div class="InputArea">
            @(Html.Kendo().TabStrip()
                    .Name("ScenaioNMDTabStrip")
                    .TabPosition(TabStripTabPosition.Top)
                    .Items(tabstrip =>
                    {
                     tabstrip.Add().Text("NMD")
                    .Selected(true)
                    .HtmlAttributes(new { style = "height: 55px;width: 20%;" })
                    .Content(@<text>
                    <div class="col-lg-11" style="float:left;">
                    </div>
                @(Html.Kendo().PanelBar()
                .Name("panelbar1")
                .HtmlAttributes(new { style = "width:200px;" })
                .Items(panelbar=>{
                panelbar.Add().Text("Scenario NMD")
                .Content(@<text>
                    @(Html.Kendo().DropDownList()
                    .Name("EmpyreanVersion")
                    .DataTextField("VersionId")
                    .DataValueField("VersionId")
                    .HtmlAttributes(new { style = "width: 150px;" })
                    )
                </text>);
                })
                
                )
            </text>);
              tabstrip.Add().Text("Empyrean");
                    })
                )
        </div>

Anton Mironov
Telerik team
 answered on 10 Mar 2025
1 answer
100 views

am using Kendo UI with Razor as the frontend and .NET Framework 4.8.1 as the backend.
I have the following code, but it does not initially display "Switzerland".
It is present in the list, but I do not want to select it manually.
I want it to be preselected from the start. Could you please help me?


@model int?

@{
    var initialItems = new List<SelectListItem>()
{
        new SelectListItem{ Text = "Schweiz", Value = "1" }
    };
}

<div class="k-floating-label-container mb-3">
    @(Html.Kendo().DropDownListFor(x => x)
        .DataTextField("Text")
        .DataValueField("Value")
        .AutoBind(false)
        .BindTo(initialItems)
        .Value(Model?.ToString())
        .Events(e => e.Open("onDropDownOpen"))
        .Deferred()
    )
    @Html.LabelFor(x => x, new { @class = "k-label k-input-label" })
    @Html.ValidationMessageFor(x => x)
</div>

<script>function onDropDownOpen(e) {
    var dropdown = $("#Store_DefaultLanguageId").data("kendoDropDownList");

    if (dropdown.dataSource.total() === 1) { 
        dropdown.setDataSource(new kendo.data.DataSource({
            transport: {
                read: {
                    url: "/Language/LanguageList",
                    dataType: "json",
                }
            },
            serverFiltering: true
        }));
    }
}
</script>

Anton Mironov
Telerik team
 answered on 07 Feb 2025
1 answer
100 views

I have a grid popup edit template that includes a Kendo dropdown.  I need to pass a model property value as the parameter to the Read() method of the dropdown.  But the model is null when the Read() method gets called.   So the value is always 0.  

I've defined the Field in the parent grid.  I even added it as a column too.  Model.ProductId is always 0.

How do I pass a value from the popup editor model to the controller for the dropdown?

                    @(Html.Kendo().DropDownList()
                        .Name("WarehouseId")
                        .OptionLabel("Select a warehouse...")
                        .HtmlAttributes(new { style = "width: 100%" })
                        .DataTextField("Text")
                        .DataValueField("Value")
                        .Value("-1")
                        .DataSource(source =>
                        {
                            source.Read(read =>
                            {
                                read.Action("Inventory_Warehouse_Read", "Purchasing", new { productId = @Model.ProductId});
                            });
                        })
                        .Height(400)
                        )

Mihaela
Telerik team
 answered on 29 Oct 2024
1 answer
213 views
Hello,

I am currently working with a Kendo Grid in my ASP.NET MVC application, specifically with a foreign key column that retrieves its data from a separate data source. I have enabled filtering on this grid, and I would like to implement a "contains" filter for a foreign key column, specifically for the "Locations" column.

Here’s the relevant portion of my Kendo Grid configuration:
            @(
                Html.Kendo().Grid<FMS_Cloud_CoreMVC.ViewModels.EnergyAdmin>()
                            .Name("EAData")
                            .Filterable()
                            .Columns(
                            
                            columns =>
                            {
                                columns.ForeignKey(p => p.CompLocID, ds => ds.Read("GetLocations", "EnergyAdmin"), "CompLocID", "CompLocString")
                                .Title("Locations").Width(300)
                                .Filterable(ftb => ftb.Cell(cell =>
                                    cell.Operator("contains").SuggestionOperator(FilterType.Contains)));





                    columns.ForeignKey( p => p.Provider, ds => ds.Read( "GetEnergyProviders", "EnergyAdmin"), "DDLID", "ProviderName")
                    .Title("Provider").Width(150) ;
                               
                    columns.Bound(p => p.NMI).Width(150);
                    columns.Bound(p => p.WWDeviceId).Width(150);
                   

                    columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(200);
                })
                .ToolBar(toolbar => toolbar.Create())
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Pageable()
                .Sortable()
                .Scrollable()
                .HtmlAttributes(new { style = "height:730px;" })
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Events(events => events.Error("error_handler"))
                .Model(model => model.Id(p => p.EnergyAdminId))
                .Create(update => update.Action("EditingInline_Create", "EnergyAdmin"))
                    .Read(read => read.Action("EditingInline_Read", "EnergyAdmin").Data("myCustomReadParam"))
                .Update(update => update.Action("EditingInline_Update", "EnergyAdmin"))
                .Destroy(update => update.Action("EditingInline_Destroy", "EnergyAdmin"))
                )
                )





While the "contains" filter works as expected with a simple text column, I would like to maintain the dropdown functionality for the foreign key column. Is there a way to achieve a "contains" filter on a foreign key column while still allowing users to select from the dropdown options?

I would greatly appreciate any guidance or examples you can provide.

Thank you in advance for your assistance!
Eyup
Telerik team
 answered on 14 Oct 2024
0 answers
96 views

After upgrading Kendo MVC from v2021.2.616 to v2024.2.514 (KendoUIProfessional), the dropdownlist "SeriesType" on the grid is not firing the onChange event anymore. I saw an error message in the browser console.

Can you guys suggest a migration solution for it? Thanks!

Browser console error:

cshtml

@(Html.Kendo().Grid<MySeriesModel>().Name("drpSeries")
              .Columns(column =>
              {
                  column.Bound(model => model.SeriesName).HtmlAttributes(new { style = "font-weight: bold" }).Title("No.").Width(40);
                  column.ForeignKey(c => c.SeriesType, (IEnumerable<SelectListItem>)ViewBag.LstSeriesType, "value", "text").HtmlAttributes(new { style = "text-align: left", onChange = "onChangeSeriesType('#=ID#'); setSerieXml();" }).Title("Series Type").MinScreenWidth(60);
                  column.Bound(model => model.SeriesTitle).Title("Series Title").HtmlAttributes(new { onChange = "setSerieXml();" }).MinScreenWidth(120).Encoded(false);
                  column.Bound(model => model.Axis).Title("Axis").ClientTemplate("#=getAxisActionLink(ID,Axis)#").MinScreenWidth(120);                  
                  column.ForeignKey(c => c.Y_Format, (IEnumerable<SelectListItem>)ViewBag.LstSeriesFormat, "value", "text").HtmlAttributes(new { style = "text-align: left", onChange = "onChangeFormat(this);" }).Title("Format").MinScreenWidth(150);
                  column.ForeignKey(c => c.Y_Axis, (IEnumerable<SelectListItem>)ViewBag.ListSerriesYAxis, "value", "text").HtmlAttributes(new { style = "text-align: left", onChange = "onChangeYAxis(this,'#=ID#');" }).Title("Y Axis Scale").Width(100);
                  column.Bound(x => x.ID).ClientTemplate("<button class= 'k-button' type='button' onclick=onRemoveSeries('#=ID#')>" + "Remove" + "</button>").HtmlAttributes(new { style = "text-align: center" }).Title("").Width(120);
              })
              .DataSource(dataSource => dataSource
                    .Ajax()
                    .ServerOperation(false)
                    .Model(model =>
                    {
                        model.Id(item => item.ID);
                        model.Field(item => item.ID).Editable(false);
                        model.Field(item => item.SeriesName).Editable(false);
                        model.Field(item => item.Axis).Editable(false);
                        model.Field(item => item.SeriesTitle).Editable(false);
                    })
                    .Read(read => read.Action("SeriesList_DataSource", "Dashboard").Data("getDataForDgdSeries_Read"))
               )
               .Events(e =>
               {
                   e.DataBound("onDataBoundDgdSeries");
               })
               .Resizable(x => x.Columns(true))
               .AutoBind(true)
               .Scrollable(x => x.Enabled(true))
               .Editable(editable => editable.Mode(GridEditMode.InCell))
               .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
               .HtmlAttributes(new { style = "overflow: auto; width:100%", @class = "form-group" })

)

JS

function onChangeSeriesType(id) {
    drpSeries = $('#drpSeries').data('kendoGrid');
    dataSource = drpSeries.dataSource;
    var lstSerieRow = dataSource.data();
    if (lstSerieRow[id - 1].Axis.length > 0) {
        lstSerieRow[id - 1].SeriesTitle = "";
        lstSerieRow[id - 1].Axis = "";
        dataSource.fetch();
    }
}

Model

public class MySeriesModel
{
    public string ID { get; set; }

    public string SeriesName { get; set; }
    public string AxisName { get; set; }
    public string Axis { get; set; }
    [AllowHtml]
    [UIHint("GridDropDownList")]
    public string SeriesType { get; set; }

    public string SeriesTitle { get; set; }

    public string X_Ordinate { get; set; }

    public string X_Format { get; set; }

    [AllowHtml]
    [UIHint("GridDropDownList")]
    public string Y_Format { get; set; }

    [AllowHtml]
    [UIHint("GridDropDownList")]
    public string Y_Ordinate { get; set; }
    [AllowHtml]
    [UIHint("GridDropDownList")]
    public string Y_OrdinateTo { get; set; }
    public string TOOLTIP_FORMAT { get; set; }

    [AllowHtml]
    [UIHint("GridDropDownList")]
    public string Y_Axis { get; set; }
}

controller


public ActionResult RenderSeriesConfig(string viewName)
{
    List<SelectListItem> seriesType = GetDashboadChartStyleTypeList();
    string arrSeriesType = "";
    for (int i = 0; i < seriesType.Count; i++)
    {
        arrSeriesType += seriesType[i].Text.ToString() + "," + seriesType[i].Value.ToString() + ";";
    }
    ViewBag.LstSeriesType = seriesType;
    ViewBag.ArrSeriesType = arrSeriesType;
    ViewBag.LstSeriesAxis_Ordinate = GetLstFieldNamesSelectListItem(viewName);
    ViewBag.LstSeriesFormat = GetFormatShortList();
    ViewBag.ListSerriesYAxis = GetYAxisSettingList();
    return PartialView("_ChartDetail_Series");
}

 

Ronan
Top achievements
Rank 1
 asked on 07 Aug 2024
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?