Telerik Forums
UI for ASP.NET Core Forum
7 answers
116 views

Hi

 

I am new to Telerik, can someone point me to a sample of using Scheduler in Razor Page with EF data? I am not using Controller but code behind for Razor Page.

thanks in advance.

Jimmy
Top achievements
Rank 1
Iron
Veteran
 answered on 11 Feb 2019
5 answers
154 views

Hello,

 

I am trying to use the Scheduler control for my application. I have it reading the data from my controller fine. However, I cannot get it call the HttpPut handler correctly.

My breakpoint isnt hit & checking the traffic the responce is:

400 - Bad Request
{"":["The input was not valid."]}

 

The code I am using for the UI is:

01.@(Html.Kendo().Scheduler<MeetingViewModel>()
02.      .Name("SchedulerView")
03.      .Height(500)
04.      .Date(DateTime.Now.ToUniversalTime())
05.      .StartTime(new DateTime(2018, 11, 28, 0, 00, 00).ToUniversalTime())
06.      .MajorTick(30)
07.      .ShowWorkHours(false)
08.      .Footer(false)
09.      .Editable(edit =>
10.      {
11.          //edit.Resize(false);
12.          edit.Create(false);
13.      })
14.      .Views(views =>
15.      {
16.          views.TimelineView(timeline => timeline.EventHeight(50));
17.          //views.TimelineWeekView(timeline => timeline.EventHeight(50));
18.          //views.TimelineWorkWeekView(timeline => timeline.EventHeight(50));
19.          //views.TimelineMonthView(timeline =>
20.          //{
21.          //    timeline.StartTime(DateTime.Now);
22.          //    timeline.EndTime(DateTime.Now.AddMonths(1));
23.          //    timeline.MajorTick(1440);
24.          //    timeline.EventHeight(50);
25.          //});
26. 
27.      })
28.      .Timezone("Etc/UTC")
29.      .Group(group => group.Resources("WorkCenters" /*,"Attendees"*/).Orientation(SchedulerGroupOrientation.Vertical))
30.      .Resources(resource =>
31.      {
32.          resource.Add(m => m.ScheduleRowID)
33.              .Title("Work Center")
34.              .Name("WorkCenters")
35.              .DataTextField("Text")
36.              .DataValueField("Value")
37.              .DataColorField("Color")
38.              .BindTo(@Model.AvailableWorkCenters);
39.      })
40.      .DataSource(d => d
41.          .ServerOperation(true)
42.          .WebApi()
43.          .Model(m =>
44.          {
45.              m.Id(f => f.ActivityID);
46.              m.Field(f => f.Title).DefaultValue("No title");
47.              //m.RecurrenceId(f => f.RecurrenceID);
48.              m.Field(f => f.Description).DefaultValue("No Description");
49.          })
50.          .Events(events => events.Error("error_handler"))
51.          .Read(read => read.Action("GetActivities", "Scheduler").Data("setRequestDateTimes"))
52.          //.Create(create => create.Action("Post", "Scheduler"))
53.          .Update(update => update.Action("PutActivity", "Scheduler", new { id = "{0}" }))
54.          //.Destroy(destroy => destroy.Action("Delete", "Scheduler", new { id = "{0}" }))
55.      )))

 

The code I am using for the Controller is:

01.[Route("Api/[controller]")]
02.[ApiController]
03.public class SchedulerController : DawnController
04.{
05.    public SchedulerController(DatabaseContext context) : base(context)
06.    {
07.    }
08. 
09.    [HttpGet]
10.    public DataSourceResult GetActivities([DataSourceRequest] DataSourceRequest request, DateTime requestStartDateTime, DateTime requestEndDateTime)
11.    {
12.        //Kendo doesnt seem to send the full date range. so + 1 day to end
13.        requestEndDateTime = requestEndDateTime.AddDays(1);
14. 
15.        List<MeetingViewModel> test = new List<MeetingViewModel>();
16. 
17.        //List<JobTask> Tasks =
18.        //    Context.JobTask.Where(j => JobTask.HasActivityInDateRange(j, requestStartDateTime, requestEndDateTime)).ToList();
19. 
20.        //foreach (JobTask jobTask in Tasks)
21.        //{
22.        //    foreach (Activites jobTaskAct in jobTask.Activites)
23.        //    {
24.        //        test.Add(new MeetingViewModel()
25.        //        {
26.        //            JobTaskID = jobTask.JobTaskId,
27.        //            ActivityID = jobTaskAct.ActivityId,
28.        //            Title = jobTaskAct.Name,
29.        //            Description = jobTaskAct.Description,
30.        //            Start = jobTaskAct.StartTime,
31.        //            End = jobTaskAct.EndTime,
32.        //            IsAllDay = false,
33.        //            ScheduleRowID = jobTaskAct.Workcenter.WorkCenterId,
34.        //        });
35.        //    }
36.        //}
37. 
38.        foreach (JobTask jobTask in Context.JobTask)
39.        {
40.            if (JobTask.HasActivityInDateRange(jobTask, requestStartDateTime, requestEndDateTime))
41.            {
42.                foreach (Activites jobTaskAct in jobTask.Activites)
43.                {
44.                    test.Add(new MeetingViewModel()
45.                    {
46.                        JobTaskID = jobTask.JobTaskId,
47.                        ActivityID = jobTaskAct.ActivityId,
48.                        Title = jobTaskAct.Name,
49.                        Description = jobTaskAct.Description,
50.                        Start = jobTaskAct.StartTime.ToUniversalTime(),
51.                        End = jobTaskAct.EndTime.ToUniversalTime(),
52.                        IsAllDay = false,
53.                        ScheduleRowID = jobTaskAct.Workcenter.WorkCenterId,
54.                    });
55.                }
56.            }
57.        }
58.        return test.ToDataSourceResult(request);
59.    }
60. 
61. 
62.    [HttpPut("{id}")]
63.    public IActionResult PutActivity(int id, MeetingViewModel task)
64.    {
65.        if (ModelState.IsValid && id == task.ActivityID)
66.        {
67.            try
68.            {
69.                //breakpoint here
70.                bool a = true;
71.                //update the db here
72.            }
73.            catch (DbUpdateConcurrencyException)
74.            {
75.                return new NotFoundResult();
76.            }
77. 
78.            return new StatusCodeResult(200);
79.        }
80.        else
81.        {
82.            return BadRequest(ModelState.Values.SelectMany(v => v.Errors).Select(error => error.ErrorMessage));
83.        }
84.    }
85.}

 

