Telerik Forums
UI for ASP.NET Core Forum
1 answer
1.0K+ views

Hello everyone

I have the following bound column set up:

  columns.Bound(site => site.SiteHasBin).ClientTemplate("#=dirtyField(data,'SiteHasBin')# #:SiteHasBin#").ClientHeaderTemplate("<a class='k-link'>Bin Present? - Select all</><input style='margin-left:10px;' id='checkAll' type='checkbox' onclick='checkAll(this)' />").Sortable(false);
   


With the associated js:

function dirtyField(data, fieldName) {
    if (data.dirty && data.dirtyFields[fieldName]) {
        return "<span class='k-dirty'></span>"
    }
    else {
        return "";
    }
}


function checkAll(input) {
    var grid = $("#gridBins").data("kendoGrid");
    var items = grid.items();
    items.each(function () {
        var dataItem = grid.dataItem(this);
          if (dataItem.SiteHasBin != input.checked) {
              dataItem.SiteHasBin = input.checked;
        }
        dataItem.dirty = true;
    })
    grid.saveChanges();
    grid.dataSource.sync();
}

However, I cannot for the life of me get the cell into it's dirty state properly which would then allow me to use the Save functionality.

As you can see from the above. It updates the values accordingly but unlike single clicking, doesn't dirty the cell / data item.

Could someone point me in the right direction please?

Rich

 

 

Tsvetomir
Telerik team
 updated answer on 02 Sep 2021
0 answers
162 views

I have the below example:

As you can see, I check and pre Save Changes, everything works ok. I check, hit Cancel Changes and we get back to its original state.

After I save/commit to the db and then hit cancel changes, the grid updates some check boxes (incorrectly) and also updates the items.

What's going on here?!

Here's my grid code


@(Html.Kendo().Grid<BinWithType>
    ()
    .Name("gridBins")
    .DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => {
    model.Id(p => p.Bin_ID);
    model.Field(p => p.SiteHasBin).Editable(true);
    model.Field(p => p.Bin_Type_Name).Editable(false);
    model.Field(p => p.Bin_Type_Group).Editable(false);
    })
    .Batch(true)
    .ServerOperation(false)
    .Read("Bins_Read", "MySites", new { site_Id = Model.Site_Id })
    .Update("Bins_Update", "MySites", new { site_Id = Model.Site_Id })
    )
    .Columns(columns =>
    {
    columns.Bound(site => site.SiteHasBin).Filterable(false);
    columns.Bound(site => site.Bin_Type_Name).Filterable(false);
    columns.Bound(site => site.Bin_Type_Group).Filterable(filterable => filterable.UI("groupFilter"));
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Filterable(filterable => filterable
    .Extra(false)
    .Operators(operators => operators
    .ForString(str => str.Clear()))
    )
    .Sortable()
    .ToolBar(toolbar =>
    {
    toolbar.Save();
    })
    )

Further strange behaviour: 

When I do a 'standard' batch update this works as expected see first half of gif above. However, when I do one by one, I appear to just replicate the first.

 

Here is my my Read & Update code:

 


   public ActionResult Bins_Read(int site_Id, [DataSourceRequest]DataSourceRequest request)
        {
            return Json(Read(site_Id).ToDataSourceResult(request));
        }


        public IEnumerable<BinWithType> Read(int siteId)
        {
            return GetAllAsync(siteId).Result.ToList();
        }

        public async Task<IList<BinWithType>> GetAllAsync(int siteId)
        {
            if (Session.GetObjectFromJson<IList<BinWithType>>("BinWithType") != null)
            {
                Session.Remove("BinWithType");
                _session.Clear();
            }

            var result = Session.GetObjectFromJson<IList<BinWithType>>("BinWithType");

            var client = new BinsClient(new HttpClient());
            var bins = await client.GetBinsWithTypeBySiteIdAsync(siteId);

            result = bins.ToList();
            Session.SetObjectAsJson("BinWithType", result);
            return result;
        }

        public ActionResult Bins_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<BinWithType> bins)
        {
            var client = new BinsClient(new HttpClient());
            foreach (var bin in bins)
            {
                if (bin.Bin_ID > 300)
                {
                    DeleteBin(bin, client);
                }


                if (bin.Bin_ID < 300)
                {
                    PostNewBin(bin, client);
                }
            }
            return Json(Read(bins.FirstOrDefault().Site_ID).ToDataSourceResult(request));
        }

        private static Task<Bin> DeleteBin(BinWithType bin, BinsClient client)
        {
            return client.DeleteBinByIdAsync(bin.Bin_ID);
        }

        [HttpPost]
        private static Task<Bin> PostNewBin(BinWithType bin, BinsClient client)
        {
            var thisBin = new Bin
            {
                Site_ID = bin.Site_ID,
                Bin_Type_ID = bin.Bin_Type_ID,
                Comments = $"Added { DateTime.Now.ToShortDateString() }"
            };
            return client.PostBinAsync(thisBin);
        }


 

