Telerik Forums
UI for ASP.NET Core Forum
1 answer
119 views

i have added kendo grid in my asp.net core 2 project ..

i have a checkbox column in it which is bound to IsVisible field

when i click edit or create button , i get a validation error which is 'The IsVisible field is required.'

 

i think there is a bug with the grid validation , because a checkbox always has a selected value (checked or not checked)

you can see the issue by adding or editing a row in telerik inline editing sample : https://demos.telerik.com/aspnet-core/grid/editing-inline

 

Viktor Tachev
Telerik team
 answered on 12 Mar 2018
4 answers
1.7K+ views

I'm trying to use Kendo grid with tag helpers, documentation you have right now is pretty much useless for my problems. I have a really simple Kendo grid, and I'm trying to create functions for create, edit, and delete buttons. 

1. openCreateWindowopenEditWindow and openDeleteWindow - How to pass an Id (in my example LanguageId)?

2. openCreateWindow - Click event doesn't work at all inside toolbar (toolbar-button), what to do?

With these functions I will call server side actions to create separate popup editors with different fields and terms using Kendo Window and Ajax forms, and I have pretty much strong reasons why I need something like this.

 

...
              <columns>
                    <column field="LanguageId" width="240" hidden="true"/>
                    <column field="Name"/>
                    <column field="Culture"/>
                    <column width="100">
                        <commands>
                            <column-command name="edit" text="Edit" click="openEditWindow(LanguageId?)"></column-command>
                        </commands>
                    </column>
                    <column width="100">
                        <commands>
                            <column-command name="delete" text="Delete" click="openDeleteWindow(LanguageId?)"></column-command>
                        </commands>
                    </column>
                </columns>
                <toolbar>
                    <toolbar-button name="custom" text="Add new record" click="openCreateWindow(LanguageId?)"></toolbar-button>
                </toolbar>

...

I'm looking forward to hearing from you.

Kind regards,
Asmir M.

Viktor Tachev
Telerik team
 answered on 09 Mar 2018
4 answers
616 views

Hi,

I have followed the steps from https://docs.telerik.com/devtools/aspnet-ajax/installation/installing-the-telerik-controls-from-nuget-package

to include Telerik's nuget package source to VS2017 but at the final step there is no package "Telerik.UI.for.AspNet.Core

 

!Capture.PNG!

Robert
Top achievements
Rank 1
 answered on 08 Mar 2018
1 answer
415 views
The ListView page at https://www.telerik.com/aspnet-core-ui/listview seems to indicate that there is drag and drop support, but the demo that it links to does not show this. Has anyone tried implementing drag and drop on a UI for ASP.NET Core ListView?
Viktor Tachev
Telerik team
 answered on 07 Mar 2018
6 answers
481 views

I"m sure you guys are working on this but would it help everyone if we started to add to the demos to show aspects of using these tools against Core Razor Pages?

I'm just conscious of not wanting to post too many questions when i can't find demos i'm interested in.

 

Cheers,

John

 

Bozhidar
Telerik team
 answered on 07 Mar 2018
2 answers
231 views

I am binding the data from a datatable but it is always binding the data against the current date.If i have set the selected date is something else also.

 

 

Code

