Telerik Forums
UI for ASP.NET MVC Forum
1 answer
21 views
How to bind data to dynamic grid MVC
Ivan Danchev
Telerik team
 answered on 21 May 2021
1 answer
8 views
In one of the columns of my grid I have a link.  It used to recognize the :visited property just fine, but I had to update to 2020.1.406 (I did not want to update, was kinda forced into it) and now the link in my grid doesn't use nor recognize the :visited property apparently.

These work as expected

.k-grid a {
color: black;
}

.k-grid a:hover {
color: green;
}

but for whatever reason, this does not:

.k-grid a:visited {
color: pink !important;
}

So how can I get the :visisted property to work correctly.  The users were using it to keep track of which record within a grid they had already worked with/processed.  I don't want to have to put in place some other roundabout way of tracking this...


Anton Mironov
Telerik team
 answered on 20 May 2021
1 answer
21 views

Can you tell me how to add a Hyperlink column to a MVC ASP.NET Grid?

I've tried everything i could find and none work.. JIRA_Ticket is the display value, and Service Desk holds the Hyperlink i want to open a new window with. It's possible i'm just not googling it right.. I'm fairly new to this so sorry if this is a dumb question.

    .Columns(columns =>
    {
        columns.Bound(m => m.JIRA_Ticket).Width(60).HtmlAttributes(new { @class = "txtovflw" });
        //.ClientTemplate("<a href='" + Url.Content("\\#= ServiceDesk \\#") + "' target='_blank'>\\#= ServiceDesk \\#Link</a>");
        //.ClientTemplate("<a href='\\#' onclick='proposalWindow(#= ServiceDesk #)'>" + "#= JIRA_Ticket #" + "</a>").Title("Title");

I just want to be able to click on the JIRA ticket column in the grid and open the servicedesk link in the model.

If this is not possible, happy to go with an action button..

 

Any help appreciated

 

Ivan Danchev
Telerik team
 answered on 20 May 2021
8 answers
882 views
I am running into an issue with a simple string property when using a custom EditorTemplate in the Kendo Grid and inline editing.

I am doing something very similar to this: http://docs.kendoui.com/documentation/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates#create-custom-editor-for-a-bound-property

The issue appears to be that the model value for the property is not being passed to the editor template when entering edit mode. For example, if I remove the custom EditorTemplate usage, the grid works fine: clicking Edit shows a textbox for the string property with the saved value for the row prefilled in the textbox. When I use the custom EditorTemplate, the Model value is null. I've tried simplifying my editor template down to nothing but outputing the model value with the same results.

Any ideas of what might be causing this?
Eyup
Telerik team
 updated answer on 20 May 2021
17 answers
701 views

The grid and popup work fine except the values I enter in create mode do not get passed back to my controller. Looking at the JS Console shows no errors. Monitoring the create process in Fiddler also shows no values being passed, although my form elements do show.

While debugging, the model in my controller is empty.

Here's the grid definition:

@(Html.Kendo().Grid<MyApp.Domain.Entities.TaktInterruptionViewModel>()
.Name("Interruptions")
.Columns(columns =>
    {
        columns.Bound(i => i.TaktInterruptionId).Hidden().IncludeInMenu(false);
        columns.Bound(i => i.DateCreated).Title("Date").Width(75).Format("{0:d}");
        columns.Bound(i => i.ActionCount).Title("Actions").Width(50).Hidden(true);
        columns.Bound(i => i.MeetingType).Title("Meeting   Type").Width(100).Hidden(true);
        columns.Bound(i => i.AreaName);
        columns.Bound(i => i.TypeName);
        columns.Bound(i => i.Responsible);
        columns.Bound(i => i.Description).Width(300);
        columns.Bound(i => i.Interruption).Width(75).Hidden(true);
        columns.Bound(i => i.TaktMissed).Title("Missed").Width(75);
    })
.ClientDetailTemplateId("ActionsTemplate")
.ToolBar(toolbar => toolbar.Create().Text("Add Interruption"))
.Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("Create").Window(w => w.Title("Interruption").Name("addInterruption").Modal(true)))
.DataSource(datasource => datasource.Ajax()
    .Model(model => model.Id(p => p.TaktInterruptionId))
    .ServerOperation(false)
    .PageSize(5)
    .Create(create => create.Action("Create", "Home"))
    .Read(read => read.Action("GetInterruptions", "Home")))
.Groupable()
.Pageable()
.Sortable()
.Filterable()
.ColumnMenu()
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.Reorderable(reorder => reorder.Columns(true))
.Resizable(resize => resize.Columns(true))
.Events(events => events.Change("displayChart"))
)

My create editor template is as follows:

@model MyApp.Domain.Entities.TaktInterruptionViewModel
@{
    ViewBag.Title = "Index";
}

<div class="span-14" style="padding: 10px;">
    @Html.ValidationSummary(true)
    <hr class="space" />
    <div>
        @Html.LabelFor(model => model.DateCreated)<br />
        @(Html.Kendo().DatePicker().Name("DateCreated").Value(DateTime.Today))
        <br />
        @Html.ValidationMessageFor(model => model.DateCreated, null, new { style =    "color:red;" })
    </div>
    <hr class="space" />
    <div class="span-7">
        @Html.LabelFor(model => model.AreaId)<br />
        @(Html.Kendo().DropDownListFor(model => model.AreaId)
            .Name("AreaId")
            .HtmlAttributes(new { style = "width:200px" })
            .OptionLabel("Select Area...")
            .DataTextField("AreaName")
            .DataValueField("AreaId")
            .DataSource(source =>
                {
                    source.Read(read =>
                        {
                            read.Action("GetAreas", "Area");
                        });
                })
         )
        <br />
        @Html.ValidationMessageFor(model => model.AreaId)
    </div>
    <div class="span-6">
        @Html.LabelFor(model => model.TaktInterruptionTypeId)<br />
        @(Html.Kendo().DropDownListFor(model => model.TaktInterruptionTypeId)
            .Name("TaktInterruptionTypeId")
            .HtmlAttributes(new { style = "width: 200px" })
            .OptionLabel("Select Type...")
            .DataTextField("TypeName")
            .DataValueField("TaktInterruptionTypeId")
            .DataSource(source =>
                {
                    source.Read(read =>
                        {
                            read.Action("GetTypes", "Area").Data("filterTypes");
                        }).ServerFiltering(true);
                })
                .Enable(false)
                .AutoBind(false)
                .CascadeFrom("AreaId")
         )
        <br />
        @Html.ValidationMessageFor(model => model.TaktInterruptionTypeId, null, new { style = "color:red;" })
    </div>
    <hr class="space" />
    <div class="span-11">
        @Html.LabelFor(model => model.Description)<br />
        @Html.TextAreaFor(model => model.Description, new { @class = "multi-line" })
        <br />
        @Html.ValidationMessageFor(model => model.Description, null, new { style = "color:red;" })
    </div>
    <hr class="space" />
    <div class="span-5">
        @Html.LabelFor(model => model.Interruption)<br />
        @(Html.Kendo().NumericTextBox().Name("Interruption").Format("#.0").Value(0))
        <br />
        @Html.ValidationMessageFor(model => model.Interruption)
    </div>
    <div class="span-6">
        @Html.LabelFor(model => model.TaktMissed)<br />
        @(Html.Kendo().NumericTextBox().Name("TaktMissed").Format("#.0").Value(0))
        <br />
        @Html.ValidationMessageFor(model => model.TaktMissed)
    </div>
    <hr class="space" />
    <div>
        @Html.LabelFor(model => model.Responsible)<br />
        @Html.EditorFor(model => model.Responsible, new { @class = "k-input k-textbox" })
        <br />
        @Html.ValidationMessageFor(model => model.Responsible, null, new { style = "color:red;" })
    </div>
    <hr class="space" />
    <hr class="space" />
</div>

<script type="text/javascript">
    function filterTypes() {
        return {
        AreaID: $("#AreaId").val()
        };
    }
</script>

And my controller create method is:

[HttpPost]
    public ActionResult Create([DataSourceRequest] DataSourceRequest request, MyApp.Domain.Entities.TaktInterruptionViewModel taktInterruption)
    {
        try
        {
            if (ModelState.IsValid)
            {
                // code removed for brevity
            }

            return Json(ModelState.ToDataSourceResult());
        }
        catch(Exception ex)
        {
            
	    // code removed for brevity
} }

If I remove my editor template from the equation and allow Kendo to do the popup, the information is passed to my controller; however, I want to control the layout of the popup and I also have cascading drop-downs (that work), thus the editor template.

My question is why aren't my values that I enter in the popup being passed to my controller?

Tony
Top achievements
Rank 1
Iron
Iron
Iron
 updated answer on 19 May 2021
1 answer
10 views

I have a 10 year old ASP.Net MVC 3 application that was originally built using Telerik ASP.Net MVC 3.  I am now trying to upgrade the website to MVC 5, and I believe I have the standard ASP.Net components upgraded, but I am really stuck with the Telerik components Benjyfishy Settings.  If I try to run the MVC 5 application with the Telerik MVC 3 components, I get this TypeLoadException.  I made an attempt to upgrade to Telerick MVC 5, but it seems like all of the classes have changed, and as you can imagine, an application that has been in active development for 10 years has a lot of App code, and I do not think I can just go and re-write it all to use completely different types for the controls.  What kind of upgrade path can you recommend to get this application to run on MVC 5 Mini Militia Mod APK?  If there is a way to just overcome this TypeLoadException with the Telerik MVC 3 components or to upgrade to Telerik MVC 5 without having to rewrite the entire application, that would be great.  Thank you.

System.TypeLoadException: Inheritance security rules violated by type: 'Telerik.Web.Mvc.PopulateSiteMapAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.

Ivan Danchev
Telerik team
 answered on 19 May 2021
1 answer
9 views

Hi,

I have a grid where amongst other columns, I have two columns which are related - in the first column I select from a list of available options and based on the value selected here, I want to apply a filter to a foreign key column elsewhere in the grid.

So for example if I have a column for "Company ID" with values [1, 2, 3, 4,5] and an FK column "Category", the values bound to the "Category" column are ID/Text pairs for all possible categories, but I'd like to filter that down based on a 3rd "CompanyID" value.

It seems that no matter how I configure the FK column, the underlying data source only ever has the ID/Text values so any attempt at filtering it down based on the CompanyID column doesn't work. Even if my bound values/remote data source returns objects with the required fields for filtering, they get dropped when the FK dropdown list's data source is created.

Is something this even possible to achieve with the grid? If so any pointers would be much appreciated.

Eyup
Telerik team
 answered on 18 May 2021
1 answer
11 views

I have a grid that's filterable. Each column has a funnel in the header. I can filter by adding a filter value to column1 and Column2. Data is filtered correctly. However when I clear filter value on Column1 and click filter, column2's filter value is also cleared. If I clear the value from Column1 but use the filter button from column2, then column2's value is used to correctly filter the data.

Does the grid NOT check the presence of filter values on all columns before filtering data? Is this a bug? 

Eyup
Telerik team
 answered on 18 May 2021
2 answers
14 views

Hello everybody,

im trying to achieve that the dropdown filter list in my grid takes the size from it's biggest option.

I found other explanations for different situations and none of those worked for me.

 

I have a MVC Grid with a ForeignKey Column, that is filtered with a dropdown of enum values.

x.ForeignKey(b => b.Status, Model.OrderGapStatus).Filterable(f => f.Cell(c => c.Template("statusFilter"))).Title(Localizer.Lang_Status).ClientTemplate("#: StatusName #");

And a js handler trying to set the width to "auto". But it doesn't work :/

<script type="text/javascript">
    function statusFilter(element) {
       // what do i need to do here?
    }
</script>

Help would be really appreciated 😃

 

Have a good day & happy coding

Nils

Nils
Top achievements
Rank 1
Iron
 answered on 17 May 2021
1 answer
17 views

Hi Team,

I have a Kendo MVC Grid. i need to apply responsive design to grid.

am trying to apply but not achieved. please resolve my issue.

here i want to show columns in all widths.

Please apply changes in my solution only.  am deleted kendo scripts version 2020.3.1118 in attached rar file.

if you unable to rar my file then please provide me a  sample example kendo grid mvc with more than 10 columns.

 

 

Ivan Danchev
Telerik team
 answered on 14 May 2021