Telerik Forums
UI for ASP.NET Core Forum
1 answer
499 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
1 answer
245 views

Hello i am using Oracle Database and have a model  called CableView Model  that i pass to grid  and CableInfoID is my  intended  id for the grid. I have issues updating grid data as always it returning 0 instead of a value.What am i doing wrong?

 

grid code

@(
                            Html.Kendo().Grid<DI_IPMS_KENDO.Models.CableViewModel>()
                                .Name("CableNetGrid")
                                .Columns(columns =>
                                {
                                    columns.Bound(p => p.CableInfoID);
                                    columns.Bound(p => p.CableId).Title("Cable").Width(100);
                                    columns.Bound(p => p.SwitchName).Width(100);
                                    columns.Bound(p => p.Port).Width(100);
                                    columns.Bound(p => p.TechnicianAssigned).Title("TechnicianAssigned").Width(150);
                                    columns.Bound(p => p.AvailableIp).Width(100);
                                    columns.Bound(p => p.SubnetMask).Width(100);
                                    columns.Bound(p => p.Comments).Width(100);
                                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
                                })
                                .ToolBar(toolbar => toolbar.Create())
                                .Editable(editable => editable.Mode(GridEditMode.PopUp))
                                .Pageable()
                                .Sortable()
                                .Scrollable()
                                .Events(ev => ev.Edit("onEdit"))
                                .Events(ev => ev.BeforeEdit("onEdit"))
                                .Events(ev => ev.Cancel("onCancel"))
                                .HtmlAttributes(new { style = "height:430px;" })
                                .DataSource(dataSource => dataSource
                                .Ajax()
                                .PageSize(20)
                                .Events(events => events.Error("error_handler"))
                                .Model(model =>
                                {
                                    model.Id(p => p.CableInfoID);
                                    model.Field(id => id.CableInfoID).DefaultValue(-1);
                                })
                            .Create(update => update.Action("Cables_Create", "Home").Data("getData"))
                            .Read(read => read.Action("Cables_Read", "Home").Data("getID"))
                            .Update(update => update.Action("Cables_Update", "Home").Data("getData"))
                            .Destroy(update => update.Action("Cables_Destroy", "Home"))
                            )
                            )

 

 

 

 

       

 public class CableViewModel

    {
        [ScaffoldColumn(false) ]
        public int CableInfoID { get; set; }



        [Required]
        [DisplayName("Cable ID")]
        public string CableId { get; set; }


        [Required]
        [DisplayName("Switch Name")]
        public string SwitchName { get; set; }

        [Required]
        [DisplayName("Port")]
        public string Port { get; set; }

        [ScaffoldColumn(false)]
        public string ToolID { get; set; }
        //public int ?ToolRecID { get; set; }
        [ScaffoldColumn(false)]
        public int ToolRecID { get; set; }

        [UIHint("_AdminEmp")]
        [Required]
        [DisplayName("Technician Assigned")]
        public string TechnicianAssigned { get; set; }

        [DisplayName("Available IP")]
        public string AvailableIp { get; set; }

        [DisplayName("Subnet Mask")]
        public string SubnetMask { get; set; }

        [DisplayName("Gateway")]
        public string Gateway { get; set; }
        public string Comments { get; set; }
    }

 

 

i have  update method as follows ..please ignore other fields as i am returning from view or grid..

Everytime i try to update  the grid row the CableInfoID is 0 

  public ActionResult Cables_Update([DataSourceRequest] DataSourceRequest request, CableViewModel product, int ToolRecID, string toolID, string Empltext)
        {
            if (ModelState.IsValid && product != null)
            {

                // Create a new Product entity and set its properties from the posted ProductViewModel.
                var entity = new DiIpmsCableTeamCableInfo
                {
                    RecordId = product.CableInfoID,
                    CableId = product.CableId,
                    SwitchName = product.SwitchName,
                    Port = product.Port,
                    TechnicianAssigned = Empltext,
                    ToolId = product.ToolID,
                    ToolRecId = ToolRecID,
                    AvailableIp=product.AvailableIp,
                    SubnetMask=product.SubnetMask
                };

                // Attach the entity.
                _db.DiIpmsCableTeamCableInfos.Attach(entity);
                // Change its state to Modified so Entity Framework can update the existing product instead of creating a new one.
                _db.Entry(entity).State = EntityState.Modified;
                // Or use ObjectStateManager if using a previous version of Entity Framework.
                // northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
                // Update the entity in the database.
                _db.SaveChanges();

            }

            // Return the updated product. Also return any validation errors.
            return Json(new[] { product }.ToDataSourceResult(request, ModelState));
        }

 

