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

Hi,

I have a a grid with inline editing and I am applying templates to each of the controls when editing through uiHints on my viewmodel.

Updating worked fine before implementing virtual scrolling, however after I added the virtual scrolling I am getting null reference errors in the console.

the console error is as follows:

Uncaught TypeError: Cannot read property 'Description' of null
    at eval (eval at getter (kendo.all.min.js:25), <anonymous>:3:22)
    at init.set (kendo.all.min.js:28)
    at init.change (kendo.all.min.js:29)
    at init.proxy (jquery-2.2.4.js:497)
    at init.trigger (kendo.all.min.js:25)
    at init._change (kendo.all.min.js:65)
    at HTMLInputElement.<anonymous> (kendo.all.min.js:65)
    at HTMLInputElement.dispatch (jquery-2.2.4.js:4737)
    at HTMLInputElement.elemData.handle (jquery-2.2.4.js:4549)
    at Object.trigger (jquery-2.2.4.js:7807)

My viewModel with ui hints looks like: 

public class FolderRetentionConfigViewModel
    {
        
        public int FolderRetentionConfigId { get; set; }
        public int SubSubId { get; set; }
        public int CaLocationId { get; set; }
        [UIHint("FolderRetentionConfigRetentionCodeTemplate")]
        public int? RetentionCodeId { get; set; }
        
        public string Description { get; set; }
        [UIHint("FolderRetentionConfigActivePeriodTemplate")]
        public int? ActivePeriod { get; set; }
        [UIHint("FolderRetentionConfigInActivePeriodTemplate")]
        public int? InactivePeriod { get; set; }
        public string TotalRetention { get; set; }      
        public string Caid
        {
            get
            {
                return this.SubSub.Title  + this.SubSub.Adcode + this.SubSub.Adsubcode;
            }
        }
 
        public CaLocations CaLocation { get; set; }
 
         
        public RetentionCodes RetentionCode { get; set; }
        public SubSubCategories SubSub { get; set; }
         
 
    }

 

and the the template files that the UI Hints are referencing  look like this 

@model IMSCore.ViewModels.FolderRetentionConfigViewModel
@{ 
    EditTemplateHelper etHelper = new EditTemplateHelper(ViewData);
}
 
<div>
    @(Html.Kendo().MaskedTextBox()
        .Name("Description")      
    )

</div>

 

And my grid looks like this:

@(Html.Kendo().Grid<IMSCore.ViewModels.FolderRetentionConfigViewModel>()
       .Name("gridFolderRetentionConfig")
       .HtmlAttributes(new { @class = "container-fluid no-padding" })
       .Columns(columns =>
       {
           columns.Bound(c => c.Caid).Width(110);
           columns.Bound(c => c.Description);
           columns.Bound(c => c.RetentionCodeId).ClientTemplate("<div><span> " +
                       "#if(data.RetentionCode != null) { # #:data.RetentionCode.RetentionCode # # } # " +
                       "</span></div>");
           columns.Bound(c => c.ActivePeriod);
           columns.Bound(c => c.InactivePeriod);
           columns.Command(command => { command.Edit();  }).Width(EditTemplateHelper.COMMAND_WIDTH);
       })      
       .Scrollable(scrollable => scrollable.Virtual(true))
       .Sortable()
       .Editable(editable =>
       {
           editable.Mode(GridEditMode.InLine);
       })
       .Events(e =>
       {
           //e.Edit("FolderRetentionConfigEditing");
           //e.Save("onGridSave");
           //e.SaveChanges("onGridSave");
       })
       .DataSource(dataSource => dataSource
           .Ajax()
           .PageSize(20)
           .Model(m =>
           {
               m.Id(pl => pl.FolderRetentionConfigId);
               m.Field(p => p.Caid).Editable(false);
 
           })
           .Read(read => read.Action("GetFolderRetentionDefaults_Post", "FolderRetentionsApi"))
           .Update(update => update.Action("UpdateFolderRetentionDefaults", "FolderRetentionsApi"))
           )
   )

 

 

Konstantin Dikov
Telerik team
 answered on 21 Dec 2017
2 answers
207 views

Hi,

In the absence of a dedicated spot for map questions I'll just post my question here:

If we look at the example code take from here:

@(Html.Kendo().Map().Name("map").Center(30.268107, -97.744821).Zoom(15).Layers(layers =>{         layers.Add().Type(MapLayerType.Tile).UrlTemplate("http://tile2.opencyclemap.org/transport/#= zoom #/#= x #/#= y #.png").Subdomains("a", "b", "c").Attribution("&copy; <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>." +"Tiles courtesy of <a href='http://www.opencyclemap.org/'>Andy Allan</a>");         layers.Add().Type(MapLayerType.Marker).DataSource(dataSource => dataSource
                  .Read(read => read.Action("_StoreLocations", "Map"))).LocationField("LatLng").TitleField("Name");}))

 

