Telerik Forums
UI for ASP.NET MVC Forum
1 answer
461 views
Hi - is it possible to rotate images with the image editor in ASP.NET MVC library?
Yanislav
Telerik team
 answered on 13 Dec 2021
0 answers
93 views

Hello, I'm trying to add one kendogrid to my page and load the data received in a property of my model and then sumbit them again.

I can show items but whsn send back to controller with a submit I recevive null in controller.

Anyone could help me?

This is my current code:

View

 

Controller

Miguel
Top achievements
Rank 1
 asked on 13 Dec 2021
1 answer
272 views

Hello, I followed the example described here to add a new row to a grid for .net core. 

https://demos.telerik.com/aspnet-core/grid/editing-custom?_ga=2.26293876.833224250.1638885818-877575679.1613496852&_gac=1.254567930.1636639521.CjwKCAiAm7OMBhAQEiwArvGi3LGIkgkIa0cryh_i3sqYkeTw5t6X4lLPrldP-jBbXgDwqmTnAOAOkhoC-yQQAvD_BwE

All works fine as it is in the example but if I change the GridEditMode to Popup then when it opens the popup it doesn't show the editor template DropDownListFor.

Can you help me out in order to have this working with the GridEditMode.Popup ?

 

Thanks,

Pedro

Yanislav
Telerik team
 answered on 13 Dec 2021
2 answers
148 views

I want to add checbox to my grid. I tried to use the Select() method but the method shows an error No overload for method Select takes 0 arguments.  I need to pass to controller a collection of id elements that the user has selected.

    @(Html.Kendo()
             .Grid<Model>()
             .Name(gridId)
             .Columns(col =>
             {
                 col.Select();
                 col.Bound(fds => fds.Id);
                 col.Bound(fds => fds.CreateDateTime).ClientTemplateDateTime();
                 col.Bound(fds => fds.IdClient);
             })
             .Pageable()
             .Sortable()
             .DefaultPageable()
             .Resizable(c => c.Columns(true))
             .AllowCopy(true)
             .DataSource(d =>
                  d.Ajax()
                        .Model(m => m.Id(vm => vm.Id))
                        .Read("GetAnalysis", "Export")))

 


Anonim
Top achievements
Rank 1
Iron
 answered on 13 Dec 2021
1 answer
177 views

Hi,

I have a Model object which is used to create the parent Kendo Grid. This Model object contains a list of object which is used as a data source to another nested grid created with a ClientDetailTemplate and DetailInit event. The nested grid is coming up fine but I am unable to perform any grid operations like sorting or filtering. It does not give any error but the grid just closes down.

I think I might be missing some configuration in DetailInit event method to make sure the sorting/filtering operations does not do server operations. So I used  grid.dataSource.serveroperation = false; in detailInit event. still the grid just closes in and looks like its trying to do server operation for sorting and filtering. Following is an example of the code that I am using:


public class ParentModel
   {
      public long ParentId { get; set; }
      public List<ChildModel> ChildModelList{ get; set; }
      ...
   }

@(Html.Kendo().Grid<ParentModel>()  
    .Name("Grid")
    ...
    .ClientDetailTemplateId("nested_grid")
    .Events(e => e.DetailInit("detailInit"))
    ...
)
  
<script id="nested_grid" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<ChildModel>()
               .Name("ParentModel_#=ParentId#")
               .Sortable()
               .Filterable()
               .ToClientTemplate()
     )
</script>
  
<script>
    function detailInit(e) {
        var grid = $("#ParentModel_" + e.data.Name).data("kendoGrid");
        grid.dataSource.data(e.data.ChildModelList);
        grid.dataSource.serveroperation = false;
        }
</script>
Thanks!
Eyup
Telerik team
 answered on 13 Dec 2021
1 answer
79 views

Hello,

My MVC project used kendo grid control which contain date column.  It seems date filter does not work  - after I clicking Filter button as below Page refreshed without filter. Any suggestion? Thanks in advance.

 

 

in View:

