Telerik Forums
UI for ASP.NET Core Forum
3 answers
433 views

Hello,

 

I have the following grid and the Read method is working fine but when I try to delete or edit a record the button doesn't call the method from the controller.

Can you please advise ?

Here is the .cshtml

<kendo-grid name="OverTime">
    <toolbar>
        <toolbar-button name="create" text="Add new Overtime"></toolbar-button>
    </toolbar>
    <columns>
        <column field="Id" title="ID" />
        <column field="RecordDate" format="{0:MM/dd/yyyy}" title="Record Date" />
        <column field="TimeFrom" title="Time From" />
        <column field="TimeTo" title="Time To" />
        <column field="NumberOfHours" title="Number of hours" />
        <column field="OvertimeReason" title="Overtime Reason" />
        <column>
            <commands>
                <column-command text="delete" name="destroy"></column-command>
                <column-command text="update" name="update"></column-command>
            </commands>
        </column>
    </columns>
    <datasource type="DataSourceTagHelperType.Ajax" page-size="20">
        <schema>
            <model id="Id">
                <fields>
                    <field name="RecordDate" type="date"   />
                    <field name="TimeFrom" type="time" />
                    <field name="TimeTo" type="time" />
                    <field name="NumberOfHours" type="number" />
                    <field name="OvertimeReason" type="string" />
                </fields>
            </model>
        </schema>
        <transport>
            <read url="@Url.Action("Read_Overtime","OverTimes",  new { id = ViewContext.RouteData.Values["Id"] })" />
            <destroy url="@Url.Action("Destroy_Overtime","OverTimes")" />
            <update url="@Url.Action("Update_Overtime","OverTimes")" />
        </transport>
    </datasource>
    <groupable enabled="true" />
    <sortable enabled="true" />
    <pageable button-count="5" refresh="true" />
    <filterable enabled="true" />
    <editable enabled="true" />
    <toolbar>
    </toolbar>
</kendo-grid>

 

 

Here is the update and delete method from the controller.

 

        [HttpPost]
        public ActionResult Destroy_Overtime ([DataSourceRequest]DataSourceRequest request, OverTimeViewModel overTime)
        {
            try
            {
                OverTime over = _context.OverTime.Find(overTime.Id);
                if (over == null)
                {
                    return Json("Employee Not Found");
                }

                _context.OverTime.Remove(over);
                _context.SaveChanges();
                return Json(_context.OverTime.ToList());
            }
            catch (Exception ex)
            {
                return Json(ex.Message);
            }
        }

        [HttpPost]
        public ActionResult Update_Overtime([DataSourceRequest]DataSourceRequest request, OverTime overTime)
        {

            try
            {
                if(ModelState.IsValid)
                {
                    
                    _context.Entry(overTime).State = EntityState.Modified;
                    _context.SaveChanges();
                    return Json(new[] { overTime }.ToDataSourceResult(request, ModelState));
                }
                else
                {
                    return Json(_context.OverTime.ToList());
                }
            }
            catch(Exception ex)
            {
                return Json(ex.Message);
            }
        }

Nikolay
Telerik team
 answered on 20 Mar 2020
1 answer
94 views

Problem :

Destroy doesn't go to the controller, What am i doing wrong?

Read function works fine.

Grid :

<kendo-datasource name="dateSource2" type="DataSourceTagHelperType.Ajax" server-operation="false">
        <transport>
            <read url="/Begroting/GetBegrotingWijzigingen?filterElement=2-9" />
            <destroy url="/Begroting/RemoveBegrotingWijziging" />
        </transport>
        <schema>
            <model id="Id">
            </model>
        </schema>
    </kendo-datasource>
 
    <kendo-grid name="grid2" datasource-id="dateSource2">
        <groupable enabled="false" />
        <sortable enabled="true" />
        <scrollable enabled="true" />
        <filterable enabled="true" />
        <pageable button-count="5" refresh="true" page-sizes="new int[] { 5, 10, 20, 50, 100 }">
        </pageable>
        <columns>
            <column field="Datum" title="Datum" />
            <column field="Afdeling" title="Afdeling" />
            <column field="Combinatie" title="Combinatie" />
            <column field="Bedrag" title="Bedrag" />
            <column field="Toelichting" title="Toelichting" />
            <column>
                <commands>
                    <column-command text="Delete" name="destroy"></column-command>
                </commands>
            </column>
        </columns>
    </kendo-grid>

 