What could be the issue for me?

Pablo
Top achievements
Rank 1
 answered on 06 Feb 2019
1 answer
254 views

Hi!

Example: https://demos.telerik.com/aspnet-core/grid/editing

When the user changes the first product name from "Chai" to "Chai2", and then back again to "Chai" without clicking on "Save changes", the dirty flag stays visible, and unchanged data is transferred to the server when clicking on "Save changes".

Is it possible to change this grid editing behaviour? In comparison, in inline editing mode, data is sent to the server when clicking on "Update" only when the data has really changed.

 

Best regards,

Kaan

Tsvetomir
Telerik team
 answered on 06 Feb 2019
1 answer
911 views

Hi,

I have created a grid with 10 columns, but I need two of them to be editable.

1 - I don't want to use inline buttons [Edit], [Save] or [Delete];

2 - I don't want the other cells to be editable, only those two I need.

3 - I want the user to click in a cell, opening it for edition;

4 - I want to save those two values only if both of them are filled out;

5 - I don't mind having a server request when the user change from once cell to another (among the editable ones).

Is it possible to do? If not, could you give me some options of how I could manage it in a Telerik grid?

Thanks.

Tsvetomir
Telerik team
 answered on 06 Feb 2019
1 answer
136 views

Hello,

I am evaluating Kendo UI for ASP.NET Core for our team.

We need to be able to render different editors in the same column. I have attached a screenshot with an example grid:

  1. Wireless Keyboard: The parameter column is empty and not editable. There is only one single version of the keyboard.
  2. T-Shirt: The parameter column has a DropDownList with options S (Id 1), M (Id 2), L (Id 3), XL (Id 4).
  3. LED Lightbulb: The parameter column has a DropDownList with options 25 Watts and 40 Watts.

When the user changes the option in a DropDownList, data is send to the server, and an updated row is returned back to the client (for example, with a different price).

 

Is it possible to implement this grid with Kendo UI? Could you provide a working example for us?

 

Best regards,

Kaan

Georgi
Telerik team
 answered on 06 Feb 2019
4 answers
856 views

Are there any asp.net core examples for embedding controls in a grid?  I am trying to show a progressbar along with my row data.  The data fields display fine, but not the progress bar. I've attached a couple screen images - one showing a list version of what I am trying to do and the second of my results.  Here is how my grid is setup:

        @(Html.Kendo().Grid<ITFactory.Models.ChartModels.FeatureProgress>()
                                .Name("FeatureProgress")
                                .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .PageSize(10)
                                    .Read(read => read
                                        .Action("GetFeatureProgress", "Dashboards")
                                        .Data("FeatureProgressFilter")
                                    )
                                )
                                .Columns(columns =>
                                {
                                    columns.Bound(c => c.FeatureName);
                                    columns.Bound(c => c.EstimatedCardCount);
                                    columns.Bound(c => c.CompletedCardCount);
                                    columns.Template(" ").Title("ProgressBar");
                                })
                                .ClientRowTemplate(
                                           "<tr>" +
                                                "<td>" +
                                                    "#:FeatureName#" +
                                                "</td>" +
                                                "<td>" +
                                                    "#: EstimatedCardCount#" +
                                                "</td>" +
                                                "<td>" +
                                                    "#: CompletedCardCount#" +
                                                "</td>" +
                                                "<td>" +
                                                    "@(Html.Kendo().ProgressBar()" +
                                                    ".Name(Progress#:FeatureName#)" +
                                                    ".Type(ProgressBarType.Percent)" +
                                                    ".Max(#: EstimatedCardCount#)" +
                                                    ".Value(#: CompletedCardCount#))" +
                                                "</td>" +
                                            "</tr>"
                                )
                                .Sortable()
        )

 

 