using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    { 
        if(!Page.IsPostBack)
        {
            dtpDate.SelectedDate = DateTime.Today.AddDays(0);
        //    OTTable();
        }
     
        //RadScheduler1.SelectedDate = (DateTime.Today.AddDays(2));
    }
    private void OTTable()
    {
        RadScheduler1.DataSource = null;
        RadScheduler1.DataBind();
        // Create a new Data Table.
        System.Data.DataTable OTTheater = new DataTable("OTTheater");
        DataColumn dtColumn;
        DataRow myDataRow;
        // Create id Column
        dtColumn = new DataColumn();
        dtColumn.DataType = System.Type.GetType("System.Int32");
        dtColumn.ColumnName = "TheaterId";
        dtColumn.Caption = "TheaterId";
        dtColumn.ReadOnly = false;
        dtColumn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTTheater.Columns.Add(dtColumn);

        // create Name column.
        dtColumn = new DataColumn();
        dtColumn.DataType = System.Type.GetType("System.String");
        dtColumn.ColumnName = "TheatreName";
        dtColumn.Caption = "TheatreName";
        dtColumn.AutoIncrement = false;
        dtColumn.ReadOnly = false;
        dtColumn.Unique = false;

        // Add Address column to the table.
        OTTheater.Columns.Add(dtColumn);

        
        
        // Add rows to the custTable using NewRow method
        // I add three customers with their addresses, name and id
        myDataRow = OTTheater.NewRow();
        myDataRow["TheaterId"] = 1;
        myDataRow["TheatreName"] = "OT1";
        
        OTTheater.Rows.Add(myDataRow);

        myDataRow = OTTheater.NewRow();
        myDataRow["TheaterId"] = 2;
        myDataRow["TheatreName"] = "OT2";
        
        OTTheater.Rows.Add(myDataRow);


        System.Data.DataTable OTPatientDetail = new DataTable("OTPatientDetail");
        DataColumn dtOTPatientDetailn;
        DataRow myDataRowOTPatientDetail;
        // Create id Column
        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.Int32");
        dtOTPatientDetailn.ColumnName = "TheaterId";
        dtOTPatientDetailn.Caption = "TheaterId";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);

        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.String");
        dtOTPatientDetailn.ColumnName = "TheatreName";
        dtOTPatientDetailn.Caption = "TheatreName";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);


        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.String");
        dtOTPatientDetailn.ColumnName = "FromTime";
        dtOTPatientDetailn.Caption = "FromTime";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);

        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.String");
        dtOTPatientDetailn.ColumnName = "ToTime";
        dtOTPatientDetailn.Caption = "ToTime";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);

        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.String");
        dtOTPatientDetailn.ColumnName = "Subject";
        dtOTPatientDetailn.Caption = "Subject";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);

        dtOTPatientDetailn = new DataColumn();
        dtOTPatientDetailn.DataType = System.Type.GetType("System.String");
        dtOTPatientDetailn.ColumnName = "TooTipText";
        dtOTPatientDetailn.Caption = "TooTipText";
        dtOTPatientDetailn.ReadOnly = false;
        //dtOTPatientDetailn.Unique = true;
        // Add id column to the DataColumnCollection.
        OTPatientDetail.Columns.Add(dtOTPatientDetailn);


       


        //TheaterId, TheaterName, FromTime, ToTime, Subject, TooTipText

        myDataRowOTPatientDetail = OTPatientDetail.NewRow();
        myDataRowOTPatientDetail["TheaterId"] = 1;
        myDataRowOTPatientDetail["TheatreName"] = "OT1";
        myDataRowOTPatientDetail["FromTime"] = "10:00";
        myDataRowOTPatientDetail["ToTime"] = "11:00";
        myDataRowOTPatientDetail["Subject"] = "Test Patient";
        myDataRowOTPatientDetail["TooTipText"] = "Test Patient";
     
        OTPatientDetail.Rows.Add(myDataRowOTPatientDetail);

        myDataRowOTPatientDetail = OTPatientDetail.NewRow();
        myDataRowOTPatientDetail["TheaterId"] = 2;
        myDataRowOTPatientDetail["TheatreName"] = "OT2";
        myDataRowOTPatientDetail["FromTime"] = "09:00";
        myDataRowOTPatientDetail["ToTime"] = "11:00";
        myDataRowOTPatientDetail["Subject"] = "Test Patient";
        myDataRowOTPatientDetail["TooTipText"] = "Test Patient";
        
        OTPatientDetail.Rows.Add(myDataRowOTPatientDetail);





 
        DataTable Dt = new DataTable();

   
        RadScheduler1.SelectedView = SchedulerViewType.DayView;
        RadScheduler1.SelectedDate = dtpDate.SelectedDate.Value;
        RadScheduler1.WorkDayStartTime = TimeSpan.Parse("06:00");
        RadScheduler1.WorkDayEndTime = TimeSpan.Parse("00:00");

        RadScheduler1.DayStartTime = TimeSpan.Parse("08:00");
        RadScheduler1.DayEndTime = TimeSpan.Parse("00:00");
       
        RadScheduler1.MinutesPerRow = int.Parse("10");
        //RadScheduler1.TimeLabelRowSpan = 30 / int.Parse(OTPatientDetail.Rows[0]["ToTime"].ToString());
      
        RadScheduler1.DataKeyField = "TheaterId";
        RadScheduler1.DataStartField = "FromTime";
        RadScheduler1.DataEndField = "ToTime";
        RadScheduler1.DataSubjectField = "Subject";

        //RadScheduler1.GroupBy = "Resource";
        //RadScheduler1.DataRecurrenceField = "RecurrenceRule";
        //RadScheduler1.DataRecurrenceParentKeyField = "RecurrenceParentId";
        RadScheduler1.ResourceTypes.Clear();
        ResourceType rt = new ResourceType("Resource");
        rt.DataSource = OTTheater;
        rt.KeyField = "TheaterId";
        rt.ForeignKeyField = "TheaterId";
        rt.TextField = "TheatreName";
        RadScheduler1.ResourceTypes.Add(rt);
       
        RadScheduler1.DataSource = OTPatientDetail;
        RadScheduler1.DataBind();
        
    }


    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
        e.Appointment.ToolTip = e.Appointment.Attributes["TooTipText"];
    }

    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        WebControl rsAptInner = (WebControl)e.Container.Parent;
        rsAptInner.Style["background"] = "#4286f4";
    }

    protected void RadScheduler1_TimeSlotContextMenuItemClicked(object sender, TimeSlotContextMenuItemClickedEventArgs e)
    {

    }

    protected void RadScheduler1_AppointmentContextMenuItemClicked(object sender, AppointmentContextMenuItemClickedEventArgs e)
    {

    }

    protected void RadScheduler1_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e)
    {

    }

    protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {

    }

    protected void as_Click(object sender, EventArgs e)
    {
       
        OTTable();
    }
    protected void OnSelectedDateChanged_dtpDate(object sender, EventArgs e)
    {
        try
        {

            as_Click(sender, e);
        }
        catch (Exception Ex)
        {
           
        }
    }
}