In the grid  update method 

Alexander
Telerik team
 answered on 14 Aug 2023
1 answer
98 views

When I add input for Id as said here https://docs.telerik.com/aspnet-core/html-helpers/layout/form/hidden-fields

i.Add().Field(f => f.Id).Editor(e => e.Hidden());

I got this text on my

Id:
hidden

How to get rid of it?

Also, I don't see input in the DOM tree, how Id will be transferred to the server?

Mihaela
Telerik team
 answered on 11 Aug 2023
1 answer
399 views
Default handler clears inputs values, but I want to set default values. I can accomplish this with my own handler, but I don't know how to remove default.
Mihaela
Telerik team
 answered on 11 Aug 2023
0 answers
90 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
161 views
Is there way to simply center the items on a Tool bar in the middle of the toolbar. 
Vasko
Telerik team
 answered on 10 Aug 2023
5 answers
261 views

I have a button which opens a window in a razor-page.

The first time I click the button, everything works fine. But when I close the window and click the same button again, the window is not opening.

The button and the window are nested inside a TabStrip.

This is the code for the button and the window:

<div id="tabVoucher">
      <button type="button" id="btnAddVoucher" class="btn btn-default">Create New</button>
      @(
        Html.Kendo().Window()
          .Name("winAddVoucher")
          .Animation(a =>{
            a.Open(o => o.Expand(ExpandDirection.Vertical));
          })
          .Draggable()
          .Actions(ac => ac
            .Minimize()
            .Maximize()
            .Close()
          )
          .Content(@<form method="post" class="needs-validation" novalidate>
            <div class="row">
              <div class="col-12">
                <label for="txbCode" class="form-label">Code</label>
                <input type="text" id="txbCode" class="form-control" required/>
              </div>
            </div>
            <div class="row">
              <div class="col-12">
                <label for="txbFrom" class="form-label">From</label>
                @(Html.Kendo().DateTimePickerFor(d => d.NewVoucher.ValidFrom).ComponentType("modern").HtmlAttributes(new { id = "txbFrom" }).Deferred())
              </div>
            </div>
            <div class="row">
              <div class="col-12">
                <label for="txbTill" class="form-label">Till</label>
                @(Html.Kendo().DateTimePickerFor(d => d.NewVoucher.ValidTill).ComponentType("modern").HtmlAttributes(new { id = "txbTill" }).Deferred())
              </div>
            </div>
            <div class="row mt-3">
              <button type="submit" class="btn btn-default">Create</button>
            </div>
          </form>)
          .Visible(false)
          .Deferred()
      )
    </div>
And this is the js-code for the button-event:
$(document).ready(function () {
      $('#btnAddVoucher').click(function(e){
        $('#winAddVoucher').data('kendoWindow').open();
      });
    });
Any idea why this is not working as expected?
Vasko
Telerik team
 answered on 10 Aug 2023
1 answer
236 views

What is the proper way to increase the size of the star icon for a Rating control? When inspecting the HTML for the control, I can see that the CSS class k-icon-xl is applied to the star icon, but there doesn't appear to be a way to adjust these classes to larger sizes (e.g. apply k-icon-xxl).

As a workaround, I'm overriding k-icon-xl with the following CSS:


.k-icon-xl.k-svg-i-star-outline.k-svg-icon, .k-icon-xl.k-svg-i-star.k-svg-icon {
        width: 48px;
        height: 48px;
    }

 

For reference I'm using the latest release of 2023.2.718.

Vasko
Telerik team
 answered on 10 Aug 2023
1 answer
73 views

That's what I tried:

columns.Command(c => c.Custom("Page").Template("<a href=/Directory/User/${Id}>Page</a>"));

I got:

ReferenceError: Id is not defined in /Directory/Users
Mihaela
Telerik team
 answered on 09 Aug 2023
1 answer
562 views
I found this question, which has an answer on how to implement filter on an object column. But my object can be null, and I can't find a way to bind to its string property or empty string.
Mihaela
Telerik team
 answered on 09 Aug 2023
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?