Telerik Forums
UI for ASP.NET Core Forum
16 answers
1.4K+ views

This worked in .NET 4. not so in Core. Is there an alternative to custom popup templates ???

.ToolBar(toolBar => {toolBar.Create();})
.Editable(e => { e.Mode(GridEditMode.PopUp); e.TemplateName("MaterialEdit");})
.Navigatable()

Viktor Tachev
Telerik team
 answered on 14 Nov 2019
1 answer
586 views

According to the demo at 

https://demos.telerik.com/aspnet-core/grid/paging

the range and total count of items does display in the far right of the grid paging control.  For example, the demo example displays initially "1 - 10 of 830 items".

In my use of the grid pager, it used to work fine just like in the demo with a range and total count of items displayed. But now with the current version 2019.3.1023 of UI for ASP.NET Core, the range and total count of items are no longer displayed with the grid pager.  Have defaults changed?  Or has the feature been removed?

What has changed? Or is it a bug?  Or perhaps just a problem in my hands on my machine?  Does anybody else have this problem?

Thanks, Carl

Alex Hajigeorgieva
Telerik team
 answered on 14 Nov 2019
5 answers
376 views

Im implementing a ViewComponent in a RazorPages application that includes two dropdownlists.  The primary would be returned with the initial view, the 2nd would be called via ajax.

Questions:
- Does the ViewComponent even need a model if I am using using a method in my VC to return data for the primary dropdown?
- If using using RazorPages, what is the syntax for the DataSource read action, which expects an MVC controler name and action?
Since the controller name is the name of the viewcomponent in this case and action would be something like "Handlers?handler=MyMethod

Petar
Telerik team
 answered on 13 Nov 2019
4 answers
286 views

I want to pull a PDF file from a Private/Protected container in Azure.  If it was a public container I could just use a Url.  But, I can't do that so I believe this needs to be pulled following this type of method:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageName);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
 
CloudBlobContainer sourceContainer =
    blobClient.GetContainerReference(
        sourceContainerName);
 
CloudBlockBlob sourceBlob =
    sourceContainer.GetBlockBlobReference(fileName);
 
if (await sourceBlob.ExistsAsync())
{
    // pull the file into memory
    using (MemoryStream stream = new MemoryStream())
    {
        // load the stream from the blob
        await sourceBlob.DownloadToStreamAsync(stream);
        await sourceBlob.FlushAsync();
        stream.Position = 0;
        ...

 

So, this turns the BLOB into a Memory Stream.  Do you have a best-practices example on how I should do this?  If not, do you have an example of how I can load a stream directly into the control.  Better yet, I pull this through a REST service.  Do you have an example on how to request a stream from an API that then loads it into the control?

Thanks for your help,

Joel

 

Martin
Telerik team
 answered on 12 Nov 2019
7 answers
1.9K+ views
Have a set of DropDownLists in a ViewComponent and work fine as is, but how can I display a loading spinner if the process takes a second or two?
Its the 2nd DDL that loads via Ajax which I would like to have the progress indicator display, even if just for a fraction of a second.
I seem to notice that the Grid has this enabled by default?  Where are these properties listed?  Do they just default to enabled?
Can one override the image for the spinner?
Aleksandar
Telerik team
 answered on 12 Nov 2019
1 answer
162 views

I am trying to use the grid and pagers, but I have some requirements to meet that I cannot find how to do.  I need to:

  • Show a pager both at the top and bottom of the grid
  • Have other controls (like a page size selector) next to the pager controls
  • Have a "select exact page" dropdown as part of the pager formatted to look like the attached mockup.

How do I do this with the drid?  This is in .NET Core 3 Razor Pages

Tsvetomir
Telerik team
 answered on 12 Nov 2019
3 answers
99 views

https://demos.telerik.com/aspnet-core/listbox/index

See attached screenshot

 

I'm using Firefox 70 64bit

 

 

Tsvetomir
Telerik team
 answered on 11 Nov 2019
5 answers
925 views

I've got a really strange issue happening.

I've got a DropDownList binding to a remote action in one of my controllers.

When rendering my drop down inside of a asynchronous View Component, the control fails to intialize. No javascript errors, nothing.

I know that the binding is working properly, because as soon as I move the control to a view instead of a view component view, the control initializes fine.

I do not have Deferred() on the control because I know that for partial views the scripts need to be inlined. I am also fairly certain it is not an issue with Deferred, because I have other controls within partial views (not view components) within the app, and the controls load fine.

This issue is specific to asynchronous view components. 

 

This is the control code inside my view component view:

@(Html.Kendo().DropDownList()
    .Name("company-selector")
    .DataTextField("Text")
    .DataValueField("Value")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCompanies", "SuperAdmin");
        });
    })
    .HtmlAttributes(new { style = "width: 100%" })
    )