Controller :

[HttpPost]
   public IActionResult RemoveBegrotingWijziging([DataSourceRequest] DataSourceRequest request, BegrotingRecord begrotingRecord)
   {
       if (!begrotingRecord.Naarcoda)
       {
           _rW.BegrotingRepository.RemoveBegrotingRecord(begrotingRecord.Id);
       }
 
       return Json("OK");
   }
Tsvetomir
Telerik team
 answered on 19 Mar 2020
1 answer
351 views

Hi,

We recently updated our .NET Core web app from Kendo UI v2019.3.1023 to Kendo UI v2020.1.219. The code snippet below used to produce a checkbox and label that didn't wrap, but after the update the label wraps onto a second line if the width of the window is decreased. I have confirmed that the source of the change is in kendo.bootstrap-v4.min.css by copying the contents of the Kendo UI v2019.3.1023 kendo.bootstrap-v4.min.css back into the project and observing that no wrapping occurs. Was this an intended change in behaviour? Is there anything we can do other than to add a white-space: nowrap style to every single col class that has a Kendo CheckBoxBuilder in it?

Kind regards,

David

<div class="row align-items-center p-1">
        <div class="col-4">Header</div>
        <div class="col-2">
            @Html.Kendo().CheckBox().Name("CheckboxName").Label("Checkbox")
            @Html.HiddenFor(model => model.Checkbox)             
        </div>
Denitsa
Telerik team
 answered on 18 Mar 2020
5 answers
1.1K+ views

Scheduler Resource Binding using DataSource not displaying Employee.  Where are the examples?  I need an example that doesn't use BindTo.  Also where are the Asp.Net Core 2 examples?  all are for Asp.net 1

 

@(Html.Kendo().Scheduler<SalonWeb.Models.TimeBlock>()
    .Name("scheduler")
    .Date(DateTime.Now)
    .StartTime(DateTime.Now)
    .Height(600)
    .MajorTick(60)
    .Views(views =>
    {
        views.DayView();
        views.WeekView();
        views.MonthView();
    })
    .Resources(resource =>
    {
        //reading but not displaying
        resource.Add(m => m.Employee)  //employee object
            .Title("Employee") //descriptive title
            .DataTextField("Name") //property in Employee Object
            .DataValueField("Id") //property in Employee Object
            .DataColorField("Color") //property in Employee Object
            .DataSource(ds => ds
                .Read("Read", "Employees") //Read function in Employee controller
            );
    })
    .DataSource(d => d
        .Model(m => {
            m.Id(f => f.Id);
            m.Field(f => f.Title).DefaultValue("No title");
            m.Field(f => f.Employee);
        })
        .Read("Read", "TimeBlocks")
        .Create("Create", "TimeBlocks")
        .Update("Update", "TimeBlocks")
        .Destroy("Delete", "TimeBlocks")
    )
)

TimeBlock controller 

public async Task<IActionResult> Create([DataSourceRequest] DataSourceRequest request, TimeBlock timeBlock)
        {
            if (ModelState.IsValid)
            {
                _context.Add(timeBlock);
                await _context.SaveChangesAsync();
            }
            return Json(await new[] { timeBlock }.ToDataSourceResultAsync(request, ModelState));
        }


Employee Controller

public async Task<IActionResult> Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(await _context.Employee.ToDataSourceResultAsync(request));
        }
Martin
Telerik team
 answered on 17 Mar 2020
1 answer
340 views

Hello Everyone, 

we need to use drill down functionality in .net core application. but no solution found any one help me how to use ?

I found one solution but it's using webforms.

https://demos.telerik.com/aspnet-ajax/htmlchart/examples/drilldownchart/defaultcs.aspx

 

 

Alex Hajigeorgieva
Telerik team
 answered on 17 Mar 2020
24 answers
472 views

When trying to select an image from the root folder everything is fine, however when selecting an images from a sub-folder the return path is wrong because it includes to following code %2F between the folder name and the image name instead of the /

This was tried under the Telerik demo site and as well as locally.

Veselin Tsvetanov
Telerik team
 answered on 16 Mar 2020
2 answers
908 views

Using either html or tag helper, the width and height seem to only accept px.  Dialog for other products accept %.  Does Dialog for Asp.Net Core accept %? 

If I edit the output HTML using browser devtools, percentage works fine.  So I'm guessing I'm just missing something.  

