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

I'm using the .NET Core HTMLHelper to instantiate an instance of the tile layout, the problem I'm running into is that the tile widths just shrink instead of reacting like a flex where the cards will stack as the layout gets narrower. Is there a way to do this either via javascript or CSS?

Code:

01.@(Html.Kendo().TileLayout()
02.        .Name("StatsTiles")
03.        .Columns(4)
04.        .Containers(c =>
05.        {
06.            c.Add()
07.                .Header(h => h.TemplateId("header-0"))
08.                .BodyTemplateId("container-0")
09.                .RowSpan(3);
10.            c.Add()
11.                .Header(h => h.TemplateId("header-1"))
12.                .BodyTemplateId("container-1");
13.            c.Add()
14.                .Header(h => h.TemplateId("header-2"))
15.                .BodyTemplateId("container-2")
16.                .RowSpan(3);
17.            c.Add()
18.                .Header(h => h.TemplateId("header-3"))
19.                .BodyTemplateId("container-3")
20.                .RowSpan(3);
21.            c.Add()
22.                .Header(h => h.TemplateId("header-4"))
23.                .BodyTemplateId("container-4");
24.            c.Add()
25.                .Header(h => h.TemplateId("header-5"))
26.                .BodyTemplateId("container-5");
27.            c.Add()
28.                .Header(h => h.TemplateId("header-6"))
29.                .BodyTemplateId("container-6")
30.                .ColSpan(4);
31.        })
32.        .RowsHeight("100")
33.    )

 

I would like to resize the height and width of all of the containers so that at certain breakpoints the Layout changes it's grid setting. Currently it seems that the grid CSS is all being placed inline, so you can't overwrite that with a media query in the CSS. I've also tried using a jQuery function on window resize to set the options of the tile layout, but the layout doesn't change and some of the content within the containers disappears.

Window resize code:

01.$(window).resize(function () {
02.    if ($(window).width() <= 767.98) {
03.        var statTiles = $('#StatsTiles').getKendoTileLayout();
04.        var containers = statTiles.options.containers;
05. 
06.        for (var i = 0; i < containers.length; i++) {
07.            containers[i].colSpan = 1;
08.            containers[i].rowSpan = 1;
09. 
10.            if (i  == 0 || i == 2 || i == 3 || i == 6)) {
11.                containers[i].height = 300;
12.            } else {
13.                containers[i].height = 100;
14.            }
15.        }
16. 
17.        statTiles.setOptions({
18.            containers: containers,
19.            columns: 1
20.        });
21.    }
22.});

 

Thanks in advance,

Nick

Tsvetomir
Telerik team
 answered on 17 Mar 2021
1 answer
95 views
I am trying to add a form inside a hierarchy grid in place of nested grid using clientdetailtemplateid but it's not getting bounded.
Tsvetomir
Telerik team
 answered on 16 Mar 2021
1 answer
228 views

Razor FileManager RootPath

 

How do I set the RootPath in the Core FileManager to use an Uploads folder that already exists?  Is this done in the cshtl page of the cshtml.cs page?  

 

 

 

 

 

Ianko
Telerik team
 answered on 16 Mar 2021
5 answers
581 views

Hi

 

 

.... bla bla bla

.EventTemplate(

        "<div class='eventItem' style='margin-left: 10px;'>" +

        "<label class='mt-checkbox mt-checkbox-outline'>" +
        "#= kendo.toString(start, 'HH:mm') # - #= kendo.toString(end, 'HH:mm') #"+
        "        <input  type='checkbox' onchange='onCheckboxChange(#=Id#,#=kendo.toString(uid)#)'  #=data.cancelled ? checked='checked' : ''#  class='input-small'> #= title # Seç" +
        "        <span></span>" +
        " </label>"+

 "</div>"
)
.DataSource(d => d
           .ServerOperation(true)
           .Read(m => m.Action("Takvimler_Read", "Kullanici", new { area = "Yonetim" }).Data("GetSchedulerData"))
))

 

.... bla bla bla

 

view in code inspector

