Hi,
I am working with Kendo UI grid in ASP .NET MVC using an EditorTemplate with ComboBoxFor inside the grid.
Issue description
Sample code
@model Department
@(Html.Kendo()
.ComboBoxFor(m=>m)
.DataValueField("departmentId")
.DataTextField("departmentName")
.DataSource(ds=>ds.Read(read=>read.Action("GetDepartments", "Home")))
)

public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
// Check if any sorts have been applied.if (request.Sorts != null)
{
// Loop through each sort.foreach (var sort in request.Sorts)
{
// Check if the Category column is being sortedif (sort.Member == "Category")
{
// Sort by the CategoryName instead of the Object.
sort.Member = "Category.CategoryName";
}
}
}
}
My grid column coincidentally also has to do with categories. I tried adding the above code to my read method and it doesn't work. When I click on the header to sort the column it doesn't automatically initiate a read call so I'm not sure how this could work. I guess I'm missing something.
My grid definition:
@(
Html.Kendo().Grid<LookupItem>()
.Name("LookupList")
.Columns(columns =>
{
columns.Bound(m => m.Id).Hidden(true);
columns.Bound(m => m.CategoryListItem).ClientTemplate("#: CategoryListItem.CategoryName #").EditorTemplateName("LookupCategoryDropDown").Width("25%"); ;
columns.Bound(m => m.Name).Width("25%");
columns.Bound(m => m.Value).Width("15%");
columns.Bound(m => m.AlternativeValue).Width("15%");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => { toolbar.Create().Text("Add New Lookup Item"); })
.Editable(editable => editable.Mode(GridEditMode.InLine).DisplayDeleteConfirmation("Are you sure you want to delete this item?"))
.Sortable()
.Scrollable()
.Filterable(filterable => filterable.Extra(false))
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(50)
.ServerOperation(false)
.Model(model =>
{
model.Id(m => m.Id);
model.Field(m => m.Category);
model.Field(m => m.Name);
model.Field(m => m.Value);
model.Field(m => m.AlternativeValue);
})
.Read(read => read.Action("Lookup_Read", "Lookup"))
.Create(create => create.Action("Lookup_Create", "Lookup"))
.Update(update => update.Action("Lookup_Update", "Lookup"))
.Destroy(read => read.Action("Lookup_Delete", "Lookup"))
)
My Controller Read Method:
public async Task<IActionResult> Lookup_Read([DataSourceRequest] DataSourceRequest request)
{
if (request.Sorts != null)
{
// Loop through each sort.
foreach (var sort in request.Sorts)
{
// Check if the Category column is being sorted
if (sort.Member == "CategoryListItem")
{
// Sort by the CategoryName instead of the Object.
sort.Member = "CategoryListItem.CategoryName";
}
}
}
var model = await _service.GetAllLookupTypesAsync();
var result = model.ToDataSourceResult(request);
return Json(result);
}

Hi,
We have a requirement, where we have a kendo grid, from the grid columns we need one or multiple columns as a dropdown/combobox.
Along with the above requirement we have the below requirements.
1. Grid column with Dropdown/Combobox should work when paste in grid
2. Export also should work with dropdown/combobox columns.
To add new rows in the grid, we have to copy the rows from excel and paste in the grid, so after the paste all the new records should appear even in the dropdown/combobox field. The export is a client side export.
And for the grid we have a button for exporting the grid data in excel. If for specific column which will be dropdown/combobox which will be of complex type then after export how that column will display in the excel.
Note: We have already tried with dropdownlist in the grid. We created a UI component and user that inside EditorTemplateComponentName
in the cshtml file. We are able to render the dropdown for that particular column inside the grid. But the problem is with dropdownlist column when we try to copy and paste records from excel to grid, paste is not working for dropdown column.
And also the dropdown column is a complex type so when we export the grid, the dropdown column value is not render in the excel file.
So, we are thinking to achieve the above requirements with a combo box, please provide the solution for the above requirements.

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

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:
@(
Thanks,
Anupriya. R

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 : '';
}

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
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.
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">
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>
