Telerik Forums
UI for ASP.NET MVC Forum
1 answer
124 views

Am I missing a configuration option?  I have a menu which has several levels of menus.  With "Security Trimming" enabled, root level objects get trimmed with no issues.  Parents which have their children objects "trimmed", still show up.  Example:

 


@(Html.Kendo().Menu()
                          .Name("Menu")
                          .SecurityTrimming(true)
                          .Items(items =>
                          {
                                items.Add().Text("Home").Action("Index", "Home");
                                items.Add().Text("Owners").Action("Index", "Owners");
                                items.Add().Text("Interred").Action("Index", "Interred");
                                items.Add().Text("Maintenance").Items(itm =>
                                {
                                    itm.Add().Text(@"Sections/Lots/Spaces").Action("Index", "MaintainSpaces");
                                    itm.Add().Text("Search Tags").Action("Index", "MaintainSearchTags");
                                    itm.Add().Text("Undertakers").Action("Index", "MaintainUndertakers");
                                    itm.Add().Text("Reclaim Spaces").Action("Index", "MaintainReclaimSpaces");
                                    itm.Add().Text("Research Tool").Action("Index", "MaintainResearchTool");
                                    itm.Add().Text("Headstones").Action("Index", "MaintainHeadstones");
                                });
                                items.Add().Text("Reports").Items(itm =>
                                {
                                    itm.Add().Text("Available Spaces").Action("Index", "ReportsPage");
                                });
                        })
                )

As you can see the "Maintenance" and "Reports" menu items are still visible.  An example situation would be :

A unauthorized user sees the "Home" button, and everything else should be trimmed.  While the actual actions are getting trimmed, the "Maintenance" and "Reports" menu items (with nothing in them) are still there.

Am I missing a configuration option to also remove parents?

Ivan Danchev
Telerik team
 answered on 03 Jul 2023
1 answer
297 views

Hello,
I've use kendo Grid MVC for my project and want to change the Input type when filter (in one field):

  • choose "Contains" display to input text.
  • choose "Is Equal To" display Select Option.

What i want like the below image: 

 

Have any way to config this ?

My Source Code : 

<script type="text/javascript">

    $(window).resize(function () {
        var gridElement = $("#BudgetApprovalAuditGrid"),
            newHeight = gridElement.innerHeight(),
            otherElements = gridElement.children().not(".k-grid-content"),
            otherElementsHeight = 0;

        otherElements.each(function () {
            otherElementsHeight += $(this).outerHeight();
        });

        gridElement.children(".k-grid-content").height(newHeight - otherElementsHeight);
    });

    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }

    function datePicker(args) {

        args.kendoDatePicker({
            format: "dd/MM/yyyy"
        });
    }

    function GetListDataSetNameFilter(element, fieldName) {
        element.kendoDropDownList({
            dataSource: {
                transport: {
                    read: {
                        url: "@Url.Action("_GetListDataSetNameFilter", "BudgetApprovalAudit")",
                    }
                }
            },
            filter: "Contains",

            optionLabel: "-Select Value-"
        });
    }

    function GetListBudgetNameFilter(element, fieldName) {
        element.kendoDropDownList({
            dataSource: {
                transport: {
                    read: "@Url.Action("_GetListBudgetNameFilter", "BudgetApprovalAudit")",
                }
            },
            filter: "Contains",

            optionLabel: "-Select Value-"
        });
    }
    function GetListApprovalStatusFilter(element, fieldName) {
        console.log("elementelementelementelementelementelementelement>>>>>>>>>>>>>>>>>>>>>>>>", element)
        element.kendoDropDownList({
            dataSource: {
                transport: {
                    read: {
                        url: "@Url.Action("_GetListApprovalStatusFilter", "BudgetApprovalAudit")",
                    }
                }
            },
            filter: "Contains",
            optionLabel: "-Select Value-"
        });
    }
    function OnDataBoundBudgetApprovalAuditGrid(e) {
        //console.log("OnDataBoundBudgetApprovalAuditGrid",e)
        //if ($('#BudgetApprovalAuditGrid tbody .k-grouping-row:contains("DatasetName") td p').length != 0) {
        //    for (var i = 0; i < $('#BudgetApprovalAuditGrid tbody .k-grouping-row:contains("DatasetName") td p').length; i++) {
        //        var tempHTML = $('#BudgetApprovalAuditGrid tbody .k-grouping-row:contains("DatasetName") td p')[i].innerHTML
        //        //do something
        //        //tempHTML


        //        $('#BudgetApprovalAuditGrid tbody .k-grouping-row:contains("DatasetName") td p')[0].innerHTML = tempHTML

        //    }
        //    //$('#BudgetApprovalAuditGrid tbody .k-grouping-row:contains("DatasetName") td p')[0].innerHTML = "Your text";
        //}
    }

