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

I have a grid in my web application(ASP.NET MVC). When I was testing it with NVDA Screen reader, NVDA reads its header and data(Content) section separately, like they are two different tables. May be this issue is due to two different table tags are used for header and grid content, that's why NVDA is reading it separately. How to solve this issue to make sure that NVDA recognize grid header and content as a single table only.

Alex Hajigeorgieva
Telerik team
 answered on 12 Jan 2021
1 answer
654 views

I added Kendo.Mvc.dll (2018.3.1017.545) to my mvc project in vs2019.

I write this code in my index.cshtml file.
@(Html.Kendo().Editor() .Name("Test") .HtmlAttributes(new { style = "width: 100%; height:840px" }) .Tools(tools => tools .Clear() .Bold().Italic().Underline() .JustifyLeft().JustifyCenter().JustifyRight() .InsertUnorderedList().InsertOrderedList() .Outdent().Indent() .CreateLink().Unlink() .InsertImage() .TableEditing() .FontName() .FontSize() .BackColor() .FontColor() ) .ImageBrowser(imageBrowser => imageBrowser .Image("~/shared/UserFiles/Images/{0}") .Read("Read", "ImageBrowser") .Create("Create", "ImageBrowser") .Destroy("Destroy", "ImageBrowser") .Upload("Upload", "ImageBrowser") ) .Value(@<text> </text>) )

and I added this using at top of my file:

@using Kendo.Mvc.UI

and I added these Scripts to _layout:

<script src="~/Scripts/kendo/kendo.all.min.js"></script>

<script src="~/Scripts/kendo/kendo.aspnetmvc.min.js">

</script><script src="~/Scripts/kendo/kendo.editor.min.js"></script>

even once I added all .js and .css file of kendo, but not worked.

but in chrome I see an empty TextArea.

what else should I do to fix it?

thanks

Dimo
Telerik team
 answered on 12 Jan 2021
1 answer
190 views

Hi,

I have a grid with a subgrid. A column in the parentgrid is calculated based on the sum of columns in the subgrid. When editing a column the value is saved properly. I have to do a refresh/read of the grids to show the new value. This is working properly. But after the refresh it is not visible for the user which row he just edited because everything is collapsed. How can I expand the row after the save to show the subgrid?

Kind regards,

Roel Alblas

Alex Hajigeorgieva
Telerik team
 answered on 12 Jan 2021
1 answer
696 views

Hi,

I like to render a column in the MVC grid with a dynamically rendered field with a color hex. This is in a subgrid wich is generated like below:

.ClientDetailTemplateId("templateSubTasks")

I know that when using a hashtag in a template grid you have to proceed it with two \ I also know that when using a hashtag for example a color hex, you have to proceed it with 4 \. But what when the color hex is loaded with a value from the data property like  #= data.TaskLabel?data.TaskLabel.Color:'' #

Her you can see the column I create in the parent grid. This has to be adjusted for use in a subgrid as a template.

columns.Bound(c => c.TaskLabel).Title(Order.clmLabel).ClientTemplate("<div style='border-radius: 3px; display:inline; width: 8px; height: 18px; background-color: #= data.TaskLabel?data.TaskLabel.Color:'' #'>&nbsp; </div><span style='margin-left:10px'> #= data.TaskLabel?data.TaskLabel.Name:'' #</span>").Width(100).Encoded(false).EditorTemplateName("GridDropdownEditorLabel");

I didn't succeed with adding \\\\ to the property data.TaskLabel.Color.

Do you have any idea?

Kind regards,

Roel Alblas

Martin
Telerik team
 answered on 12 Jan 2021
1 answer
560 views

Hello,

Does anyone have an idea how to keep check box check status when changed page? 

I added check box as a ( ClientTemplate) column, user can check or uncheck them. but check box's value was removed after page moving. How to keep those status?  Thanks in advance.

Georgi Denchev
Telerik team
 answered on 11 Jan 2021
1 answer
440 views

Hello,

 

in C# I've got 2 ViewModels:

```

public class TestListViewModel

{

    public string Param { get; set; }

    public IEnumerable<TestViewModel> Counts { get; set; }

}

```

 

```

public class TestViewModel

{

    public string Name { get; set; }

    public int Count { get; set; }

}

```

 

now I will pass IEnumerable<TestListViewModel> as model to grid. How can I get the result like this: https://demos.telerik.com/aspnet-mvc/grid/aggregates?

I don't need to aggregate any data because it's already done. I just need to fill this grid somehow.

It's my local data, so the Grid will starts with:

```

@(Html.Kendo().Grid(Model)

    .Name("grid")

    .Columns(columns => (?))

    (...)

)

```

Anton Mironov
Telerik team
 answered on 11 Jan 2021
2 answers
134 views

Another 'Invalid Template' error ... there are tons out there, and I thought I'd find my answer, but no.