And this is my controller data binding (again which works fine when control is not inside a view. Also hits a break point even with the control in a view component, but the control isn't initialized)

 

public List<SelectListItem> GetCompanies()
        {
            var companies = _companyRepository.GetCompanies().ToList();
            var companiesSelectList = companies.Select(m => new SelectListItem
            {
                Text = m.Name,
                Value = m.Id.ToString()
            }).ToList();
            return companiesSelectList;
        }

Dimitar
Telerik team
 answered on 11 Nov 2019
3 answers
775 views

1. Is it possible to use a model for the grid definition and another model for the Add/Edit template?

My example:

 

01.@(Html.Kendo().Grid<UserDto>()
02.    .Name("usersGrid")
03. .Editable(e => e.Enabled(true)
04.        .Mode(GridEditMode.PopUp)
05.        .TemplateName("EditUser")
06.        .AdditionalViewData(new {ApiUrl = Model.ApiUrl}))
07.        .DataSource(dataSource =>
08.        dataSource
09.            .Ajax()
10.            .ServerOperation(true)
11.            .Model(model =>
12.            {
13.                model.Id(p => p.Id);
14.                model.Field(p => p.Created).Editable(false);
15.            })
16.            .Read(read =>
17.                read.Url(Model.ApiUrl + "/users/get")
18.                    .Type(HttpVerbs.Get)
19.                )
20.            .Create(acc => acc.Url(Model.ApiUrl + "/users/create")
21.                .Type(HttpVerbs.Post)
22.                )
23.            .Update(acc => acc.Url(Model.ApiUrl + "/users/update")
24.                .Type(HttpVerbs.Put)
25.                )
26.            .Destroy(acc => acc.Url(Model.ApiUrl + "/users/delete")
27.                .Type(HttpVerbs.Post)
28.                )

 

 

 

 

EditUser.cshtml:

 

1.@model CreateUserModel
2. 
3.    <input type="hidden" asp-for="Id"/>

 

 

 

The reason I'm asking is that the 2 models have different columns, the grid model has more columns, needed for display. The edit model has columns for edit, metadata for edit.

 

 2. Is it possible to attach and send a parameter to the datasource CRUD actions when the action has Url instead of Action name, Controller Name?

 

1..Update(acc => acc.Url(Model.ApiUrl + "/users/update")
2.                .Type(HttpVerbs.Put)
3.                )
Veselin Tsvetanov
Telerik team
 answered on 08 Nov 2019
1 answer
83 views

     I have a grid that is defined as such:

@(Html.Kendo().Grid<JohnstonePortal.Data.Entities.Announcement>()
                    .ToolBar(tools =>
                    {
                        tools.Create();
                    })
                   .Name("grdAnnouncements")
                   .AutoBind(true)
                   .Events(x=> x.Edit("onEdit"))                       
                    .ToolBar(tools =>
                    {
                        tools.Search();
                    })
                   .Columns(columns =>
                   {
                       columns.Bound(c => c.Text).Width(500).Title("Announcements");
                       columns.Command(command =>
                       {
                           command.Edit();
                           command.Destroy();
                       }).Width(250);
                   })
                 .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("_EditAnnouncement"))
                .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model=>
                {
                model.Id(ann => ann.Id);
                })
                .Read(read => read.Action("AnnouncementsRead", "Announcements"))
                .Create(create => create.Action("AddAnnouncement", "Announcements"))
                .Update(update => update.Action("UpdateAnnouncement", "Announcements"))
                .Destroy(destroy => destroy.Action("DeleteAnnouncement", "Announcements"))
                ))

 

and the controller is defined as:

public IActionResult AddAnnouncement([DataSourceRequest]DataSourceRequest request, Announcement announcement)
     {
         if (ModelState.IsValid)
         {
             _db.Add<Announcement>
                 (new Announcement
                 {
                     DateCreated= DateTime.Now,
                     Text = announcement.Text
                 });            
             _db.SaveChanges();
         }
 
         // Return a collection which contains only the newly created item and any validation errors.
         return Json(new[] { announcement }.ToDataSourceResult(request, ModelState));
     }
 
     public IActionResult UpdateAnnouncement([DataSourceRequest]DataSourceRequest request, Announcement announcement)
     {
         if (ModelState.IsValid)
         {
             var editAnnouncement = _db.Announcements.Single(x => x.Id == announcement.Id);
             editAnnouncement.Text = announcement.Text;
             _db.SaveChanges();
         }
 
         // Return a collection which contains only the updated item and any validation errors.
         return Json(new[] { announcement }.ToDataSourceResult(request, ModelState));
     }

 

The odd thing is, if I update a row when the page loads, it behaves as normal but if I create one and then update another one, It calls the add endpoint first with the original model that was passed the first time to it and then calls the update on the new model that was intended. This obviously results in a duplicate of the first item that was created. I am not sure what I am doing incorrectly here.

Tsvetomir
Telerik team
 answered on 07 Nov 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?