</script>

 

<div style="height: calc(100vh - 220px);">
    <div style="height: 900px">
        @(Html.Kendo().Grid(Model)
        .Name(gridId)
        .HtmlAttributes(new { })
        .Columns(columns =>
            {
            columns.Bound(p => p.DatasetName).Title("Dataset Name22222222").ClientGroupHeaderTemplate("#=value#").Width(100)
                                             .Filterable(x => x.UI("GetListDataSetNameFilter").Extra(false).Operators(operators => operators.ForString(str => str.Clear().IsEqualTo("Is Equal To"))));

            columns.Bound(p => p.BudgetName).Title("Budget Name").Width(150).ClientGroupHeaderTemplate("#=value#")
                                            .Filterable(x => x.UI("GetListBudgetNameFilter").Extra(false).Operators(operators => operators.ForString(str => str.Clear().IsEqualTo("Is Equal To"))));
            
            columns.Bound(p => p.ApprovalStatus).Title("Approval Status").Width(300)
                                                .Filterable(x => x.UI("GetListApprovalStatusFilter").Extra(false).Operators(operators => operators.ForString(str => str.Clear().IsEqualTo("Is Equal To"))));
            
            columns.Bound(p => p.ApprovalPath).Title("Full path").Width(300);
            columns.Bound(p => p.UserName).Title("User Name").Width(150);
            columns.Bound(p => p.CompletedUserName).Title("Completed User Name").Width(150);
            columns.Bound(p => p.TimeDateString).Title("Created Date").Width(200)
                                                .Filterable(x => x.Extra(false).Operators(operators => operators.ForString(str => str.Clear().Contains("Contains"))));

            columns.Bound(p => p.CompletedTimeDateString).Title("Completed Date").Width(200)
                                                .Filterable(x => x.Extra(false).Operators(operators => operators.ForString(str => str.Clear().Contains("Contains"))));

            columns.Template(@<text> </text>).Title("&nbsp;");

            })
        .ToolBar(toolbar =>
        {
        toolbar.Template(@<text><a class="k-button" style="opacity:0"></a></text>);
        })
        .DataSource(ds => ds.Ajax().Read("_GetListBudgetApproval", "BudgetApprovalAudit")
        .Events(events => events.Error("error_handler"))
        ).Events(x=>x.DataBound("OnDataBoundBudgetApprovalAuditGrid"))
        .Sortable()
        .Scrollable()
        .Filterable(filterable => filterable
                .Extra(false)
                .Operators(operators => operators
                    .ForString(str => str.Clear()
                        .IsEqualTo("Is Equal To")
                        .Contains("Contains")
                    ))
                )
        .Resizable(resize => resize.Columns(true))
        .Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row)))
    </div>
</div>



Thanks

 
Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 30 Jun 2023
0 answers
108 views

I have a C# ASP.NET MVC application where I populate a Kendo grid with data from an Ajax call.  I need to have one of the grid columns displayed with a dropdown list.  I also need to set the selected value of the dropdown list.

This is the code for the grid:


    @(Html.Kendo().Grid<TaxCertApp.ViewModels.ParcelViewModel>()

      .Name("DetailedParcelGrid")
      .AutoBind(true)
      .Columns(columns =>
      {
          columns.Bound(parcel => parcel.ParcelKey)
               .ClientTemplate("<button type='button' class='btn btn-taxapp btn-primary assesment-taxyear-add' id='btnAddTaxYear'><b>Add Tax Year</b></button>")
               .Title("")
               .Width(200);
          columns.Bound(parcel => parcel.ParcelKey)
                .ClientTemplate("<span class=\"assesment-parcel-edit glyphicon glyphicon-edit\" style=\"color: rgb(40, 96, 144)\"></span></a>")
                .Title("")
                .Width(30);
          columns.Bound(parcel => parcel.LotNo).Title("Lot #").Width(50);
          columns.Bound(parcel => parcel.AssembledTaxDescription).Title("Tax Description").Width(140);
          columns.Bound(parcel => parcel.SchoolDistrict).Title("School District").Width(120);
          columns.Bound(parcel => parcel.ParcelStreetNo).Title("Street Number").Width(110);
          columns.Bound(parcel => parcel.ItemNo).Title("Item").Width(50);
          columns.Bound(parcel => parcel.Class).Width(50);
          columns.Bound(parcel => parcel.ParcelStatusList)
              .Title("Parcel Status")
              .Width(150)
           //   .ClientTemplate("#=SeeList(ParcelStatusList)#");
              .EditorTemplateName("DropDownEditor");

          columns.Bound(parcel => parcel.ParcelNotes).Title("Parcel Notes");

      })
        .Scrollable()
        .HtmlAttributes(new { style = "height:550px;" })
        .ClientDetailTemplateId("template")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(n => n.CaseKey))
            .Read(read => { read.Action("GetDetailedParcelDetails", "Parcel").Data("{ CaseKey: " + @Model.CaseKey + "}"); }))
            .Events(events => events.DataBound("dataBound"))
        )