<input type="checkbox" onchange="onCheckboxChange(1916,05d45395-b80b-4eb1-9700-80c1d7592f0c)" class="input-small">

function

 

    function onCheckboxChange(Id, Uid) {
        console.log("CheckboxChange Id", Id)
        console.log("CheckboxChange Uid", Uid)
    }

 

error

When the checkbox is clicked, an error occurs while passing the Uid value to the function with the parameter.

Uncaught SyntaxError: Invalid or unexpected token

 

 

Petar
Telerik team
 answered on 16 Mar 2021
4 answers
143 views

Hi,

I thought I should let you know that the issue with Fire Fox and the Editor, where it is unable to get focus if not shown on the page initially is still present in Firefox 68.4.1esr. This is an asp.net core 3.1 app using UI for asp.net Core v2019.3.1023

The js refresh fix  as described here https://www.telerik.com/forums/editor-issues-with-firefox-17 fix still works.

For me, I have the Editor embedded in a Tab page and I am triggering the refresh within the onShow client event.

<div class="form-row">
       <div class="form-group col-md-12">
           <label class="control-label">Event Text</label>
 
           @(Html.Kendo().Editor()
                 .Name("editor")
                 .HtmlAttributes(new { style = "height:200px", required="required" })
                 .Tools(tools => tools
                     .Clear()
                     .Bold().Italic().Underline().Strikethrough()
                     .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
                     .InsertUnorderedList().InsertOrderedList()
                     .Outdent().Indent()
                     .SubScript()
                     .SuperScript()
                     .CleanFormatting()
                 )
                 .StyleSheets(css => css
                   .Add(Url.Content("~/css/editorBase.css"))
                 )
           )
       </div>
   </div>

 

function onShow(e) {
           if (currentIndex == 2 && !isMovingBack) {
               setTimeout(refreshEventGrid(), 50);
               jQuery("#selectedEventDefinition").val("");
           }
 
            if (currentIndex == 3 && !isMovingBack) {
                   setTimeout(function () {
                       var editor = jQuery('#editor').data("kendoEditor");
                       editor.refresh();
                   }, 50);
           }
 
           progress.value(currentIndex + 1);
 
       }

 

I'm not sure if there is anything you can do to address this as it seems to be a Firefox issue. I did find a bugzilla reference mentioned in a post somewhere but that points to a very old closed bug: https://bugzilla.mozilla.org/show_bug.cgi?id=254144

 

Thanks

Chris

 

Veselin Tsvetanov
Telerik team
 answered on 15 Mar 2021
2 answers
238 views

Hi

I am using .net core Razor pages and want to add an image browser to an email editor.

The page has an anti-forgery token and other elements on the page use ajax to pass this to the page behind to process data.

Initially when I was trying to call the image browser in a similar way I was getting 400 errors. I then added the attribute [IgnoreAntiforgeryToken(Order = 1001)] to the code behind and was able to hit the code. This is the razor code I am using in order to generate the editor.

 

 @(Html.Kendo().Editor()
       .Name("email-editor")
       .HtmlAttributes(new { style = "width: 100%; height: 420px" })
       .Tools(tools => tools
                  .Clear()
                  .Bold().Italic().Underline()
                  .JustifyLeft().JustifyCenter().JustifyRight()
                  .InsertUnorderedList().InsertOrderedList()
                  .Outdent()
                  .Indent()
                  .CreateLink().Unlink()
                  .InsertImage())
                  .ImageBrowser(imageBrowser => imageBrowser
                  .Image("~/Content/UserFiles/Images/{0}")
                  .Transport(t =>
                  {
                      t.Read(r => r.Url("./EmailOverview?handler=ReadImage"));
                  })

))

 

This is the most basic method in the code behind so I can call it.
public async Task<JsonResult> OnPostReadImage()
 {
            return new JsonResult(true);
}

 

Is there some syntax I can use to pass in an anti-forgery token with the call. Or can I pass in some additionally parameters with jquery?

 

Many thanks

   

Ianko
Telerik team
 answered on 15 Mar 2021