The hierarchy (nested) grid below works great until I uncomment line 58 or 67.  Then I get the invalid template error.

I've escaped my hash symbols on line 52 as I read in a ton of other posts.

Does anyone spot anything amiss???

TIA

001.@(Html.Kendo().Grid<OrgViewModel>()
002.    .Name("Grid")
003.    .Columns(columns =>
004.    {
005.        columns.Bound(e => e.OrgType).Hidden(true);
006.        columns.Bound(e => e.OrgId).Hidden(true);
007.        columns.Bound(e => e.OrganizationType).Title("Partner or Charter");
008.        columns.Bound(e => e.OrgName).Title("Name");
009.    })
010.    .Filterable(filterable => filterable
011.        .Extra(false)
012.        .Operators(operators => operators
013.            .ForString(str => str.Clear()
014.                .StartsWith("Starts with")
015.                .IsEqualTo("Is equal to")
016.                .IsNotEqualTo("Is not equal to")
017.            ))
018.    )
019.    .Groupable()
020.    .Pageable(m => m.PageSizes(new[] { "20", "50", "100", "All" }))
021.    .Resizable(resizable => resizable.Columns(true))
022.    .Sortable()
023.    .Scrollable(s => s.Enabled(true))
024.    .ClientDetailTemplateId("template")
025.    .HtmlAttributes(new { style = "height:850px;" })
026.    .DataSource(dataSource => dataSource
027.        .Ajax()
028.        .PageSize(20)
029.        .Read(read => read.Action("Orgs_Read", "FiscalContacts"))
030.        .Sort(sort =>
031.        {
032.            sort.Add(x => x.OrgName);
033.            sort.Add(x => x.OrgType);
034.        })
035.    )
036.    .Events(events => events.DataBound("dataBound"))
037.    )
038. 
039.@section scripts {
040.<script id="template" type="text/kendo-tmpl">
041.    @(Html.Kendo().Grid<FiscalContactViewModel>()
042.        .Name("Grid_#=OrgType#_#=OrgId#") // template expression, to be evaluated in the master context
043.        .Columns(columns =>
044.        {
045.            //columns.Command(command => { command.Edit(); }).Width(250);
046.            columns.Bound(o => o.Id).Hidden(true);
047.            columns.Bound(o => o.SalesforceId).Hidden(true);
048.            columns.Bound(o => o.LastName);
049.            columns.Bound(o => o.FirstName);
050.            columns.Bound(o => o.Title);
051.            columns.Bound(o => o.Email);
052.            columns.Bound(x => x.ExecComm).Title("Exec").Width(75).Filterable(true).ClientTemplate("\\#=ExecComm ? 'Yes': ''\\#").HtmlAttributes(new { style = "text-align:center" });
053.            columns.Bound(o => o.Roles);
054.            columns.Bound(o => o.FiscalPermissions).Title("Perms").Width(75);
055.        })
056.        .ToolBar(tools =>
057.        {
058.            //tools.Create();
059.            tools.Excel();
060.        })
061.        .Excel(excel => excel
062.            .FileName("Fiscal Contacts.xlsx")
063.            .Filterable(true)
064.            .AllPages(true)
065.            .ProxyURL(Url.Action("Excel_Export_Save", "FiscalContacts"))
066.        )
067.       
001.@(Html.Kendo().Grid<OrgViewModel>()
002.    .Name("Grid")
003.    .Columns(columns =>
004.    {
005.        columns.Bound(e => e.OrgType).Hidden(true);
006.        columns.Bound(e => e.OrgId).Hidden(true);
007.        columns.Bound(e => e.OrganizationType).Title("Partner or Charter");
008.        columns.Bound(e => e.OrgName).Title("Name");
009.    })
010.    .Filterable(filterable => filterable
011.        .Extra(false)
012.        .Operators(operators => operators
013.            .ForString(str => str.Clear()
014.                .StartsWith("Starts with")
015.                .IsEqualTo("Is equal to")
016.                .IsNotEqualTo("Is not equal to")
017.            ))
018.    )
019.    .Groupable()
020.    .Pageable(m => m.PageSizes(new[] { "20", "50", "100", "All" }))
021.    .Resizable(resizable => resizable.Columns(true))
022.    .Sortable()
023.    .Scrollable(s => s.Enabled(true))
024.    .ClientDetailTemplateId("template")
025.    .HtmlAttributes(new { style = "height:850px;" })
026.    .DataSource(dataSource => dataSource
027.        .Ajax()
028.        .PageSize(20)
029.        .Read(read => read.Action("Orgs_Read", "FiscalContacts"))
030.        .Sort(sort =>
031.        {
032.            sort.Add(x => x.OrgName);
033.            sort.Add(x => x.OrgType);
034.        })
035.    )
036.    .Events(events => events.DataBound("dataBound"))
037.    )
038. 
039.@section scripts {
040.<script id="template" type="text/kendo-tmpl">
041.    @(Html.Kendo().Grid<FiscalContactViewModel>()
042.        .Name("Grid_#=OrgType#_#=OrgId#") // template expression, to be evaluated in the master context
043.        .Columns(columns =>
044.        {
045.            //columns.Command(command => { command.Edit(); }).Width(250);
046.            columns.Bound(o => o.Id).Hidden(true);
047.            columns.Bound(o => o.SalesforceId).Hidden(true);
048.            columns.Bound(o => o.LastName);
049.            columns.Bound(o => o.FirstName);
050.            columns.Bound(o => o.Title);
051.            columns.Bound(o => o.Email);
052.            columns.Bound(x => x.ExecComm).Title("Exec").Width(75).Filterable(true).ClientTemplate("\\#=ExecComm ? 'Yes': ''\\#").HtmlAttributes(new { style = "text-align:center" });
053.            columns.Bound(o => o.Roles);
054.            columns.Bound(o => o.FiscalPermissions).Title("Perms").Width(75);
055.        })
056.        .ToolBar(tools =>
057.        {
058.            //tools.Create();
059.            tools.Excel();
060.        })
061.        .Excel(excel => excel
062.            .FileName("Fiscal Contacts.xlsx")
063.            .Filterable(true)
064.            .AllPages(true)
065.            .ProxyURL(Url.Action("Excel_Export_Save", "FiscalContacts"))
066.        )
067.        //.Editable(editable => editable.Mode(GridEditMode.InCell))
068.        .DataSource(dataSource => dataSource
069.            .Ajax()
070.            .PageSize(10)
071.            .Read(x => x.Action("ListContacts", "FiscalContacts", new { orgType = "#=OrgType#", orgId = "#=OrgId#" }))
072.            .Create(x => x.Action("FiscalContacts_Create", "FiscalContacts", new { orgType = "#=OrgType#", orgId = "#=OrgId#" }))
073.            .Update(x => x.Action("FiscalContacts_Update", "FiscalContacts"))
074.            .Model(model =>
075.            {
076.                model.Id(x => x.Id);
077.                model.Field(x => x.Id).Editable(false);
078.                model.Field(x => x.FiscalPermissions).Editable(false);
079.            }).Sort(sort =>
080.            {
081.                sort.Add(x => x.LastName);
082.                sort.Add(x => x.FirstName);
083.            })
084.        )
085.        .Filterable(filterable => filterable
086.            .Extra(false)
087.            .Operators(operators => operators
088.                .ForString(str => str.Clear()
089.                    .StartsWith("Starts with")
090.                    .IsEqualTo("Is equal to")
091.                    .IsNotEqualTo("Is not equal to")
092.                ))
093.        )
094.        .Groupable()
095.        .HtmlAttributes(new { style = "height:600px;" })
096.        .Pageable(m => m.PageSizes(new[] { "20", "50", "100", "All" }))
097.        .Resizable(resizable => resizable.Columns(true))
098.        .Sortable()
099.        .Scrollable(s => s.Enabled(true))
100.        .ToClientTemplate()
101.    )
102.</script>
103.    <script>
104.        function dataBound() {
105.            this.expandRow(this.tbody.find('tr.k-master-row').first());
106.        }
107.</script>
108.}
.Editable(editable => editable.Mode(GridEditMode.InCell))
068.        .DataSource(dataSource => dataSource
069.            .Ajax()
070.            .PageSize(10)
071.            .Read(x => x.Action("ListContacts", "FiscalContacts", new { orgType = "#=OrgType#", orgId = "#=OrgId#" }))
072.            .Create(x => x.Action("FiscalContacts_Create", "FiscalContacts", new { orgType = "#=OrgType#", orgId = "#=OrgId#" }))
073.            .Update(x => x.Action("FiscalContacts_Update", "FiscalContacts"))
074.            .Model(model =>
075.            {
076.                model.Id(x => x.Id);
077.                model.Field(x => x.Id).Editable(false);
078.                model.Field(x => x.FiscalPermissions).Editable(false);
079.            }).Sort(sort =>
080.            {
081.                sort.Add(x => x.LastName);
082.                sort.Add(x => x.FirstName);
083.            })
084.        )
085.        .Filterable(filterable => filterable
086.            .Extra(false)
087.            .Operators(operators => operators
088.                .ForString(str => str.Clear()
089.                    .StartsWith("Starts with")
090.                    .IsEqualTo("Is equal to")
091.                    .IsNotEqualTo("Is not equal to")
092.                ))
093.        )
094.        .Groupable()
095.        .HtmlAttributes(new { style = "height:600px;" })
096.        .Pageable(m => m.PageSizes(new[] { "20", "50", "100", "All" }))
097.        .Resizable(resizable => resizable.Columns(true))
098.        .Sortable()
099.        .Scrollable(s => s.Enabled(true))
100.        .ToClientTemplate()
101.    )
102.</script>
103.    <script>
104.        function dataBound() {
105.            this.expandRow(this.tbody.find('tr.k-master-row').first());
106.        }
107.</script>
108.}
Kim
Top achievements
Rank 1
Veteran
 answered on 11 Jan 2021
