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");
}