Peter Milchev
Telerik team
 answered on 05 Mar 2018
1 answer
94 views

Call code:

@(
            Html.Kendo().Grid<HomeFlat>()
                .Name("TestGridName")
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .ServerOperation(true)
                    .Model(model =>
                        {
                            model.Id(p => p.TestProperty);
                            model.Field(p => p.TestProperty).Editable(false);
                        }
                    )
                    .Read(read => read.Action("Action_Test", "Home"))
                )
        )

 

The error you get with the build:

Critical error was detected at line 74, column 9 in http://localhost:XXXX/.
SCRIPT1002: Syntax error

Viktor Tachev
Telerik team
 answered on 01 Mar 2018
3 answers
1.2K+ views

Hello,

is there any possibility to add an additional value to the ToDataSourceResult in the Kendo read Action to pass that value with
the Ajax request to the Client?

return Json(result.ToDataSourceResult(request));

 

Background: we have a paged grid and in my action I pass the ID of a row which is added to the database with a Ajax form outside the grid
and calculate on the Server the page for that row so I want to pass that page as an additional value to the client:
https://www.telerik.com/forums/find-row-and-select-it-in-grouped-sorted-and-paged-grid#nF26Ya0-hkqiWAdfUkaSuQ

robert

Georgi
Telerik team
 answered on 28 Feb 2018
2 answers
257 views

What am I doing wrong.  I have a grid that refuses to post back to the proper action in the controller.  It continually goes back to the (get) Index action even though in the grid I am calling an action called Cleanup_Update.  When initially calling the page Cleanup_Read works fine.  Only when editing the inside of the grid and hitting save changes is it not going where it should go. 

Thanks in advance

 

View

@{
    ViewData["Title"] = "Index";
}
@Html.AntiForgeryToken()
 
<h2>Index</h2>
 
@(Html.Kendo().Grid<FacilityDataManagerMVC.Models.ViewModels.ErrorCleanup>
                ()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(c => c.ID).Width(150);//.Hidden(true);
        columns.Bound(c => c.stationAssetID).Width(140).Filterable(ftb => ftb.Multi(true).CheckAll(true));
                    columns.Bound(c => c.stationID).Width(140).Filterable(ftb => ftb.Multi(true).CheckAll(true));
                    columns.Bound(c => c.errorType).Width(110).Filterable(ftb => ftb.Multi(true).CheckAll(true));
                    columns.Bound(c => c.readingDate).Width(110).Format("{0:MM/dd/yyyy}").Filterable(ftb => ftb.Multi(true).CheckAll(true));
        //columns.Bound(c => c.errorCorrected).Width(25);
        //change the column above to a checkbox
        columns.Bound(c => c.errorCorrected).ClientTemplate("<input type='checkbox' disabled='true' value='#= errorCorrected #' " + " # if (errorCorrected) { #" + "checked='checked'" + "# } #" + "/>");
                    columns.Bound(c => c.operatingHours).Width(25);
                    columns.Bound(c => c.totalDowntimeHours).Width(25);
                    columns.Bound(c => c.horsepowerHours).Width(25);
                    columns.Bound(c => c.fuelConsumed).Width(25);
                    columns.Bound(c => c.engineStartAttempts).Width(25);
                    columns.Bound(c => c.engineStartFailed).Width(25);
                    columns.Bound(c => c.engineStartSuccess).Width(25);
                    columns.Bound(c => c.startupDuration).Width(25);
                    columns.Bound(c => c.throughputMMCF).Width(25);
                    columns.Bound(c => c.averageUnitRPM).Width(25);
                    columns.Bound(c => c.oilUsageCompressor).Width(25);
                    columns.Bound(c => c.oilUsageEngine).Width(25);
                    columns.Bound(c => c.oilUsageManual).Width(25);
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Save();
                })
                .Editable(editable => editable.Mode(GridEditMode.InCell))
                .Sortable()
                .Filterable()
                .Pageable()
                .Navigatable()
                .DataSource(dataSource => dataSource
                .Ajax()
                .Batch(true)
                .PageSize(20)
                .ServerOperation(false)
                .Events(events => events.Error("error_handler"))
                //set the fields to non-editable here
                .Model(model =>
                {
                    model.Field(p => p.ID).Editable(false);
                    model.Field(p => p.stationID).Editable(false);
                    model.Field(p => p.readingDate).Editable(false);
                    model.Field(p => p.errorType).Editable(false);
                    model.Field(p => p.stationAssetID).Editable(false);
                    model.Field(p => p.errorCorrected).Editable(false);
                })
                .Read(read => read.Action("Cleanup_Read", "Cleanup").Data("sendAntiForgery"))
                .Update(update => update.Action("Cleanup_Update", "Cleanup").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);
        }
    }
