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

Hi!

The ListView is breaking my web application, and I cannot make head or tail of the reason:

An unhandled exception occurred while processing the request.

NotSupportedException: "ClientTemplateId or ClientTemplateHandler" cannot be null or empty.

Kendo.Mvc.UI.ListView<T>.VerifySettings()

 

Also, you demos for the ListView are broken and the browser tab crashed after a while.

I need an urgent fix, as this is affecting the live application.

Aleksandar
Telerik team
 answered on 17 Mar 2023
2 answers
25 views

Hi There,

I have a complex model in view.  But, i sended simple example for subject.

 

Main View Model : 

public class ErpProductModel
{
    public string Title { get; set; }
    public string Code { get; set; }
    public string ShortCode { get; set; }
    public int MinStock { get; set; }
    public int ShelfLife { get; set; }
    public int CategoryId { get; set; }
    public int TaxCategoryId { get; set; }
    public decimal AmountInProduct { get; set; }
    public int MeasureWeightId { get; set; }
    public int CountryId { get; set; }
    public int StatusId { get; set; }
    public List<ErpProductPackageTypeModel>? PackageTypes { get; set; } = [];
}

PackageTypes Model : 

public record ErpProductPackageTypeModel 
{
    public int? ProductId { get; set; }
    public string Barcode { get; set; }
    public int Quantity { get; set; }
    public string? PackageType { get; set; }
    public int PackageTypeId { get; set; }

    public List<SelectListItem> AvailablePackageTypes { get; set; } = [];
}

View Source :


<script type="text/x-kendo-tmpl" id="packageTypeTemplate">
         <div class="card widget widget-info">
             <div class="card-body">
                 <div class="widget-info-container">
                     <div class="widget-info-image" style="background: url('@Url.Content("/Assets/Images/barcode_mock.png")')"></div>
                     <h5 class="widget-info-title">#=Barcode#</h5>
                     <p class="widget-info-text">#=PackageType# / #=Quantity# PCS</p>
                 </div>
             </div>
         </div>
</script>

@(Html.Kendo().ListView<ErpProductPackageTypeModel>()
            .Name("package-types")
            .BindTo((IEnumerable<ErpProductPackageTypeModel>)Model.PackageTypes)
            .TagName("div")
            .Bordered(false)
            .Layout("grid")
            .Grid(p=> p.Cols(4).Gutter(20))
            .ClientTemplateId("packageTypeTemplate")
            .HtmlAttributes(new { @class= "rubi-listview package-types" })
            .DataSource(dataSource => 
                dataSource.Ajax()
                .Batch(true)
                .ServerOperation(false))
            )

 

Controller Post Method :


[HttpPost]
public virtual async Task<IActionResult> EditAsync(ErpProductModel model)
{
    var erpProduct = await _erpProductService.GetErpProductAsync(model.Id);
    if (erpProduct == null)
        return RedirectToAction("List");
    erpProduct = model.ToEntity(erpProduct);

    await _erpProductService.UpdateErpProductAsync(erpProduct);

    return RedirectToAction("Edit", new { id = erpProduct.Id });
}
When the page is first opened, data is filled into the listview control. No problem here. But when I do a post operation again, the PackageTypes in the model are not filled. In fact, it does not even appear in the first data that arrives. I couldn't figure out why. I only want a Client Side transaction.

My scenario is simple;
I have a product save screen. There are package types depending on this product. If all I want is to fill the package types, I will make various updates, additions or deletions on this data.

Thank you in advance for your help.
Mehmet
Top achievements
Rank 1
Iron
 answered on 15 Mar 2024
1 answer
26 views

Hi,

Is there an easy way to disable the spinner when loading more content in the list view on endless scroll mode? I can set the following CSS to hide it altogether but this would affect the initial load and load after filter etc

    .k-loading-mask {
        display: none !important;
    }

Many thanks,

Dale

Stoyan
Telerik team
 answered on 12 Dec 2023
1 answer
187 views

I have a listview that a user can click a button on and go to a new page.  I pass the current page and the id of the selected item to the new page.  When the user clicks on a link to return to the page with the listview, the page and the id are passed back.  I can change the page to the correct page and select the record in the dataBound event as shown below but, I have not been able to figure out how to scroll it into view.   Is there a way to do that?

function dataBound(e){
        var listViewDS = $("#lvDisplay").data("kendoListView").dataSource;
        var myPage = '@ViewBag.CurrentPage';
        var myId = '@ViewBag.CurrentId';

        if (myPage != 1){
            setTimeout(() => { listViewDS.page(myPage); }, 1000);

            var listView = $("#lvDisplay").data("kendoListView");
            var dataItems = listView.dataSource.view();
            var index = 0;
            for (var j = 0; j < dataItems.length; j++) {
                if (dataItems[j].Id == myId) {
                    index = j;
                    listView.select(index);

                    var row = e.sender.element.find("[data-uid='" + dataItems[j].uid + "']");
                    row.addClass("k-state-selected");
                };
            };
        }       
    }

I have tried the code below but always get an error for top.

$("#lvDisplay").scrollTop($("#lvDisplay").find(".k-state-selected").position().top);

 

 

 

