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

I'm trying to implement an upload into a window.

this is a code

<!-- >> IMPORT EXCEL-->
 
@{Html.Kendo().Window()
          .Name("importExcelFileWindow")
          .Title("Importa file Excel")
          .Width(500)
          .Height(300)
          .Content(@<text>
        @using (Html.BeginForm("ImportExcelFile", "UploadContacts", FormMethod.Post))
        {
            @(Html.Kendo().Upload()
                                .Name("excelFiles")
                                .Validation(v=>v.AllowedExtensions(new string[] { ".xlsx", ".xls" }))
                                .Async(a => a
                                    .Save("Async_Save", "UploadContacts")
                                    .Remove("Async_Remove", "UploadContacts")
                                    .AutoUpload(true)
                                ).Events(e=>e.Error("uploadError"))
                                )
        }
        </text>)
.Visible(false)
.Render();
}
<script>

function uploadError(e) {
        alert(e.XMLHttpRequest.response);
    }

[...]

<!-- << IMPORT EXCEL-->

 

 

this is a controller

public class AsyncUploadContactsController : Controller
    {
        public IWebHostEnvironment HostingEnvironment { get; set; }
        public string incomingFolder { get; set; }
        private readonly BusinessDbContext _context;
 
        public AsyncUploadContactsController(IWebHostEnvironment hostingEnvironment, BusinessDbContext context)
        {
            HostingEnvironment = hostingEnvironment;
            _context = context;
 
            incomingFolder = "App_Data";
        }
 
        [HttpPost]
        public ActionResult ImportExcelFile()
        {
            return View();
        }
 
        public async Task<ActionResult> Async_Save(IEnumerable<IFormFile> files)
        {
            if (files != null)
            {
                foreach (var file in files)
                {
                    var fileContent = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
 
                    var fileName = Path.GetFileName(fileContent.FileName.ToString().Trim('"'));
                    var physicalPath = Path.Combine(HostingEnvironment.WebRootPath, incomingFolder, fileName);
 
                    using (var fileStream = new FileStream(physicalPath, FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                }
            }
 
            // Return an empty string to signify success
            return Content("");
        }
 
        public ActionResult Async_Remove(string[] fileNames)
        {
            // The parameter of the Remove action must be called "fileNames"
 
            if (fileNames != null)
            {
                foreach (var fullName in fileNames)
                {
                    var fileName = Path.GetFileName(fullName);
                    var physicalPath = Path.Combine(HostingEnvironment.WebRootPath, incomingFolder, fileName);
 
                    if (System.IO.File.Exists(physicalPath))
                        System.IO.File.Delete(physicalPath);
                }
            }
 
            // Return an empty string to signify success
            return Content("");
        }
    }

 

when I open the window and I try to upload a file, I obtain this effect (attached screen-shots)

 

The strange thing is that if I set a breakpoint into actions, I notice that it doesn't go into an action AsynchSave.

I create App_Data folder into wwwroot node's project (is it corrects?

Where I wrong?

 

Dario
Top achievements
Rank 1
Veteran
 answered on 19 Jun 2020
2 answers
129 views

Is there a place where I can see all of the tool names for the Tag Helpers?

I can't seem to get the TableEditing or the SuperScript tool too show. They both just say "undefined".

Johannes
Top achievements
Rank 1
Veteran
 answered on 18 Jun 2020
4 answers
136 views

Hi,

I am experiencing an odd behavior when using the .NoRecords() function of the grid.  If I add .NoRecords() the height of the grid auto sizes to an extreme height beyond the view screen height when there are no records.  If there are records, then the grid auto sizes appropriately.  If I remove .NoRecords() then the grid is collapsed to a reasonable height when no records are available.  I have not had this issue with previous versions.  Using Developer Tools for the browsers I cannot see any .css file that is applying any height value that would be causing this issue.  Is this a known issue, working as intended or am I missing something?

I am using version 2020.2.513.

Thanks.

Rick
Top achievements
Rank 1
 answered on 18 Jun 2020
2 answers
1.5K+ views
@(Html.Kendo().Grid<ViewModel>(Model)<br>               
    .Name("UserGrid")<br>               
    .Columns(columns =><br>               
    {
         columns.Bound(p => p.Name);
         columns.Bound(p => p.Status);
    columns.Bound(p => p.Id);<br>                })<br>                .Pageable(pager => pager.PageSizes(new[] { 10, 20, 50, 100 }))<br>                .Sortable(sortable => sortable<br>                    .AllowUnsort(true)<br>                    .SortMode(GridSortMode.MultipleColumn)<br>                    .ShowIndexes(true))<br>                .Filterable()<br>                )
Ivan Danchev
Telerik team
 answered on 18 Jun 2020
3 answers
293 views

How do I refer to a model property value in the template? I have:

<div class="k-content">
    @(Html.Kendo().ListView<MemberSkillModel>()
        .Name("listViewSkills")
        .TagName("div")
        .ClientTemplateId("skillstemplate")
        .BindTo(@Model.MemberSkills)
        )
</div>

 

and

<script type="text/x-kendo-tmpl" id="skillstemplate">
    <div class="k-widget" style="border:0px">
        <div class="row">
            <div class="col-12">
                #:Name#
                @if (@Model.MemberSkills.ExpiryDate != null)
                {
                    @:(exp kendo.toString(ExpiryDate, "MMMM dd, yyyy")#)
                }
            </div>
        </div>
    </div>
</script>
 

Obviously @Model.MemberSkills.ExpiryDate throws an error as it needs a model item instead of the entire model contents.

Tsvetomir
Telerik team
 answered on 18 Jun 2020
1 answer
163 views

Hi, My kendo inline grid is not calling the update method in controller, when any of its fields is autopopulated dynamically.

I am not manually editing any of the fields in the particular row, instead the fields are getting automatically populated. And on update click I need to do validation in server controller method .But unfortunately the control is not going to the server method on update button click.

Can someone help me to resolve this,

 

Ivan Danchev
Telerik team
 answered on 17 Jun 2020
2 answers
269 views

Hello,

 

I'm using ASP.NET Core 2.1 and trying to get a Pie chart bound to a remote datasource based on this example:  https://demos.telerik.com/aspnet-core/pie-charts/remote-data-binding.  I can't get anything except the "Title" to show. The pie never displays. (FYI, the pie chart works fine for hardcoded data.)  I know the controller works as I'm getting response data in the format I expect.  Here's some streamlined code:

Here's my view:

    @(Html.Kendo().Chart<WT.Models.Cars>()
        .Name("chart1")
.Title(title => title.Text("Title").Position(ChartTitlePosition.Top))
        .DataSource(ds => ds.Read("CarTotals_PieChart", "Output"))
        .Series(series => series.Pie(model => model.NumCars, model => model.CarManu))
        )

Here's my model:

public class Cars
{
    public string CarManu{ get; set; }
    public int NumCars { get; set; }
}

Here's my response JSON data:

{"Data":[{"CarManu":"GM","NumCars":167},{"CarManu":"Ford","NumCars":120},{"CarManu":"Mazda","NumCars":60},{"CarManu":"Ferrari","NumCars":19}],"Total":4,"AggregateResults":null,"Errors":null}

 

I've seen other posts related to this exact same (issue but never a resolution.  What am I doing wrong? Thanks in advance.

Werdna
Top achievements
Rank 1
 answered on 17 Jun 2020
2 answers
81 views

Hello,

in a Telerik RadGrid (web) I need to merge some cell rows like the attached image, 
and change the font color based on values in these cells.

Has anyone idea how to make this?

Thanks a lot. 

Luis

Luis
Top achievements
Rank 1
Veteran
 answered on 17 Jun 2020
1 answer
165 views
Is it possible to have Filename, Error events and validation with synchronous mode? I have a form where i need the upload to happen on form submit for the additional information and would like these options. Is it possible? 
Aleksandar
Telerik team
 answered on 16 Jun 2020
3 answers
218 views

I'm using Asp.net core razor pages with custom column settings.  The client wants to block users from navigating off the page when there is a row in edit mode. Is there a suggested way to do this that doesn't involve jquery? Every example I've found so far is under jquery. Ideally, the client should be told with some kind of message the reason for preventing page close. 

 

Ivan Danchev
Telerik team
 answered on 15 Jun 2020
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?