Richard
Top achievements
Rank 1
 updated question on 02 Sep 2021
1 answer
1.0K+ views

Hey everybody,

I'm experimenting with the Kendo Forms and I recognized that building/rendering the form with razor all labels showing the property name itself instead the display name I set in the model.

@(Html.Kendo().Form<Provider>()
            .Name("form")
            .Validatable(v =>
            {
                v.ValidateOnBlur(true);
                v.ValidationSummary(vs => vs.Enable(false));
            })
            .Items(items =>
            {
                items.Add().Field(x => x.Description).Editor(x => x.Editor());
                items.Add().Field(x => x.Url);
            })
        )

My model has set a display name for the properties.

    public class Provider
    {
        [Display(Name = "Kurzbeschreibung")]
        public string Description { get; set; }

        [Display(Name = "Link zur Website")]
        public string Url { get; set; }
    }
The view is showing the property name "Description" als label text instead the display name "Kurzbeschreibung". Is this behavior expected? If not I have to set for all fields I'm gonna use a title text for the frondend. It would be easier und beautiful when the form could automatically use the display name.
Aleksandar
Telerik team
 answered on 02 Sep 2021
1 answer
675 views

I am using a nested grid. The nested grid is inside of script tags and looks like this. For some reason when rendering it throws "Unexpected Token '<'. Im unsure why. It renders fine if I pull it out and remove .ToClientTemplate()

<script id="template"> @(Html.Kendo().Grid<Student>() .Name("Student#=Student_ID#") .Width(1500) .HtmlAttributes(new { style="margin-right:20px;height: fit-content;font-size:small" }) .Columns(columns => {

columns.Bound(o => o.StudentName).Width(300) columns.Bound(o => o.TimeStamp).Width(300).Title("Date").Format("{0:G}"); columns.Bound(o => o.Details).Width(900); }) .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .PageSize(10) .Read(read => read.Action("GetDetails", "Grid", new{ studentName= "#=StudentName#" })) ) .Pageable(x => x.Refresh(true)) .Sortable() .ToClientTemplate() ) </script>


Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 30 Aug 2021
1 answer
144 views

Is there a way to create an Combobox in the PanelBar header? We want to reload content of the PanelBar after changing the Combobox value.

I haven't found a function or Property like HeaderTemplate() or something similar.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 30 Aug 2021
1 answer
1.1K+ views

I have a web application that I am adding additional functions to.  The File Manager has just about everything I need (except to hide create folders).  But users have to have the ability to download files. (I kind of don't get how you can have a file manager without the ability to download files.)

Users will upload some CSV files, start a process & at end of process download log files created by the process. 

I see an example of how to extend File Manger but it just doesn't seem to fit the razor page model.  Can anyone point me towards some good examples of how to add that in?

Stoyan
Telerik team
 answered on 26 Aug 2021
1 answer
184 views

Is Server side paging supported on Treelist control?

It seems like Pager automatically dissaper when ServerOperation flag is true.

Thanks in advance.

Mihaela
Telerik team
 answered on 26 Aug 2021
1 answer
393 views
I see in the examples for Cards that they scroll horizontally .. but can they scroll vertically?  If so .. how do I do that?
Mihaela
Telerik team
 answered on 25 Aug 2021
1 answer
711 views

In my project asp .Net 5.0 Core, I have the next problem when my page load.

unable to resolve service for type 'kendo.mvc.rendering.kendo html generator'

  • Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)

  • lambda_method29(Closure , IServiceProvider , object[] )

  • Microsoft.AspNetCore.Mvc.Infrastructure.TypeActivatorCache.CreateInstance<TInstance>(IServiceProvider serviceProvider, Type implementationType)

  • Microsoft.AspNetCore.Mvc.Razor.Infrastructure.DefaultTagHelperActivator.Create<TTagHelper>(ViewContext context)

  • Microsoft.AspNetCore.Mvc.Razor.DefaultTagHelperFactory.CreateTagHelper<TTagHelper>(ViewContext context)

  • Microsoft.AspNetCore.Mvc.Razor.RazorPageBase.CreateTagHelper<TTagHelper>()

  • AspNetCore.Views_AlmacenProductosServicios_Index.ExecuteAsync() in Index.cshtml

    1. ViewData["Title"] = "Listado de productos y servicios";
  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)

  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)

  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)

  • Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

  • Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

  • Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

  • Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

 