Tsvetomir
Telerik team
 answered on 05 Feb 2019
7 answers
94 views

Hello, 

I am trying to use a DDL (This happens to both HTML Helper & Tag Helper) With a 'Option-Label'. however, every time this is applied it causes the DDL to deformat. Please see the attached pictures. Do you have any idea why this is happening? 

Misho
Telerik team
 answered on 05 Feb 2019
5 answers
400 views

I have an issue where the DIV on the bottom of the edit templates is not filling the width of the window.  Please see attached.

I have added the following .css which seems to control it but if the width is set to "auto" or "100%" it looks like the attachment.  If I change to to a specific pixel width it sizes but as I remember this should not need to be manually handled.

<style>
   div.k-edit-buttons.k-state-default{
     /*width:560px;*/
     width:100%;
    }
</style>

 

The grid does have the height and width set in the column declarations

.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Template").Window(x => x.Width(600).Height(500)))

 

Please advise

 

Reid
Top achievements
Rank 2
 answered on 05 Feb 2019
2 answers
202 views

Have a grid and context menu defined in a partial view.  When the grid is positioned where the page is scrolled to the top then the context menu opens at point of right mouse click.  But as soon as page is scrolled down and grid is partially moved up and hidden from view, then the context menu is not positioned correctly on the y axis.

 

@using Kendo.Mvc.UI

@using NEP_Deconstruction.Data
@{
    const string ValuesSuffix = "-Values";
}

@(Html.Kendo().Grid<NEP_Deconstruction.Data.Models.ApprovalViewModel>()
                    .Name("approval_grid")
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.ID)
                            .EditorTemplateName("IntegerReadonly");
                        columns.Bound(o => o.ApprovalNumber)
                            .EditorTemplateName("IntegerReadonly");
                        columns.Bound(o => o.SourceCount)
                            // other column definitions
                        columns.Bound(o => o.Comment);

                        columns.Command(command =>
                        {
                            command.Edit().Text(" ").IconClass("k-icon k-i-edit").HtmlAttributes(new { style = "min-width: auto" });
                            command.Destroy().Text(" ").IconClass("k-icon k-i-delete").HtmlAttributes(new { style = "min-width: auto" });
                        }).Width(/*210*/ 125);
                    })
                    .ToolBar(toolbar => { toolbar.Create(); /*toolbar.Save();*/ })
                    .Editable(editable =>
                    {
                        editable.TemplateName("ApprovalPopupEditor");
                        editable.Mode(GridEditMode.PopUp);
                    })
                    .Resizable(c => c.Columns(true))
                    .Reorderable(c => c.Columns(true))
                    .Filterable()
                    .Groupable()
                    .Pageable(p => p.Numeric(false).PreviousNext(false))
                    .Selectable()
                    .Sortable()
                    .Scrollable(scrollable => scrollable.Virtual(true).Endless(true))
                    .ColumnMenu()
                    .HtmlAttributes(new { style = "height:430px;" })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .PageSize(100)
                        .ServerOperation(true)
                        .Events(events => events.Error("error_handler")
                                                .RequestStart("approval_grid_requeststart"))
                        .Model(model =>
                        {
                            // ***
                            // various default values set
                        })
                        .Read(read => read.Action("Read", "Approval"))
                        .Create(create => create.Action("Create", "Approval"))
                        .Update(update => update.Action("Update", "Approval"))
                        .Destroy(destroy => destroy.Action("Destroy", "Approval"))
                    )
                    .Events(events => events.Change("approval_grid_change")
                                            .DataBound("approval_grid_databound")
                                            .Edit("approval_grid_edit")
                                            .Save("approval_grid_save"))
)
@(Html.Kendo().ContextMenu()
                    .Name("approval_menu")
                    .Target("#approval_grid")
                    .Filter("tr[role='row']")
                    .Orientation(ContextMenuOrientation.Vertical)
                    .Items(items =>
                    {
                        items.Add()
                        .Text("Refresh");
                        //.ImageUrl(Url.Content("~/shared/web/toolbar/reply.png"))
                        items.Add()
                        .Text("Edit");
                        items.Add()
                        .Text("Delete");
                    })
                    .Events(e => e.Select("approval_menu_select"))
)

 

Edward
Top achievements
Rank 1
 answered on 04 Feb 2019
1 answer
454 views

I have found many examples of cascading from DropDownListFor to DropDownListFor using the CascadeFrom() event. However, I need to get a similar effect from using a DropDownListFor to a MultiSelectFor. Since the MultiSelectFor does not have the CascadeFrom() event,  how would I go about making it work? 

Example
- The user selects an item from the DropDownListFor.
- The MultiSelectFor DataSource will be updated based on the selected item of the DropDownListFor.
- The MultiSelectFor will be enabled/disabled based on DropDownListFor.

Found the following JS sample but it does not seem to really apply to asp.net core.
https://docs.telerik.com/kendo-ui/controls/editors/multiselect/how-to/cascade/cascade-from-ddl


Any help will be greatly appreciated.

Hilton
Top achievements
Rank 1
 answered on 04 Feb 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?