Brian
Top achievements
Rank 1
 answered on 12 Mar 2020
1 answer
571 views

Hi,

I need to do display server side validations errors on Edit/Add Screen of Popup.

I have added the custom template through  "TemplateName" and placed it in "EditorTemplates" and I am adding error message at server as :

                ModelState.AddModelError("error1", "Error 1 description");

but. how do I display on the popup. Currently it shows in JavaScript script error handler I have defined as:
              .Events(events => events.Error("error_handler"))   

 

1) I want to display error besides field on the popup. 
2) As soon as I click update the popup closes. I want it to keep open and display error message. I tried  e.preventDefault();  but it doesn't seems to work. It does cancel the grid refresh but window closes.

 

Has anyone done this? is there a sample I can follow.

 

Thanks in advanced.

 

Aleksandar
Telerik team
 answered on 12 Mar 2020
7 answers
506 views

Hello Everyone,

Currently i'm working on  dynamically data binding in kendo pie chart in .net core 3.0.

We have get data from database and values greater than 0 so it's working fine.

but KPI value recieve 0 so pie chart is not draw properly. Please review attached file "PieChartEmpty.PNG"

 

We need to draw Default chart if value received from Database is 0. Please review attached file "ExpectedResult.PNG"

Please provide solution ASAP

 

 

 

 

Preslav
Telerik team
 answered on 12 Mar 2020
20 answers
1.3K+ views

Hi All,

I cant seem to make breadcrumb work inside kendo grid toolbar template.

Heres my code, what did I miss?

Please note that the button menu, user type dropdown, field search dropdown, and searchbox is showing on my grid toolbar.

 

 

@(Html.Kendo().Grid<UsersList>
                                ()

.ToolBar(t =>
                                {
                                    t.ClientTemplateId("GridToolbarTemplate");
                                })

)

 

<script id="GridToolbarTemplate" type="text/x-kendo-template">
                    <div class="menuBtnContainer">
                        <ul id="menu">
                            <li>
                                <span style="font-family: verdana,arial,sans-serif; font-size: 12px;" class="k-pager-refresh k-link k-button k-button-icon" title="Menu"><span class="k-icon k-i-menu"></span></span>
                                <ul>
                                    <li>Sub Item 1</li>
                                    <li>Sub Item 2</li>
                                    <li>Sub Item 3</li>
                                </ul>
                            </li>
                        </ul>

                    </div>
                    <div class="toolbar">
                        <input id="dropdownSource" style="width:200px; display:none; font-family: verdana,arial,sans-serif; font-size: 12px;" />
                        &nbsp;&nbsp;&nbsp;
                        <label class="search-label" for="search">Search</label>
                        <input id="dropdownFilterItems" style="width:150px; display:none; font-family: verdana,arial,sans-serif; font-size: 12px;" />
                    </div>
                    <span class="k-textbox k-grid-search k-display-flex" style="float:left"><input title="Search..." class="k-input" placeholder="Search..." autocomplete="off" style="font-family: verdana,arial,sans-serif; font-size: 12px;"><span class="k-input-icon"><span class="k-icon k-i-search"></span></span></span>
                    <div class="row"></div>
                    <nav id="breadcrumb"></nav>
                </script>

 

 

 <script>
        $(document).ready(function () {
            
            $("#menu").kendoMenu({
                animation: { open: { effects: "fadeIn" } },
                
            });
            $("#dropdownSource").kendoDropDownList({
                dataSource: ["FB Users", "CB Users"],
                //select: "NC Users",
                //change: change
            });
            $("#dropdownFilterItems").kendoDropDownList({
                dataSource: ["Email", "First Name", "Last Name", "Status", "User Type", "Date Created", "Date Last Login"],
                //select: "NC Users",
                //change: change
            });
            $("#breadcrumb").kendoBreadcrumb({
                items: [
                    {
                        type: "rootitem",
                        href: "https://demos.telerik.com/kendo-ui/",
                        text: "All Components",
                        showText: true,
                        icon: "home",
                        showIcon: true
                    },
                    {
                        type: "item",
                        href: "/breadcrumb",
                        text: "Breadcrumb",
                        showText: true
                    },
                    {
                        type: "item",
                        href: "/index",
                        text: "Basic Usage",
                        showText: true
                    }
                ]
            });
            
        });

 </script>

 

 

Dimitar
Telerik team
 answered on 12 Mar 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?