</script>
<script type="text/javascript">
    function sendAntiForgery() {
        return { "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val() }
    }
</script>
<style>
    .k-readonly {
        color: gray;
    }
</style>

Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using FacilityDataManagerMVC.Data;
using FacilityDataManagerMVC.Models.ViewModels;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
 
namespace FacilityDataManagerMVC.Controllers
{
 
    public class CleanupController : Controller
    {
        private readonly FacilityDataManagerMVCContext _context;
 
        public CleanupController(FacilityDataManagerMVCContext context)
        {
            _context = context;
        }
        // GET: Cleanup
        public ActionResult Index()
        {
            return View();
        }
 
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult IndexPost([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ErrorCleanup> errors)
        {
 
            if (errors != null && ModelState.IsValid)
            {
                foreach (var product in errors)
                {
                    //productService.Update(product);
                    string x = "mystring";
                }
            }
 
            return Json(errors.ToDataSourceResult(request, ModelState));
        }
 
        [HttpPost]
        [ValidateAntiForgeryToken]
        public IActionResult Cleanup_Update([DataSourceRequest] DataSourceRequest request, [Bind]IEnumerable<ErrorCleanup> errors)
        {
            if (errors != null && ModelState.IsValid)
            {
                foreach (var product in errors)
                {
                    //productService.Update(product);
                    string x = "mystring";
                }
            }
 
            return Json(errors.ToDataSourceResult(request, ModelState));
        }
       
        public IActionResult Cleanup_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(getScadaErrors().ToDataSourceResult(request));
        }
        private IEnumerable<ErrorCleanup> getScadaErrors()
        {
            using (_context)
            {
                return _context.ScadaErrors.Select(scadaError => new ErrorCleanup
                {
                    ID = scadaError.Id,
                    stationAssetID = scadaError.StationAssetId,
                    stationID = scadaError.StationId,
                    errorType = scadaError.ErrorType,
                    readingDate = scadaError.ReadingDate,
                    operatingHours = scadaError.OperatingHrs,
                    totalDowntimeHours = scadaError.TtlDowntimeHrs,
                    horsepowerHours = scadaError.HrsepwrHrs,
                    fuelConsumed = scadaError.FuelConsumed,
                    engineStartAttempts = scadaError.EngineStartsAttempts,
                    engineStartFailed = scadaError.EngineStartsFailed,
                    engineStartSuccess = scadaError.EngineStartsSuccess,
                    startupDuration = scadaError.StartupDuration,
                    throughputMMCF = scadaError.ThruputMmcf,
                    averageUnitRPM = scadaError.AvgUnitRpm,
                    oilUsageCompressor = scadaError.OilToCompCyl,
                    oilUsageManual = scadaError.OilNewCcHand,
                    errorCorrected = scadaError.ErrorCorrected
                    //blowdownCount = (int)scadaError.BlowdownCnt
                }
                ).ToList();
            }
        }
    }
}

 

 

 

 

Michael
Top achievements
Rank 1
 answered on 27 Feb 2018
1 answer
117 views

On the documentation for the Grid located here:

 

https://docs.telerik.com/aspnet-core/helpers/html-helpers/grid

I see a reference to the ProductService but don't see that as part of the sample on that page.  Where can this code be found. 

Preslav
Telerik team
 answered on 21 Feb 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?