__PRESENT__PRESENT__PRESENT__PRESENT__PRESENT__PRESENT__PRESENT

__PRESENT__PRESENT__PRESENT
Mihaela
Telerik team
 answered on 26 Oct 2023
1 answer
53 views

Hi there,

I'd like to trigger the virtualization scroll event programatically. My idea is to use a global body scroller to register the scroll down, and completely turn off the scroller on the listview container.

When I use the following code it will only replace my existing rows.

$("#allProductsListView").data("kendoListView").dataSource.read({ page: 2, pageSize: 36 })

I need a way to append in order to make virtualization work programatically.

Thank you.

Mihaela
Telerik team
 updated answer on 28 Aug 2023
1 answer
156 views

I have reached my wits end trying to figure out why my Kendo UI ListView will not display the data when using a very simple template.  The ListView is based on a IEnumerable Model.  I'm very frustrated at this point.  No errors in f12.  The template just does not display.  Checking in debugger the data is all there and the model passed back as Json to the view is populated.  I have triple checked the field names match in the template and model.

 

Update:  One more bit of info...even if the template is a simple thing like this it STILL does not show:

<script type="text/x-kendo-tmpl" id="template">
    <div>TEST TEMPLATE</div>
</script>

 

Relevant View Code:

<script id="templateTest" type="text/x-kendo-tmpl">
    <div>Accounts:</div>
    <div class="product-view k-widget">
        <dl>
            <dt>Bank Name</dt>
            <dd>#:BankName#</dd>
        </dl>
    </div>
</script>


@(Html.Kendo().ListView<PayrollAccountModel>()
    .Name("listViewTest")
    .AutoBind(false)
    .TagName("div")
    .ClientTemplateId("templateTest")
    //.ClientTemplateHandler("templateTest")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id("Id"))
        .Create(create => create.Action("PayrollAccount_Create", "DirectDeposit"))
        .Read(read => read.Action("PayrollAccount_Read", "DirectDeposit"))
        .Update(update => update.Action("PayrollAccount_Update", "DirectDeposit"))
        .Destroy(destroy => destroy.Action("PayrollAccount_Destroy", "DirectDeposit"))
    )
    .Editable().Deferred()
    )

 

Relevant Controller Code:

DirectDepositController:

public ActionResult PayrollAccount_Read([DataSourceRequest] DataSourceRequest request)
        {
            //create new listView item and add some test data
            List<PayrollAccountModel> Accounts = new()
            {
                new PayrollAccountModel { Id = 1, BankName = "Bangor Savings Bank", AccountNumber = "99999999", RoutingNumber = "123456789" },
            };

            return Json(Accounts.ToDataSourceResult(request));
        }

 

 

Any help would be hugely appreciated!

 

Thanks

Mihaela
Telerik team
 answered on 15 Aug 2023
0 answers
39 views
I've upgraded to my project to ASP.NET Core from the MVC version and updated all of the Kendo scripts to version 2023.2.718, and the reload animation for many of my controls now looks like the attached image. 
Jonas
Top achievements
Rank 1
 asked on 10 Aug 2023
1 answer
78 views

Hello,

I've searched forums and documentation and can't seem to find an example of how to do what I need.  What I am trying to do is I need an editable List View on my page where I want to use my model as the data source (in memory only).  Each time I save a record in the list view I want to add it to the model, then pass the contents of that same model to my server.

The List View will need to display all entries (update with each entry)

I need the data to persist in the model during the session.

Can anybody please point me to an example that does this in MVC C# .NET 6?

Thanks!

Mihaela
Telerik team
 answered on 29 Jun 2023
1 answer
50 views

Hi,

How can I use JS to scroll the ListView to the bottom.
The solution below does not work
            var listView = $("#ChatListView").data("kendoListView");
            var lastIndex = listView.dataSource.total() - 1;
            var lastItemOffsetTop = listView.items().eq(lastIndex).offset().top;
            var listViewHeight = listView.element.height();
            var scrollDistance = lastItemOffsetTop - listViewHeight + listView.items().eq(lastIndex).height();
            listView.element.scrollTop(scrollDistance);

Alexander
Telerik team
 answered on 20 Apr 2023
1 answer
550 views

hi

i need to pass parameter or model for ListView (not Model Page) to partialView  Page in listView with use ClientTemplateId

my code is:

<script type="text/x-kendo-tmpl" id="template">
    @Html.Partial("_myPartialView",new MSG_UserMessagesList_Ex_For_Model  { Name =  #: FileName # });
</script>
@(Html.Kendo().ListView<MSG_UserMessagesList_Ex_For_Model>()
                                        .Name("listView")
                                        .TagName("div")
                                        .HtmlAttributes(new { style = "height:100%; width: 100%;" })
                                        .ClientTemplateId("template")
                                        .DataSource(dataSource => dataSource
                                        .Ajax()
                                        .Read(r => r.Url(@Url.Page("MsgList", "MSG_UserMessagesList_Ex")).Data("forgeryToken"))
                                        )
                                        )
plase Help Me
Mihaela
Telerik team
 answered on 16 Feb 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?