Hi,
I have a razor page which is showing a grid, where the on-change is bound to a javascript function that loads a partial view using $.ajax into an element on the same page.
That partial view is using kendo htmlhelpers to construct certain elements.
Since these elements are initialized using kendo.syncReady(), those initialization functions are (obviously) put into the global scope.
This leads to a problem due to those initialization functions never get cleaned up as I can see while debugging in VS 2017.
There is a script block section in which those methods keep adding up each time i select another row which loads the related partial view.
any ideas how to prevent this or how to clean this up ?
Thanks in advance.
Is there a way to send back the number of rows affected on an updated with inline batch editing so that I can inform the users how many rows they have successfully updated? I haven't been able to find anything on the web for the Kendo Grid that would help me out. My cshtml file is
@{ ViewData["Title"] = "Index";}@Html.AntiForgeryToken()<h2>Index</h2>@(Html.Kendo().Grid<FacilityDataManager.ViewModels.FDMError> () .Name("grid") .Columns(columns => { columns.Bound(c => c.ID).Hidden(true);//.Hidden(true); columns.Bound(c => c.ScadaDailyID).Hidden(true); columns.Bound(c => c.station_asset_id).Filterable(ftb => ftb.Multi(true).CheckAll(true)).Title("Station Asset ID").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal;font-weight:700;" }); columns.Bound(c => c.station_id).Filterable(ftb => ftb.Multi(true).CheckAll(true)).Title("Station ID").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal;" }); columns.Bound(c => c.error_type).Filterable(ftb => ftb.Multi(true).CheckAll(true)).Title("Error Type").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.reading_date).Format("{0:MM/dd/yyyy}").Filterable(ftb => ftb.Multi(true).CheckAll(true)).Title("Reading Date").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); //change the column below to a checkbox //columns.Bound(c => c.errorCorrected).ClientTemplate("<input type='checkbox' disabled='true' value='#= errorCorrected #' " + " # if (errorCorrected) { #" + "checked='checked'" + "# } #" + "/>" ); columns.Bound(c=> c.operating_hrs).Title("Operating Hours").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.ttl_downtime_hrs).Title("Downtime Hours").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.hrsepwr_hrs).Title("Horsepower Hours").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.fuel_consumed).Title("Fuel Consumed").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.engine_starts_attempts).Title("Engine Start Attempts").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.engine_starts_failed).Title("Engine Start Failures").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.engine_starts_success).Title("Engine Start Successes").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.startup_duration).Title("Startup Duration").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.thruput_mmcf).Title("Throughput MMCF").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.avg_unit_rpm).Title("Average Unit RPM").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.oil_to_comp_cyl).Title("Oil Usage (Compressor)").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.oil_to_pwr_cyl).Title("Oil Usage (Engine)").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.oil_new_cc_hand).Title("Oil Usage (Manual)").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); columns.Bound(c => c.blowdown_cnt).Title("Blowdown Count").HeaderHtmlAttributes(new { style = "overflow: visible; white-space: normal" }); }) .ToolBar(toolbar => { toolbar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Sortable() .Filterable() .Pageable() .Scrollable(scrollable => scrollable.Height(700)) .Reorderable(reorderable => reorderable.Columns(true)) .Resizable(resizable => resizable.Columns(true)) .ColumnResizeHandleWidth(20) .ColumnMenu() .Navigatable() .DataSource(dataSource => dataSource .Ajax() .Batch(true) .PageSize(20) .ServerOperation(false) .Events(events => events .Error("error_handler") .RequestEnd("refreshGrid") ) //set the fields to non-editable here .Model(model => { model.Id(p => p.ID); model.Field(p => p.ID).Editable(false); model.Field(p => p.station_id).Editable(false); model.Field(p => p.reading_date).Editable(false); model.Field(p => p.error_type).Editable(false); model.Field(p => p.station_asset_id).Editable(false); model.Field(p => p.ScadaDailyID).Editable(false); }) .Read(read => read.Action("Cleanup_Read", "DataCorrection").Data("sendAntiForgery")) .Update(update => update.Action("Cleanup_Update", "DataCorrection").Data("sendAntiForgery")) ))<script type="text/javascript"> function error_handler(e) { if (e.errors) { var message = "Errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += this + "\n"; }); } }); alert(message); } } function sendAntiForgery() { return { "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val() } } function refreshGrid(e) { if (e.type == 'update') { e.sender.read(); } }</script><style> .k-grid { font-size: 9px; width:2000px; } .k-grid td { line-height: 2em; } .k-readonly { color:darkgray; } .k-grid-header { font-weight:700; } .k-grid-header .center-header { text-align: center; } .k-grid-header .wrap-header { height: auto; overflow: visible; white-space: normal; }</style>
And my action controller (using Dapper) is shown below (curiously when I check Affected rows shows -1, so not sure why that happens)
[HttpPost] [ValidateAntiForgeryToken] public IActionResult Cleanup_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<FDMError> errors) { if (errors != null && ModelState.IsValid) { var connectionString = _ConnectionString.Value.ConnectionString; string subject = Regex.Replace(User.Identity.Name, ".*\\\\(.*)", "$1", RegexOptions.None); //subject = "Roberts_C"; int affectedRows = 0; foreach (var correction in errors) { //Run your stored procedure here to do a couple of things //insert into the Scada Daily Table //Update the flag on the ScadaErrors table where the ID = to the ID here int scadaErrorID = correction.ID; string stationAssetID = correction.station_asset_id; string stationID = correction.station_id; string errorType = correction.error_type; DateTime readingDate = correction.reading_date; double operatingHours = correction.operating_hrs; double totalDowntimeHours = correction.ttl_downtime_hrs; int horsepowerHours = correction.hrsepwr_hrs; double fuelConsumed = correction.fuel_consumed; int engineStartAttempts = correction.engine_starts_attempts; int engineStartFailed = correction.engine_starts_failed; int engineStartSuccess = correction.engine_starts_success; double startupDuration = correction.startup_duration; double throughputMMCF = correction.thruput_mmcf; int averageUnitRPM = correction.avg_unit_rpm; double oilUsageCompressor = correction.oil_to_comp_cyl; double oilUsageManual = correction.oil_new_cc_hand; //bool errorCorrected = correction.errorCorrected; int blowdownCount = correction.blowdown_cnt; int scadaDailyID = correction.ScadaDailyID; DynamicParameters p = new DynamicParameters(); p.Add("@ScadaErrorID", correction.ID, dbType: DbType.Int32, direction: ParameterDirection.Input); p.Add("@stationAssetID", correction.station_asset_id, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@stationID", correction.station_id, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@errorType", errorType, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@readingDate", readingDate, dbType: DbType.DateTime, direction: ParameterDirection.Input); p.Add("@operatingHours", operatingHours, dbType: DbType.Double, direction: ParameterDirection.Input); p.Add("@totalDowntimeHours", totalDowntimeHours, dbType: DbType.Double, direction: ParameterDirection.Input); p.Add("@horsepowerHours", horsepowerHours, dbType: DbType.Int32, direction: ParameterDirection.Input); p.Add("@fuelConsumed", fuelConsumed, dbType: DbType.Double, direction: ParameterDirection.Input); p.Add("@engineStartAttempts", engineStartAttempts, dbType: DbType.Int32, direction: ParameterDirection.Input); p.Add("@engineStartFailed", engineStartFailed, dbType: DbType.Int32, direction: ParameterDirection.Input); p.Add("@engineStartSuccess", engineStartSuccess, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@startupDuration", startupDuration, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@throughputMMCF", throughputMMCF, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@averageUnitRPM", averageUnitRPM, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@oilUsageCompressor", oilUsageCompressor, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@oilUsageManual", oilUsageManual, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@blowDownCount", blowdownCount, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@scadaDailyID", scadaDailyID, dbType: DbType.String, direction: ParameterDirection.Input); p.Add("@userID", subject, dbType: DbType.String, direction: ParameterDirection.Input); using (var con = new SqlConnection(connectionString)) { string storedProcName = "scada.usp_UpdateDailyTableByID"; con.Open(); affectedRows += con.Execute(storedProcName, p, commandType: System.Data.CommandType.StoredProcedure); }
} } return Json(errors.ToDataSourceResult(request, ModelState)); } }
Is there a way to size the toolbar? I am using the MVC server side declaration.
Thanks

