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

My controller will start several async method, then my cshtml will show a long time white page. I do not want it.

I want to add a a Indeterminate ProgressBar when these async task is running, and when the task is completed, I want to hide this progressbar.

Thanks.

Xavier

Ivan Zhekov
Telerik team
 answered on 26 Dec 2017
1 answer
374 views

I am creating a data-entry page on an ASP.NET MVC Core application using EF Core.

I am using ViewData to populate the ComboBox. 

public IActionResult Add()
{
     ViewData["CostCenterID"] = _context.CostCenters.ToList();
     ViewData["ReasonCodeID"] = _context.ReasonCodes.ToList();
     ViewData["ShiftID"] = _context.Shifts.ToList();

     return View();
}

The razor view for one of the combo boxes looks like this:

 <div class="form-group">

            @Html.LabelFor(model => model.Shift, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @(Html.Kendo().ComboBoxFor(model => model.Shift.ShiftID)
                        .HtmlAttributes(new { @class = "form-control", @style = "width: 35%;" })
                        .Placeholder("Select a shift...")
                        .DataValueField("ShiftID")
                        .DataTextField("Name")
                        .BindTo((System.Collections.IEnumerable)ViewBag.ShiftID)
                )

                <span asp-validation-for="Shift" class="text-danger"></span>
            </div>
        </div>

 

When I save the form, the Shift property is set and the ShiftID property is still 0. There are a total of 5 combo boxes on this form. One is used just to cascading another combo box. That combo box sets the Entity property as well, and that two needs the ID set. I figure once one gets solved the rest will fall in place. If I use regular select objects with asp-for properties it works, but I want to use the Telerik controls.

The save method looks like this:

[HttpPost]
[ValidateAntiForgeryToken]

        public async Task<IActionResult> Add(DownTimeEntry downTimeEntry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(downTimeEntry);
                await _context.SaveChangesAsync();
                return RedirectToAction(nameof(Index));
            }

            ViewData["CostCenterID"] = _context.CostCenters.ToList();
            ViewData["ReasonCodeID"] = _context.ReasonCodes.ToList();
            ViewData["ShiftID"] = _context.Shifts.ToList();

            return View(downTimeEntry);
        }

 

Any help on this would be appreciated!

Veselin Tsvetanov
Telerik team
 answered on 22 Dec 2017
3 answers
115 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
210 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
303 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
775 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
621 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
339 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
420 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
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?