This is the code in the DropDownEditor.cshtml:


@using System.Collections
@model System.String

@(Html.Kendo().DropDownListFor(m => m)
    .BindTo((IEnumerable)ViewData["ParcelStatusList"])
    .OptionLabel("- Select Parcel Status -")
)

I included an image of the grid that gets generated. I also included an image of the console.log when the code executed the .ClientTemplate code which looks like this:


    function SeeList(parcelStatusList) {

        console.log(parcelStatusList);

        var obj = JSON.stringify(parcelStatusList);

        console.log(obj);

        return parcelStatusList;
    }

Any suggestions on what is preventing the dropdown from displaying properly?

 

Thank you.

 

 

jonathan
Top achievements
Rank 1
Iron
 asked on 28 Jun 2023
1 answer
417 views
Using the UI for ASP.NET MVC 2023.2.606 build and trying to set custom icons for the native grid excel export toolbar item (ref snippet below) - unlike the same build # for MVC CORE the .IconClass "override" setting is not respected and defaults to rendering the pure kendo .svg icon for excel.  Compare the 2 image captures of the rendered html/classes for the same defined toolbar between the ASP.NET MVC and MVC CORE builds


                       .ToolBar(t => {
                            if (PermissionHelper.HasPermissionAny(Roles.RoleAdmin))
                            {
                                t.Create().Text("Add User Role");
                            }
                            t.Excel().Text("Export to Excel").IconClass("fa-solid fa-file-excel");
                        })
Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 26 Jun 2023
1 answer
107 views

Hello, I am dealing with an issue while implementing a hierarchy grid using server binding. I need to access data child in server so I can modify this data as I need. 

I.E. 

columns.Bound(pet => pet.Origen).Width(100).HtmlAttributes( new {@title = item.title});

I would need to display the tooltip I have in my model, but the problem is that "item" reffers to the father row, not the child. How can I get this done?

 

I don't know if I am using the correct approach here, any help would be appreciated.

Thanks and best regards.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 26 Jun 2023
2 answers
305 views

Hi,

 

I am trying to implement same way as ASP.NET Core PDF Export Key Features Demo | Telerik UI for ASP.NET Core

but Its exporting in client side but it's not going to controller. Don't know what mistake I am doing. Is there a way to send the pad to controller and send it to email attachment. Below is my code.


        $("#btnSubmit").on("click", function (e) {
            e.stopPropagation();
            e.preventDefault();
            var sigval = signature.value();
            $('#lblSearchError').text('');
            if (sigval === undefined || sigval === '') {
                $('#lblSearchError').text('*Signature field is required.');
            } else {
                var data = $("#submitForm").serializeArray();
                var obj = { name: 'signature', value: sigval };
                data.push(obj);

                // Convert the DOM element to a drawing using kendo.drawing.drawDOM
                kendo.drawing.drawDOM($("#mainContect"))
                .then(function (group) {
                    // Render the result as a PDF file
                    return kendo.drawing.exportPDF(group, {
                        paperSize: "auto",
                        margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
                    });
                })
                .done(function (data) {
                    // Save the PDF file
                    kendo.saveAs({
                        type: 'POST',
                        dataURI: data,
                        fileName: "Provider.pdf",
                        proxyURL: '@Url.Action("Submit", "Provider")'
                    });
                });
            }
        });

I tried proxyURL AND URL none of them worked. When I clicked on submit button it's just downloading the pdf file. But it not hitting controller.

and in controller 


        [HttpPost]
        public ActionResult Submit(string contentType, string base64, string fileName)
        {
            //if (!ModelState.IsValid)
            //{
            //    data.Id = 0;
            //    return Json(data, JsonRequestBehavior.AllowGet);
            //}

            //var providerData = portalServices.saveProviderData(data);
            //    return Json(providerData, JsonRequestBehavior.AllowGet);

            var fileContents = Convert.FromBase64String(base64);

            return File(fileContents, contentType, fileName);
        }

Babu
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 23 Jun 2023
1 answer
108 views

The Value Axis isn't showing a DateTime like '5/1/2023 10:00 AM' which is the same DateTime format that the data from my stored procedure is using. I'd like the value axis to show each hour of the day.

Attached is a screenshot of the grid. Thanks!