HI,
The filtering options show for each column, but when "Filter" is clicked nothing changes in the grid.
@(Html.Kendo().Grid<FlRazor2.Models.Header>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.id).Title("Case ID");
columns.Bound(p => p.individual.firstName).ClientTemplate("#=individual? individual.firstName:''#").Title("First Name");
columns.Bound(p => p.individual.lastName).ClientTemplate("#=individual? individual.lastName:''#").Title("Last Name");
//columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
})
.ToolBar(tools =>
{
//tools.Create();
})
.Sortable()
.Pageable()
//.Filterable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
.IsEqualTo("Exactly matches")
.StartsWith("Starts with"))))
.DataSource(dataSource =>
dataSource
.WebApi()
.Model(model =>
{
model.Id(p => p.id);
})
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Get", "Home"))
//.Create(create => create.Action("Post", "Product"))
//.Update(update => update.Action("Put", "Product", new { id = "{0}" }))
//.Destroy(destroy => destroy.Action("DELETE", "Product", new { id = "{0}" }))
)
)
from controller:
[HttpGet]
public DataSourceResult Get([DataSourceRequest]DataSourceRequest request, string t)
{
string userName = User.Identity.Name;
int indexOfSlash = userName.IndexOf("\\");
userName = userName.Substring(indexOfSlash + 1).ToLower();
//DataSourceResult test = service.Read().ToDataSourceResult(request);
//return service.Read().ToDataSourceResult(request);
IEnumerable<Header> headers = _service.Read();
DataSourceResult result = new DataSourceResult();
result.Data = headers;
result.Total = headers.Count();
return result;
}