1 answer
375 views

Hi,

I have a grid, where the column is rendered via ClientRowTemplate, and on that template, I have 3 buttons, that should open 3 different pop-ups (similar to popUp Edit).

.Editable(editable => editable<br>            .Mode(GridEditMode.PopUp)<br>            .Window(w =><br>            {<br>                w.HtmlAttributes(new { @class = "csa-edit"});<br>                w.HtmlAttributes(new { style = "height: 200px;" });<br>                w.Height(200);<br>                w.Width(500);<br>                w.Title("Customer Validation");<br>                w.Events(v =><br>                    v.Open("OnEditStart")<br>                        .Activate(@<text>function () { console.log("EditWindow.Activate") }</text>));<br>                }))

 

I've tried this, but it's not what I exactly need, because I need to have customized templates for each button. 

Can you point me some article or demo ?

Any help would be highly appreciated. 

Best regards,

Manuel

Nikolay
Telerik team
 answered on 12 Mar 2021
1 answer
149 views

Hi,

 

I have a grid with nested property 'OrderName'. Not all rows have the OrderName but this is no problem.  Everything works perfect till I want to delete row and this row does not have the OrderName (there is no reference to a Order table/object).

I get the error:

Cannot set property 'OrderId' of null

    at Object.eval [as Order.OrderId] (eval at setter (kendo.all.js:2138), <anonymous>:3:16)

Schema definition:

<schema>
<model id="Id">
<fields>
                            <field name="CreateDate" type="date"></field>
                       
                            <field name="UserName" from="CustomerUser.Name"></field>
                            <field name="AnswerDate" type="date"></field>
                       
                            <field name="OrderName" from="Order.OrderId" default-value="String.Empty"></field>

<field name="Direction" type="number"></field>
<field name="CustomerName" from="Customer.Name" default-value="String.Empty"></field>
</fields>
</model>
</schema>

 

Column definition:

<column field="OrderName" width="150" title="@SharedLocalizer["grid_column_order"].Value" template="@($"# if(OrderId !== null) {{#  <a class='underline' href='{Url.Action("Detail", "Orders")}/#= OrderId #'>#= OrderName #</a>#}}#")"></column>

 

Delete function:

grid.dataSource.remove(dataItem); 
grid.dataSource.sync();

 

Georgi Denchev
Telerik team
 answered on 12 Mar 2021
4 answers
1.8K+ views

Hi,

 

I'm trying to use an Upload component on a .Net Core 2.2 Razor Pages project, I have a form to edit a record, where I would like to add a file as a an attachment.

I've been trying 2 difference methods to achieve this.

 

Method 1 - To a Controller

I've been able to get the below to upload a file to a controller, where I can convert to a byte array to eventually try and save to a database.

Component

@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .Save("SaveAsync", "Upload")
        .Remove("Remove", "Upload")
    )
    .Validation(validation => validation.AllowedExtensions(new string[] { ".gif", ".jpg", ".png" }))
)

 

Controller 

public async Task<ActionResult> SaveAsync(IEnumerable<IFormFile> files)
       {
           if (files != null)
           {
               foreach (var file in files)
               {
                   if (file.Length > 0)
                   {
                       using (var ms = new MemoryStream())
                       {
                           await file.CopyToAsync(ms);
                           var fileBytes = ms.ToArray();
                           string s = Convert.ToBase64String(fileBytes);
                       }
                   }
               }
           }
           return Content("");
       }

 

Problem:  I don't know how pass the records ID when the files are passed to the controller, so I can save the Byte Array to the correct record. How do I include a parameter?

 

Method 2 - Via Code Behind (Ideal)

The ideal method as this is a razor pages app, is to pass the files to a handler on the code behind, so I have the Record ID available, I've moved the SaveAsync Task to the Razor page code behind, but I can't get it to trigger when the file is uploaded.

So far, I've tried the below to call the OnPostSaveAsync Handler