My question is this - in the scenario of using Core Razor Pages we do not have a Controller Action as such.

Could I please if it is possible have a modified sample like the one above except to show using data-source using the new Razor Pages model?

Thanks for your time,

John

John
Top achievements
Rank 1
 answered on 19 Dec 2017
1 answer
300 views

Hi,

we have a problem with filtering when grid column is binded to the complex type.

Below you can find the makup for the problematic column and DataSource:

columns.Bound(m => m.PaymentMethod.Name).Title("Payment Method").Width(100)
               .Filterable(filterable => filterable.Operators(operators => operators.ForString(str => str.Clear().Contains("contains").IsEqualTo("equals"))));

.DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(true)
        .PageSize(20)
        .Model(model =>
        {
            model.Id(id => id.IdPayment);
            model.Field(m => m.PaymentMethod).DefaultValue(new PaymentMethodViewModel());
            model.Field(m => m.PaymentStatus).DefaultValue(new PaymentStatusViewModel());
        })
        .Read(read => read.Action("Read", "Payments"))
        .Create(create => create.Action("Create", "Payments"))
        .Update(update => update.Action("Update", "Payments"))
        .Destroy(destroy => destroy.Action("Delete", "Payments"))
    )

When we filter for the first time everything works OK, the correct set of data is returned.

But something breaks the filter button. When we clik the filter button for the second time, filter menu window doesn't show up and there is a JS error in console:

 

Błąd mapy źródła: TypeError: this.worker is null
URL zasobu: null
URL mapy źródła: null
[Więcej informacji]
Error: Syntax error, unrecognized expression: [data-field=PaymentMethod.Name]

 

Does Grid for Asp.Net Core supports filtering on complex types?

Stefan
Telerik team
 answered on 19 Dec 2017
5 answers
761 views

Hello,

If I change the value of a field which is grouped in the grid (Popup Edit) and save it, the grid does not reflect the changed row in the correct group...

to use grid.refresh() doesn't help - is it necessary to Reload the grid in such a case?

robert

Stefan
Telerik team
 answered on 18 Dec 2017
1 answer
613 views

While running the demo at http://demos.telerik.com/aspnet-core/multiselect/serverfiltering I noticed that the MultiSelect is passing filter query string parameters.

For example, searching for chef sends the following parameters:

text: chef
filter[filters][0][value]: chef
filter[filters][0][field]: ProductName
filter[filters][0][operator]: startswith
filter[filters][0][ignoreCase]: true
filter[logic]: and

However the example ignores the filter parameters and implements a contains filter in the controller:

public JsonResult GetProducts(string text)
{
    products = products.Where(p => p.ProductName.Contains(text));

 }


Can the filter parameters be bound to a model? Is there an existing Telerik filter model class that can be used?
Dimitar
Telerik team
 answered on 15 Dec 2017
17 answers
1.3K+ views

The attached image shows the error for a aspnetcore 2.0 project targeting 461 trying to do server side filtering on a grid, you will get a 500.

public ActionResult CustomerRead([DataSourceRequest] DataSourceRequest request)

{

}

 

Anyone else running into this issue?

Bozhidar
Telerik team
 answered on 15 Dec 2017
3 answers
333 views
I have a kendo grid as below :

@(Html.Kendo().Grid(Model)
              .ToolBar(toolbar =>
              {
                  toolbar.Create().Text("Add attachment");
                  toolbar.Save().SaveText("Save").CancelText("Cancel");
              })
              .Name("AttachmentsGrid")
              .Columns(columns =>
              {
                  columns.Bound(p => p.Id).Title("ID").Width(20);
                  columns.Bound(p => p.AttachmentType).Title("Type").Width(100).EditorTemplateName("AttachmentTypeDropDown").ClientTemplate("#:AttachmentType#");
                  columns.Bound(p => p.AttachmentPath).Title("Attachments").Width(200).EditorTemplateName("UploadAttachments")
                      .ClientTemplate("<a href='" + Url.Action("DownloadAttachment", "Utility", new { fileName = "#=AttachmentPath#" }) + "'/>" + "#=AttachmentName#" +"</a>");
                  columns.Bound(p => p.LastModifiedBy).Title("Uploaded By").Width(100);
                  columns.Bound(p => p.LastModifiedAt).Title("Uploaded On").Format("{0:dd-MMM-yyyy}").Width(100);

                  columns.Command(command => command.Destroy().Text(" "));
              }))

The column AttachmentPath has a ClientTemplate which allows the user to download the file on click of it.
I have added an Editor Template also which displays Kendo Upload for allowing the user to browse the file for upload.