Here's the chart's code:

 @(Html.Kendo().Chart<BatchPlantHourlyOutputViewModel>()
    .Name("chart")
    .Title("Planned Pour Delivery Times vs Actual Pour Delivery Times")
    .Legend(legend => legend
        .Visible(true)
        .Position(ChartLegendPosition.Bottom)
    )

    .DataSource(dataSource => dataSource
        .Read(read => read.Action("GetBatchPlantHourlyOutputGraph", "Production")
        .Data("PSW.UI.getSelectedInputVals(false)")))
        .Events(e => e.DataBound("PSW.Events.Graph.onBatchPlantHourlyOutputGraphDataBound"))

    .Series(series =>
    {
        series.Line(model => model.ScheduledHour)
           .Name("Scheduled Time");

        series.Line(model => model.StartTime)
            .Name("Actual Time");
    })

    .CategoryAxis(axis => axis
        .Categories(model => model.Output)
        .MajorGridLines(lines => lines.Visible(true))
    )

    .ValueAxis(axis => axis
        .Date()      
        .Labels(labels => labels.Format("{0:MM/dd/yyyy hh:mm:ss}"))
        .Line(line => line.Visible(false))
    )
    )
Anton Mironov
Telerik team
 answered on 22 Jun 2023
2 answers
188 views

Hi,

I created a TileLayout with MVC 

@(Html.Kendo().TileLayout()
   .Name("zoneWorkflow").Columns(1)
   .Gap(g => g.Columns(8).Rows(8))
   .Columns(1)
   .Reorderable(true)
   .Resizable(true)
   .HtmlAttributes(new { Title = this.LocalResources("LegendeEtapes") })
   .RowsHeight("auto"))

On the header template I added a button to remove tile with handle to

removeOperationBox(e) { // e is a KendoButton into Header tile
   const itemId = e.sender.element.parents("div[role='listitem']").attr("id");
   const workflow = $("#zoneWorkflow").data("kendoTileLayout");
   const index = workflow.items.findIndex(i => i.id === itemId);
   workflow.items.splice(index, 1);
}
The splice method work perfectly the item was removed from collection. But the relative Tile in the Layout not removed from view. If I repeat the call for button for this tile the index is equal to -1 (because is not in the items collection anymore).

I tried the example of remove from Add / Remove TileLayout but this operation remove all jquery listeners from remaining tiles.

Thanks
FranckSix
Top achievements
Rank 2
Iron
Iron
Veteran
 answered on 20 Jun 2023
7 answers
1.7K+ views
Hello Dear Telerik Team!

I want to realize a scenario where Html-Attributes are conditionally applied to cells. In a ClientTemplate it would look like
" #if(BooleanProperty) { <p style=\"MyStyle: MyValue\">#= ValueProperty #</p> } else { <p>#=ValueProperty#</p> } "
My Questions now:
1. Is this possible without using a client template?
2. How exactly must the syntax look like?

I hope you can help me...

brgds
Malcolm
Sven
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 19 Jun 2023
1 answer
227 views

Hello,

I'm using a Grid control with virtual scrolling.  When I export to PDF, the content runs right off of the bottom of the page without breaking to a new page.  

I have my datasource's page size set to 100 records to limit the number of times the grid will need to fetch new data from the server.  If I change this to only 5 records, for example, then the PDF will create a page break after 5 records.  However, I am also using grouping on the data.  If every row is in its own group, I can get about 6 or 7 rows onto a page.  If every row falls under the same group, I can get about 13-15 rows onto a page.  Because the number of rows per page may vary, I can't resort to setting the page size on the datasource.

My main concern at the moment is getting automatic page breaking to work.   In the screenshot I've attached, you can see that there is still some data at the very bottom of the page that is cut off.  There should be 11 rows of data, across 6 groups, but only 9 rows manage to fit onto the page.  Relevant code below:


.Pdf(pdf => pdf .FileName("BidAwards.pdf") .AllPages() .PaperSize("A4") .Landscape() .AvoidLinks() )

.DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(100)
                    .Events(events => events.Error("error_handler"))
                    .Model(model => model.Id(col => col.BidId))
                    .Read(read => read.Action("BidAwardGridData", "Reports", Model))
                    .Group(groups => groups.Add(col => col.GroupValue))

                )

 

I'd also like to find a way to keep entire groups of rows on a page if possible.  In other words, if the whole group won't fit on the remainder of the page, break to a new page for that group. 

Unfortunately, for the time being I'm stuck on an older version of the Telerik controls, and can't easily update until after this development cycle is completed (unless it's necessary to fix this).

 

Thanks!!!

Christopher
Top achievements
Rank 1
Iron
 answered on 14 Jun 2023
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
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
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?