1 answer
74 views

I am experiencing an issue where, using Internet Explorer 11, the animation containers on certain components do not appear in alignment with the component they are originating from. For the most part, what this means is the animations appear off to the left, but sometimes, animations also open above where they would open below on Edge or Chrome. Affected components are dropdown list in a grid's popup editor and filter menus appearing after a filter icon on a grid column is pressed.

Identical issue: https://stackoverflow.com/questions/60257190/alignment-issue-with-kendo-ui-dropdown-list-in-ie11

It seems like resolution has some influence on this because in some cases, the issue goes away when the page is very zoomed out (though it isn't very comfortable for the user at this point).

Neli
Telerik team
 answered on 07 Jan 2021
6 answers
182 views

Hello

I am trying to  implement kendo grid,

I see all the data in grid but when i move to next page all the data is deseapers.

This is my controller code

  public async Task<ActionResult> TodaysSalesList([DataSourceRequest] DataSourceRequest request, DateTime? fileDate, int? pageSize, int? pageNo, int? loanCustomerId)
        {
            PagedResults<VmpLoanSalesVM> resultloans;
            try
            {
                var startDate = fileDate.GetValueOrDefault().Date;

                var dic = new DualControlDictionary
                {
                    { "date", startDate.Date.ToString() },
                    { "loanCustomerId", loanCustomerId.ToString() }
                };
                resultloans = await _dualControlService.GetData(dic);   
                var jsonRes = Json(resultloans.Results.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                jsonRes.MaxJsonLength = int.MaxValue;
                return jsonRes;
            }
            catch (Exception e)
            {
                Log.Error(e);
                return Json(new
                {
                    success = false
                }, JsonRequestBehavior.AllowGet);
            }
        }

I have also tried return the data like this 

 var jsonRes = Json( new {Data=resultloans.Results.ToDataSourceResult(request),Total=esultloans.ResultsCount()}, JsonRequestBehavior.AllowGet);
                jsonRes.MaxJsonLength = int.MaxValue;
                return jsonRes;

But it doesn't help

See attched file my grid cshtml

Preslav
Telerik team
 answered on 06 Jan 2021
3 answers
1.2K+ views

Hello , 

I'm trying to filter a grid column having DateTime value , for eg - 12/21/2020 12:01:47 PM . and below my implementation .

This works for the first time only and if we open the filter menu again, the filter operator shows as blank (It should have the operator as Equals) and upon selecting a new value from operator list ,it throws JS error at d.filters[0].operator as d.filters[0] is coming as undefined.

Grid filter settings-
.Events(x => x.FilterMenuInit("filterDateWithoutTimeTest"))

.Filterable(f => f.Operators(operators => operators.ForDate(dt => dt.Clear()
                                                        .IsEqualTo("Equals")
                                                        .IsLessThan("EarlierThan")
                                                        .IsGreaterThan("LaterThan")
                                                        )))

 

function filterDateWithoutTimeTest(e) {
        var grid = e.sender;
        if (e.sender.dataSource.options.schema.model.fields[e.field].type === "date") {
            e.preventDefault();
            var columnTobeFiltered = e.field;
            e.container.find('button[type="submit"]').click(function (e) {     
                var existingFilters = grid.dataSource.filter();
                var newFilter = [];               
                var filterType = $(this.form).find($("select[data-role=dropdownlist]")).eq(0).val();
                if (filterType == "eq") {
                   
                    //gets the datePicker input date
                    var selectedDate = $(this.form).find($("input[data-role=datepicker]")).eq(0).val();

                    //    //create a filter
                    grid.dataSource.filter({
                        field: columnTobeFiltered,
                        //create custom filter operator
                        operator: function (fieldDate) {
                            var fieldDate2 = new Date(fieldDate);
                            var parsedSelectedDate = kendo.parseDate(selectedDate);
                            //parse the field date in order to ignore the time
                            var parsedFieldDate = new Date(fieldDate2.getFullYear(), fieldDate2.getMonth(), fieldDate2.getDate());
                            var result = (parsedFieldDate.getTime() == parsedSelectedDate.getTime());

                            return result;

                        },
                        value: selectedDate
                    });

                    //close filter window
                    $(gridElement).find("th[data-field=" + columnTobeFiltered + "]").data("kendoFilterMenu").popup.close();
                }
            })
        }
    }

Any help around this is appreciated.

Thanks

Nikolay
Telerik team
 answered on 06 Jan 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?