On click of the column , the download works successfully.
But after that it does not show the hyperlink – it is just displayed as simple text.

If the user wants to download again, the column needs to be sorted or the grid needs to be refreshed
How can I resolve this issue?
Stefan
Telerik team
 answered on 14 Dec 2017
3 answers
417 views

Hello,

I have multiple MultiSelectFor in my view with the same Ajax Datasource - now I want to use the Html.Kendo().DataSource for all of this

MultiSelectFor but it seems this is not possible - is it only possible to use Html.Kendo().DataSource with Grid and Autocomplete like in the sample?

how to share a datasource with multiple MultiSelectFor or FropDownFor?

(I don't want to have multiple requests)

robert

Dimitar
Telerik team
 answered on 13 Dec 2017
3 answers
294 views

Hello,

I want to set a NumericTexbox to work with integer numbers without decimals, but using taghelper didn't work.

This code block shows the number with 2 decimals:
<kendo-numerictextbox for="Id" spinners="false" decimals="0" format="#"/>

But if I use this code block, it works as expected:
@Html.Kendo().NumericTextBoxFor(model => model.Id).Format("#").Decimals(0).Spinners(false)

Thanks

Konstantin Dikov
Telerik team
 answered on 13 Dec 2017
1 answer
517 views

 @(Html.Kendo().Grid<SysRoleModel>
        ()
        .HtmlAttributes("") 
        .AutoBind(true)
        .Name("grid")
        .Selectable(selectable =>//Grid选中设置
        {
            selectable.Enabled(true);//是否可以选中
            selectable.Type(GridSelectionType.Row);//选中行还是单元格;Row为行模式;Incell为单元格模式
            selectable.Mode(GridSelectionMode.Multiple);//选中一行还是可以选中多行;Single为单选;Multiple为多选
        })
        .Columns(columns =>
        {

            columns.Template("<input class=\"box\" id=\"assignChkBx\" name=\"assignChkBx\" title=\"#=RoleName#\" CompanyRole=\"#=CompanyRole#\" type=\"checkbox\" value=\"#=Id#\" onclick=\"selectRow(this)\"/> ")
            .Width(50)
            .ClientHeaderTemplate("<input class=\"selectAll\" type=\"checkbox\" id=\"allBox\" onclick=\"selectAllRow(this)\" /></text>")
            .HeaderHtmlAttributes(new { style = "text-align: center" })
            .HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.RoleName).Title("角色名称").Width(150).HeaderHtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.RoleDescription).Title("角色说明").Width(150).HeaderHtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.Remark).Title("备注").Width(117).HeaderHtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.Enabled).Title("是否有效").Width(117).HeaderHtmlAttributes(new { style = "text-align: center" }).ClientTemplate("#if(Enabled=='1'){#" +
                                              "<span>是</span>" +
                                          "#}else {#" +
                                              "<span>否</span>" +
                                         "#}#").HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.CompanyRole).Title("系统角色").Width(117).HeaderHtmlAttributes(new { style = "text-align: center" }).ClientTemplate("#if(CompanyRole=='1'){#" +
                                                     "<span>是</span>" +
                                                 "#}else {#" +
                                                     "<span>否</span>" +
                                                "#}#").HtmlAttributes(new { style = "text-align: center" });
            columns.Bound(c => c.InDate).Title("录入时间").Width(126).HeaderHtmlAttributes(new { style = "text-align: center" }).Format("{0:yyyy-MM-dd HH:mm:ss}");
        })
        .Pageable(page => page
        .Refresh(true)
        .ButtonCount(10)
        .PageSizes(new[] { 20, 30, 50 })
        .Messages(mess => mess.ItemsPerPage("每页显示数目").Display("显示{0}-{1}条,共{2}条"))
        )//分页设置
        .Sortable()  // 是否支持排序
        .Scrollable(c => c.Height("100%"))
        .HtmlAttributes(new { @class = "k-grid-autoheight" })
        .Events(c => c.DataBound("window.kendoGridAutoHeightDataBound"))
        .PersistSelection()
        .Reorderable(reorderable => reorderable.Columns(true))//是否支持列的拖拽
        .Resizable(resizable => resizable.Columns(true))//设置Grid是否可以手动调整列宽
        .ColumnMenu()
        .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(20)
                    .ServerOperation(true)
                    .Model(model => model.Id(p => p.Id))
                    .Read(read => read.Action("Role_Read", "Role").Data("GetCriteria"))
        )
)

 

Scrollable Properties set 100% Why does not work, I want to make the grid control automatically according to the interface height how to set

 

Stefan
Telerik team
 answered on 08 Dec 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?