Hello,
I've got some problems with add template to PanelBar. I've just tried simple code bellow ... but it doesn't work (and no error raised)
Could you help me?
@{ List<PanelBarItemModel> panelBarList = new List<PanelBarItemModel>(); panelBarList.Add(new PanelBarItemModel() { Id = "1", Text = "val1" }); panelBarList.Add(new PanelBarItemModel() { Id = "2", Text = "val2" }); } <script id="panelbar-template" type="text/kendo-ui-template"> #: item.Id # - #: item.text # </script> @(Html.Kendo().PanelBar() .Name("TestPanelBar") .TemplateId("panelbar-template") .ExpandMode(PanelBarExpandMode.Multiple) .BindTo(panelBarList) )Hello,
I have a toolbar with a Split Button and many entries which are not all visible because the height of the screen is not big enough...
How to have a scrolling of the splitbutton dropdown list if the screen is to small i.e. there a more items to display depeneding on the screen size (I don't want to have a fix height)
see attached picture
Hi,
My grid is configured as follows:
@(Html.Kendo().Grid<GRL.DomainViewModel.ViewModel>()
.Name("tblView")
.Columns(columns =>
{
columns.Bound(p => p.Selected).Width(50).Title(" ").ClientTemplate("<input id='recApprovalsSelected' style = 'width: 30px' type='checkbox' #= Selected ? checked='checked' :'' #' onclick='recApprovalViewRowCheck(this)' />");
....
columns.Command(command => command.Custom("approverViewCoversheet").Text("Coversheet").Click("recApprovalsViewCoversheetClick")).Width(100).Title(" ");
columns.Command(command => command.Custom("approverViewReconcilerComment").Text("Comment").Click("recApprovalsViewCommentClick")).Width(100).Title(" ");
})
.Scrollable(s => s.Height(550))
.Pageable(pageable => pageable.Refresh(true)
.Input(true)
.PageSizes(new int[] { 100, 250, 500, 1000 }))
.Sortable()
.NoRecords()
.AutoBind(false)
.Reorderable(r => r.Columns(true))
.Resizable(resize => resize.Columns(true))
.Filterable()
.Groupable(true)
.ClientDetailTemplateId("approverViewPackageDetails")
.DataSource(dataSource => dataSource
.WebApi()
.Batch(true)
.Model(model =>
{
model.Id(p => p.PkgName);
})
.PageSize(100)
.ServerOperation(false)
.Read(read => read.Action("View", "Manager").Data("ViewParameters"))
)
)
<script id="approverViewPackageDetails" type="text/kendo-tmpl">
<h4>Details for Package \\##=PkgName# </h4>
@(Html.Kendo().Grid<GRL.DomainViewModel.GLComboViewModel>()
.Name("grid_#=PkgId#")
.Columns(columns =>
{
columns.Bound(p => p.Account).Title("Account").Width(75);
.....
columns.Bound(p => p.TransCur).Title("Trans.Cur").Width(80);
columns.Bound(p => p.TransAmount).Title("Trans.Amount").Width(100);
columns.Bound(p => p.RecAmount).Title("Rec.Amount").Width(100);
})
.Pageable()
.Sortable()
.NoRecords()
.Reorderable(r => r.Columns(true))
.Resizable(resize => resize.Columns(true))
.Filterable()
.DataSource(dataSource => dataSource
.WebApi()
.Model(model =>
{
model.Id(p => p.RecPackageId);
})
.PageSize(15)
.Read(read => read.Action("RecPackageCombo", "RecPackageManager", new
{
PkgId = "#=PkgId#",
pkgVer = "#=PkgVersion#"
}))
)
.ToClientTemplate()
)
For my Child Grid, if TransAmount is not equal to RecAmount, i need the row be highlighted in different color.
I tried using the ClientRowTemplate on child grid also tried adding ClientTemplate on the Child grid columns, but it did not work.
Thanks,

How to set DataTextField of ListBox dynamically
I have a listbox control as
@(Html.Kendo().ListBox()
.Name("ListboxCompany")
.Selectable(ListBoxSelectable.Single)
.DataTextField("name")
.DataValueField("Id")
)
.BindTo(Model)
)
and
created a radiobuttongroup. So how I can change DataTextField with the value checked from radiobuttongroup
Is there any plans to port the File Explorer control in the asp ajax suite to Asp.Net Core?
Thanks,
Richard