...

 columns.Bound(model => model.HireDate).Width(120).Format("{0:yyyy/MM/dd}");

...

  .ColumnMenu(columnMenu => columnMenu.Enabled(true).Filterable(true).Sortable(false).ComponentType("modern"))

Anton Mironov
Telerik team
 answered on 13 Dec 2021
0 answers
91 views

Hi

I've explored the use of Moq. I found it useful, except for the fact that it relies heavily on code style that uses dependency injection. As I'm working on some existing legacy code, it can become quite the refactoring effort. The code base also includes some assembly references that could not be addressed via Moq.

Microsoft Fakes worked great IMHO. The only downside I saw was the requirement of VS Enterprise 2019. I'm not sure if I can get my employer to pay for the $5k/yr/developer. I really liked the ability to generate fakes on an assembly directly within VS.

Telerik's solution looks equally expensive. I've yet to explore it. Fakes, Stubs, and Mocks (telerik.com)

Prig looks viable, but looks like a pain to setup with powershell scripts, omegle etc.

Thanks

Jack
Top achievements
Rank 1
 updated question on 13 Dec 2021
1 answer
339 views

ASP.NET MVC 2020.3.915, development on an enclave network, so upgrading to newer versions takes an act of Congress, and all the code shown here is typed in by hand—meaning if there are any obvious typos, don't take that as the reason it's not working.

I have a DropDownList set up to get a fresh list of items based on Change and Close events on two DatePicker controls, and it works exactly as desired. I am trying to move this same set of controls to an (existing) preferences settings page. I copied the cshtml code verbatim and made appropriate changes, but it's not working.

Here's the control that is working. It sits inside a TabStrip control:


<div class="editor-field">
    @(Html.Kendo().DropDownListFor(m => m.ReportType)
        .Name("ReportType")
        .DataTextField("Text")
        .DataValueField("Value")
        .OptionLabel("Select a Report Type...")
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("GetFilteredTeams", "Home").Data("get_Dates");
            }).ServerFiltering(true);
        })
        .HtmlAttributes(new { @class = "reportTypeDropdown" }))
</div>

When I inspect this page, I see that this JavaScript was generated:

kendo.SyncReady(function(){jQuery("#ReportType").kendoDropDownList({dataSource":{"transport":{"read":{"url":"/Reporting/Home/GetFilteredTeams","data":getDates},"prefix":""},"serverFiltering":true,"filter":[],"schema":{"errors":"Errors"}},"dataTextField":"Test","dataValueField":"Value","optionLabel":"Select a Report type..."});});


Again, I copied the DropDownList over to the preference page, where it's inside a PanelBar, made appropriate changes, and this is what it looks like: (FWIW, the get_Dates JavaScript function is in a separate JavaScript file associated with the preferences page. Also, the DropDownList is not bound to the model here).

<div class="pref-sub-section-item">
    @(Html.Kendo().DropDownList
        .Name("ReportTypePref")
        .DataTextField("Text")
        .DataValueField("Value")
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("GetFilteredTeams", "Preferences").Data("get_Dates");
            }).ServerFiltering(true);
        })
        .HtmlAttributes(new { @class = "reportTypeDropdown" }))
</div>

However, this is the JavaScript that gets generated:


kendo.SyncReady(function(){jQuery("#ReportTypePref").kendoDropDownList({"dataTextField":"Test","dataValueField":"Value"});});

If I copy the JS generated from the working page, change the name of the control and the URL, then paste it in the console (or add it to a document.ready block), the DropDownList starts working in sync with the DatePickers.

I've tried fooling with the CSS in case that was erroring out and causing a conflict. I've had my eye on the console, and there are no JS errors popping up. I've also taken the non-working version out of the PanelBar and just pasted the <div> to the root/top level on that page. Same results. No JS, and it doesn't work. I've also tried adding a property to the model and using DropDownListFor (just throwing darts, really), and still, no luck.