@(Html.Kendo().Upload()
            .Name("files")
            .Async(a => a
                .SaveUrl("/Case/Edit?handler=SaveAsync")
                .Remove("Remove", "Upload")
            )
            .Validation(validation => validation.AllowedExtensions(new string[] { ".gif", ".jpg", ".png" }))
        )

 

public async Task<ActionResult> OnPostSaveAsync(IEnumerable<IFormFile> files)
       {
           if (files != null)
           {
               foreach (var file in files)
               {
                   if (file.Length > 0)
                   {
                       using (var ms = new MemoryStream())
                       {
                           await file.CopyToAsync(ms);
                           var fileBytes = ms.ToArray();
                           string s = Convert.ToBase64String(fileBytes);
                       }
                   }
               }
           }
           return Content("");
       }

 

Problem:  It doesn't trigger the handler.. Can you see what I'm missing/done wrong? If passing the razor code behind isn't possible, how would I pass a parameter of the record ID to the controller, using the MVC method?

 

Thanks in advance for any help on this, we've only recently purchased DevCraft and I'm hoping it's something simple! 

 

Mark

 

Dimitar
Telerik team
 answered on 12 Mar 2021
5 answers
203 views

I need an example on how to pull a file from Azure to view in this control and to limit the functionality in the ImageEditor to not allow upload and download.  I use your PDF Viewer so based on that example, this is what I have:

Controller:

        [HttpGet]
        public async Task<FileStreamResult> DownloadFileFromBlobStorage(int id)

        {

        ...

                                    if (currentContainer.Container != null)
                                    {
                                        BlobContainerClient blobContainerClient =
                                            currentContainer.Container.Name.GetContainer();

                                        if (await blobContainerClient.ExistsAsync())
                                        {
                                            if (await blobContainerClient.BlobExists(currentContainer.Path))
                                            {
                                                Stream stream =
                                                    await blobContainerClient.GetStream(
                                                        currentContainer.Path);
                                                stream.Position = 0;

                                                return File(stream, contentType);
                                            }
                                            else
                                            {
                                                throw new Exception("File not found in Azure container for this record");
                                            }
                                        }
                                        else
                                        {
                                            throw new Exception(
                                                $"Unable to capture Azure container: {currentContainer.Container.Name}");
                                        }
                                    }

        }

 

View:

pdfViewer works... I need help with the imageEditor:

    @if (Model.Item.Extension.ToLower() == Glossary.PdfExtension)
    {
        <div>
            @(Html.Kendo().PDFViewer()
                .Name("pdfviewer2")
                .PdfjsProcessing(pdf => pdf.File(""))
                .Toolbar(toolbar =>
                {
                    toolbar.Items(items =>
                    {
                        items.Add().Name("pager");
                        items.Add().Name("spacer");
                        items.Add().Name("zoom");
                        items.Add().Name("toggleSelection");
                        items.Add().Name("spacer");
                        items.Add().Name("search");
                        items.Add().Name("download");
                        items.Add().Name("print");
                    });
                })
                )
        </div>
    }
    else if (Model.Item.Extension.ToLower() == Glossary.PngExtension)
    {
        <div>
            @(Html.Kendo().ImageEditor()
                .Name("imageEditor")
                .Height(900)

... how to load image from FileStreamResult
                )
        </div>
    }

View Script:

    $(document).ready(function() {
        var pdfViewer = $("#pdfviewer2").data("kendoPDFViewer");

        // pdfViewer is not rendered unless the file extension is PDF
        if (pdfViewer != null) {
            var handlerUrlPdf = "/Pdfs/DownloadFileFromBlobStorage/" + @Model.Item.Id + "/" + @Glossary.Pdf;
            pdfViewer.fromFile(handlerUrlPdf);
        }

        var imageViewer = $("#imageEditor").data("kendoImageEditor");

        if (imageViewer != null) {
            var handlerUrlPng = "/Pdfs/DownloadFileFromBlobStorage/" + @Model.Item.Id + "/" + @Glossary.Image;
            imageViewer.fromFile(handlerUrlPng);
        }
    });

Ianko
Telerik team
 answered on 11 Mar 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?