Telerik Forums
UI for ASP.NET Core Forum
2 answers
92 views

I cannot figure out how to override the overall container size of a Grid Editor. So I have the custom types in the ~/Shared folder and while they all show in edit mode they are many times to small in width.  Yet setting the style of the wrapper div the controls are in has no effect.  Is there a style I need to override in each view?

 

Thanks

Reid
Top achievements
Rank 2
 answered on 02 Apr 2018
1 answer
112 views

Hi,

 

I am planning to use tag helpers instead of this - 

 <select asp-for="Input.ReviewBank" asp-items="@(new SelectList(@Model.Banks,"BankBacisId","ReviewBankandCity"))" class="form-control" on></select>

but the documentation is available only for API or ajax call. Can you please point me towards achieving a filtered drop down from Model values on a Razor Page. 

Veselin Tsvetanov
Telerik team
 answered on 02 Apr 2018
1 answer
1.1K+ views

Hi,

I have 2 date pickers-

<div class=""><kendo-datepicker name="Input.ReviewStartDateTime" start="CalendarView.Month" depth="CalendarView.Year" format="yyyy/MM/dd" value="DateTime.Now" on-change="endChange"/> </div>

<div><kendo-datepicker name="Input.ReviewEndDateTime"  start="CalendarView.Month" depth="CalendarView.Year" format="yyyy/MM/dd" value="DateTime.Now" /></div>      

 

I am trying to change the value of Input.ReviewEndDateTime  picker to + 60 days  on change Input.ReviewStartDateTime picker -

        function endChange() {
            var startDatePicker = $("#Input.ReviewStartDateTime").data("kendoDatePicker"),
                startDate = this.value();
            console.log(startDate);
            if (startDate) {
                var endDate = new Date(startDate.getMonth() + 2);

                var endatepicker = $("#Input.ReviewEndDateTime").data("kendoDatePicker");
                endatepicker.value(startDate);
                endatepicker.trigger("change");
            }
        }

but I get the following error- 

Uncaught TypeError: Cannot read property 'value' of undefined

 

How can I change the date picker to 60 dates after theselected date from Input.ReviewStartDateTime

Stefan
Telerik team
 answered on 02 Apr 2018
2 answers
149 views

I am trying to create ChunkUploadController for Net Core 2 API Controller follow 

https://demos.telerik.com/aspnet-core/upload/chunkupload

but getting compilation error 

Error CS0144 Cannot create an instance of the abstract class or interface 'FileResult'

on the line 

FileResult fileBlob = new FileResult();

 

Could you guide me how to fix this error?

Thank you,

Vladimir

 

Dimitar
Telerik team
 answered on 30 Mar 2018
2 answers
1.5K+ views

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.

Tsvetina
Telerik team
 answered on 30 Mar 2018
1 answer
105 views

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));
        }
    }
Stefan
Telerik team
 answered on 30 Mar 2018
1 answer
161 views

Is there a way to size the toolbar?  I am using the MVC server side declaration.

 

Thanks

Ivan Danchev
Telerik team
 answered on 30 Mar 2018
1 answer
91 views

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

 

 

Viktor Tachev
Telerik team
 answered on 28 Mar 2018
4 answers
328 views

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)
    )
Dimitar
Telerik team
 answered on 27 Mar 2018
3 answers
178 views

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

Magdalena
Telerik team
 answered on 27 Mar 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?