It seems the problem is that on my preferences page, Kendo is not generating the full JS for some reason. This is such a massive project that it's not really feasible to create a discrete model where the problem is repeatable. I realize without viewing the full project, it will be hard to pinpoint, but I'm just looking for some help on how to troubleshoot what's going on here, since looking under the hood of Kendo has it's limits.

Oh, also, the page that is working is \Reporting\Home\Index.cshtml — the page that is not working is \Preferences\Index.cshtml
John
Top achievements
Rank 1
Iron
 answered on 10 Dec 2021
1 answer
148 views

Hi, 

   I wonder if you could help. I have a Kendo UI grid that has 2 bool elements, this is a MVC core 3.1 project.  When I click on the Create or Update buttons on the Edit popup, nothing happens - no errors and the controller action is not being called. 

    I have code similar to the following code for the grid itself : 


@(Html.Kendo().Grid<MyObject>()
    .Name("MyGrid")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(m => m.Id(e => e.Id))
        .PageSize(20)
        .Read(read => read.Action("Read", "ActionRead"))
        .Create(create => create.Action("Create", "ActionCreate"))
        .Update(update => update.Action("Update", "ActionUpdate"))
        .Events(events => events.Error("onError"))
    )
    .Columns(columns =>
    {
        columns.Bound(p => p.Name);
        columns.Bound(p => p.IsCompleteStatus).ClientTemplate("<input type='checkbox' #= IsCompleteStatus ? checked='checked' :'' # />"); 
        columns.Bound(p => p.IsPendingStatus);
columns.Command(command =>
        {
            command.Edit();
            command.Custom("Remove").Click("onRemove").Visible("isRemoveable").IconClass("k-icon k-i-delete k-icon-32");
            command.Custom("Restore").Click("onRestore").Visible("isRestorable").IconClass("k-icon k-i-reset k-icon-32");
        });
    })
    .ToolBar(toolbar => toolbar.Create().Text("Add Status"))
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .GridDefaults()

And this is what I have in my view for the popup window: 

 


<form>
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <input asp-for="Id" type="hidden" />
    @Html.FormGroupFor(m => m.Name)
    @Html.EditorFor(m => m.IsCompleteStatus)  
  @Html.FormGroupFor(m => m.IsPendingStatus)
</form>

The popup displays fine. However clicking on the Create button (when I hit 'Add') or the Update button (when I click on 'Edit') does absolutely nothing, unless I actually check the checkbox. 

If it is a bool type, it also doesn't let me leave it empty, so it needs it checked all the time.

If it a bool? type, it doesn't let me interact with it at all - I cannot check the boxes, so no Create/Update either.    If I remove the checkboxes from the view, it displays and works fine.  Can you help please? Thank you 

Tsvetomir
Telerik team
 answered on 09 Dec 2021
1 answer
153 views

Hi Team,

I am using Kendo UI MVC Grid and trying to override the checkbox style using FontAwesome fonts. I thought of doing it through CSS alone but since we can't select parent selector through CSS I ended up using the filterMenuInit event. 

Grid column is configured using:-

.Filterable(f => f.Multi(true).Search(true));

I am adding another label to the rendered checkbox text using the below function:-


 function addCustomLabel(e) {
            var container = e.container;
            var allCheckboxes = $("input[type='checkbox']", container);
            $.each(allCheckboxes, function (id) {
                $(this).attr("id", 'chk' + id).addClass("blueCheckbox");
                var checkbox = $(this)[0];
                console.log(checkbox);
                var parentLabel = $(this).parent('label');
                var labelText = parentLabel.text();
                parentLabel.empty();
                parentLabel.append(checkbox);
                parentLabel.append("<label for='"+ 'chk' + id +"'>" + labelText + "</label>");
            });
        }
It's working as expected i.e. adding an id to checkbox and label with "for" attribute but only the "Select All" checkbox is not working. I am assuming it's because kendo is checking for text "Select All" which is now wrapped inside a label. Could you please suggest a fix for this? Or please let me know if there is any better way to do this. 
Eyup
Telerik team
 answered on 08 Dec 2021
Narrow your results
Selected tags
Tags
+133 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?