I used the telerik package telerik.ui.for.aspnet.core.2021.2.616

In _ViewImports

@using WASys

@using WASys.Models

@using Kendo.Mvc.UI

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@addTagHelper *, Kendo.Mvc

My Page

 

<kendo-grid name="grid" height="550">

  <columns>

    <column field="ID" title="Order ID">

      <filterable enabled="false"></filterable>

    </column>

    <column field="CodigoInterno" title="Codigo" />

    <column field="NombreLargo" title="Nombre Producto/Servicio" />

    <column field="PrecioCosto" title="Precio Costo" />

  </columns>

  <scrollable enabled="true" />

  <sortable enabled="true" />

  <pageable enabled="true" />

  <filterable enabled="true" />

  <datasource type="DataSourceTagHelperType.Ajax" page-size="20">

    <transport>

      <read url="@Url.Action("Orders_Read", "AlmacenProductosServicios")" />

    </transport>

  </datasource>

</kendo-grid>

Mihaela
Telerik team
 answered on 25 Aug 2021
1 answer
133 views
 The item data is not transferred via the hash syntax to the custom template ("tooltip-tamplate") for the tooltip. But it works for other templates "task-templat" and "column-template". Please help me to find out the solution. Below is my code in View:

            <!--Style progress bar-->
            <script id="task-template" type="text/x-kendo-template">
                <div class="template" style="background-color: #= Color #;">
                    <a href="#= Link #">
                        <h5 style="font-family: "Open Sans",sans-serif;">#= title #<\h5>
                    </a>
                </div>
            </script>

            <!--Style columns-->
            <script id="column-template" type="text/x-kendo-template">
                @*<i class="tio-bookmark-outlined tio-lg text-primary"></i>*@
                <span>#= ProjectGenre #</span>
            </script>

            <!--Style ToolTip-->
            <script id="tooltip-tamplate" type="text/x-kendo-template">
                <div style="padding: 1rem;">
                    <p>Genre: #= ProjectGenre # </p>
                </div>
            </script>

@(Html.Kendo().Gantt<TaskViewModel, DependencyViewModel>((IEnumerable<TaskViewModel>)ViewData["tasks"], (IEnumerable<DependencyViewModel>)ViewData["dependencies"])
                            .Name("gantt")
                            .Columns(columns =>
                            {
                                columns.Bound(c => c.Studio).Title("Студія").Width(200).Sortable(true);
                                columns.Bound(c => c.ProjectGenre).Title("Жанр").Width(300).Sortable(true).TemplateId("column-template");
                            })
                            .Views(views =>
                            {
                                views.YearView(yearView => yearView.Selected(true));
                            })
                            .ShowWorkHours(false)
                            .ShowWorkDays(false)
                            .Editable(false)
                            .Height(600)
                            .TaskTemplateId("task-template")
                            .DataSource(d => d
                                .Model(m =>
                                {
                                    m.Id(f => f.TaskID);
                                    m.ParentId(f => f.ParentID);
                                    m.Field(f => f.Expanded).DefaultValue(true);
                                    m.Field(f => f.Start).ToString();
                                    m.Field(f => f.End).ToString();
                                })
                            )
                            .Tooltip(t =>
                            {
                                t.Visible(true);
                                t.TemplateId("tooltip-tamplate");
                            })
                            .DependenciesDataSource(d => d
                                .Model(m =>
                                {
                                    m.Id(f => f.DependencyID);
                                    m.PredecessorId(f => f.PredecessorID);
                                    m.SuccessorId(f => f.SuccessorID);
                                })
                            )
                    )
Aleksandar
Telerik team
 answered on 20 Aug 2021
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?