Telerik Forums
UI for ASP.NET Core Forum
6 answers
168 views

My TreeList is generally working.  However, when a user selects a Custom Command Button, I need to populate the Model with that Group.Id key value.  How is this accomplished?  As shown, the "function goDetail(e)" code works.  However, if I remove the comment the last 2 lines the TreeList doesn't build... of course, I don't get any feedback as to what is wrong.  That would be nice.  But, this is where I'm trying to pull the dataItem.Id into the Model.  How can I get this to happen?  Thanks.

<script id="icon-template" type="text/x-kendo-template">
    <div class='group-icon'
         style='background-image: url(@Url.Content("#: ImageUrl #"));'></div>
    <div class='group-name'>#: Name #</div>
</script>
 
@(Html.Kendo().TreeList<Group>()
    .Name("treelist")
    .Columns(columns =>
    {
        columns.Add().Command(c => { c.Custom().Text("Select")
            .Name("selectButton").ClassName("selectButton")
            .Click("goDetail"); })
            .Width(Glossary.Portal.ButtonWidth);
        columns.Add().Field(e => e.Name).TemplateId("icon-template").Width(350);
    })
    .DataSource(dataSource => dataSource
        .Read(read => read.Action("IndexJson", "Groups").Data("getData"))
        .ServerOperation(false)
        .Model(m =>
        {
            m.Id(f => f.Id);
            m.ParentId(f => f.ParentId);
            m.Expanded(true);
            m.Field(f => f.Name);
        }).Events(events => events.Error("onError"))
    )
    .Events(evt => evt.DataBound("treeListBound")))
 
<script type="text/javascript">
 
    function getData() {
        return @Html.Raw(Model.GetIndexData());
    }
 
    function goDetail(e) {
        e.preventDefault();
        alert("goDetail: " + e.toString());
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        alert("goDetail: " + dataItem.id);
        @*@Model.Item.GroupId = dataItem.id;
        alert("goDetail: " + @Model.Item.GroupId);*@
    }
 
    function treeListBound(e) {
        var treeList = e.sender;
        var items = treeList.items();
 
        for (i = 0; i < items.length; i++) {
            var dataItem = treeList.dataItem(items[i]);
 
.....

 

Joel
Top achievements
Rank 3
Bronze
Iron
Iron
 answered on 04 Mar 2020
3 answers
171 views

If I have a column filter configured like this:-

 

            c.Bound(p => p.CreatedDateTime)
                .Title("Created")
                .Filterable(f => f
                    .Operators(o => o.ForDate(d => d.Clear().IsGreaterThanOrEqualTo("On or after").IsLessThan("Before")))
                    .UI(GridFilterUIRole.DateTimePicker)
                )

 

It shows a dropdown for "And" and "Or" between the two filter options. In my case, this doesn't make sense.

Is there a way to specify the options or remove the dropdown?

Nikolay
Telerik team
 answered on 03 Mar 2020
1 answer
184 views
Hello Support Team, I need to show dynamic name of column as per model value from backend.
in Html.Kendo().Grid.
can you please let me that what to do.
Thanks,
Alex Hajigeorgieva
Telerik team
 answered on 03 Mar 2020
3 answers
349 views

Hello,

I have a grid with an ajax data source and ServerOperation set to true. The data source has roughly about 1.5 million entries and I want to display them with virtual scrolling enabled so that only the relevant portion of the data is loaded into the DOM.

Now the problem is that only about half of the available data is shown in the grid when scrolled to the end. See picture "missing_data.png" for clarification.

I tried to troubeshoot the issue myself and came up with this KB article: Virtual Scrolling - Setting the scrollbar, but I cannot get all elements to show with either hint. Apparently a height of 36px is the minimum for a grid row and with that value not all rows are shown. Disabling word-wrap has no effect. I noticed the maximum amount of entries displayed when scrolled to the end changes with different themes and changes sometimes when I scroll to the bottom repeatedly.

Now my question is how can I reliably show all rows and keep virtual scrolling? Currently my grid looks like this:

@(Html.Kendo().Grid<LogEntry>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.EventDateTime)
            .Title("Date").Width(100)
            .Format("{0: dd.MM.yyyy HH:mm:ss}");
        //.Filterable(config => config
        //    .UI("DateTimeFilter")
        //    .Cell(cell => cell
        //        .Template("DateTimeFilterRow")));
 
        columns.Bound(c => c.EventLevel).Title("Level").Width(100);
        columns.Bound(c => c.MachineName).Title("Hostname").Width(150);
        columns.Bound(c => c.EventMessage).Title("Message").Width(600)
            .HtmlAttributes(new { @class = "nowrap" });
 
        //columns.Bound(c => c.StackTrace).Hidden();
        //columns.Bound(c => c.ErrorMessage).Hidden();
    })
    .ColumnMenu(config => config
        .Sortable(false)
        .Columns(true)
        .Enabled(true))
    .Sortable()
    .Groupable()
    .Filterable(config => config
        .Extra(false)
        .Mode(GridFilterMode.Row)
        .Operators(config => config
            .ForDate(config => config
                .Clear()
                .IsGreaterThanOrEqualTo("Ist nach")
                .IsLessThanOrEqualTo("Ist vor")
                .IsEqualTo("Ist gleich"))
            .ForString(config => config
                .Clear()
                .IsEqualTo("Ist gleich")
                .IsNotEqualTo("Ist ungleich")
                .StartsWith("Beginnt mit")
                .EndsWith("Endet mit")
                .Contains("Enthält")
                .DoesNotContain("Enthält nicht")
                .IsNullOrEmpty("ist NULL"))))
    .Scrollable(config => config
        .Height("auto")
        //.Endless(true)
        .Virtual(true))
    //.ClientDetailTemplateId("log-detail")
    .Resizable(config => config.Columns(true))
    .Reorderable(config => config.Columns(true))
    .Pageable(config => config
        .Refresh(true)
        .Numeric(true))
    //.Events(events => events
    //    .DetailExpand("onDetailExpand"))
    .DataSource(config => config
        .Ajax()
        .PageSize(200)
        .ServerOperation(true)
        .Read("Logs_Read", "Home")
        .Events(events => events
            .Error("error_handler"))
    )
)

 

 

Angel Petrov
Telerik team
 answered on 02 Mar 2020
1 answer
1.1K+ views

When binding to remote data:-

    .DataSource(d => d
        .Ajax()
        .Read(r => r.Action("Index", "Books", new { id = Model.Id }))

If an error occurs when calling the controller method, there is no error message and the grid displays no results, so the user doesn't know what's going on.

I'm aware that I can catch errors in my controller method and do something with the DataSourceRequest, however, the particular case I'm experiencing is when a session has been idle and the authentication has timed out, calling the controller method wants to redirect me to the login page.

Usually this would be OK, however, as it's being called in the AJAX handler by the grid, it just fails silently.

How can I catch the error and display it, or ideally, catch the redirect and navigate to the login page?

 

 

 

Tsvetomir
Telerik team
 answered on 02 Mar 2020
2 answers
160 views

Hey guys,

I have a simple telerik grid in my asp.net core app which basically consists of two columns:"Activity", "Share of total". 

"Share of total" is the only (inCell) editable column and consists of percentage values between 0 and 100. 

Now I have the following problem, which I haven't been able to solve yet: 

If not in edit mode, the cells of the "Share of total" should display "0"-Values just normal. But when entering edit-mode, I want those zeros to not be displayed in the input-field. Instead it should just be empty, so that new values can easily be entered.

Especially in internet explorer, the cursor is positioned in front of the zero, which leads to entering for example 20 instead of 2, which is quite annoying for quick inputs.

Do you have a solution for that?

Best regards

Alex Hajigeorgieva
Telerik team
 answered on 28 Feb 2020
1 answer
768 views

I have GridView two column,  1 column is RadioButton and other is Checkbox,
I want based on RadioButton click in the same row checkbox should be checked or unchecked, in the following code if click radio button then all checkbox in the columns is checked.

 

<script type="text/javascript">


    function Check_Radio(rb) {
           var isChecked = rb.checked;
           var row = rb.parentNode.parentNode;
        if (isChecked) {
            row.style.backgroundColor = '#B6C4DE';
            row.style.color = 'black';
            
        }        
        
        var currentRdbID = rb.id;
        parent = document.getElementById("<%= GridView1.ClientID %>");
        var items = parent.getElementsByTagName('input');

        for (i = 0; i < items.length; i++) {
            if (items[i].id != currentRdbID && items[i].type == "radio") {
                if (items[i].checked) {
                    items[i].checked = false;
                    items[i].parentNode.parentNode.style.backgroundColor = 'white';
                    items[i].parentNode.parentNode.style.color = '#696969';

                }

            }

            if (items[i].id != currentRdbID && items[i].type == "checkbox") {

                items[i].checked = true;

            }                 
    }
    }  
</script>
How can be fix the problem..

Thanks

Georgi
Telerik team
 answered on 27 Feb 2020
1 answer
134 views

I'm doing Server Filtering on a combobox on selecting a school. School may have thousands of row.  I have it working fine but when I go back into Edit mode I was to display the Template to the selected saved record. I have what should be displayed as well as the ID in the ViewModel.  I tried Value and I tried do it in javascript but can't find a way. 

 

                                                            @(Html.Kendo().ComboBox()
                                                                     .Name("SchoolId")
                                                                     .Placeholder("Select School")
                                                                     .DataTextField("schoolName")
                                                                     .DataValueField("schoolId")
                                                                     .HtmlAttributes(new { @class = "form-control" })
                                                                     .Filter(FilterType.Contains)
                                                                     .AutoBind(false)
                                                                     .MinLength(3)
                                                                     .DataSource(source =>
                                                                     {
                                                                         source.Read(read =>
                                                                         {
                                                                             read.Action("GetSchools", "User");
                                                                             read.Type(HttpVerbs.Get);
                                                                         })
                                                                         .ServerFiltering(true);
                                                                     })
                                                                     .Template("#: data.schoolName # (#: data.schoolCity #, #: data.schoolState #)")
                                                            )

 

Petar
Telerik team
 answered on 27 Feb 2020
4 answers
246 views

Hello Every one,

I am using Kendo ui grid in .net core. I have facing one issue in this grid to add comma in paging value. Please review my attached file and let know what is the better solution for adding comma in paging value? Please help me and share code

thanks

 

 

Veselin Tsvetanov
Telerik team
 answered on 27 Feb 2020
10 answers
671 views

Hi!

I have a problem with SignalR and the Grid.

I have a hub like this:

01.public class ACTaskHub : Hub
02.{
03.    private IMemoryCache taskCache;
04. 
05.    public ACTaskHub(IMemoryCache cache)
06.    {
07.        taskCache = cache;
08.    }
09. 
10.    public override Task OnConnectedAsync()
11.    {
12.        //Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName());
13.        return base.OnConnectedAsync();
14.    }
15. 
16.    public override Task OnDisconnectedAsync(Exception exception)
17.    {
18.        //Groups.RemoveFromGroupAsync(Context.ConnectionId, GetGroupName());
19.        return base.OnDisconnectedAsync(exception);
20.    }
21. 
22.    public IEnumerable<TaskViewModel> Read()
23.    {
24.        var tasks = taskCache.Get("tasks") as IEnumerable<TaskViewModel>;
25. 
26.        if (tasks == null)
27.        {
28.            var products = AppData.TaskList.Select(t => new TaskViewModel
29.            {
30.                ID = t.ID,
31.                Name = t.Name,
32.                LastRunTime = t.LastRunTime,
33.                Duration = t.Duration,
34.                Schedule = t.Schedule,
35.                Status = t.Status.ToString(),
36.                Result = t.LastResult,
37.                Exception = t.Exception?.Message,
38.                CreatedAt = DateTime.Now.AddMilliseconds(1)
39.            });
40.             
41.            tasks = products.ToList();
42.            taskCache.Set("tasks", tasks, TimeSpan.FromMinutes(30));
43.        }
44. 
45.        return tasks;
46.    }
47. 
48.    public TaskViewModel Create(TaskViewModel task)
49.    {
50.        //task.ID = Guid.NewGuid();
51.        //product.CreatedAt = DateTime.Now;
52.        //product.Category = product.Category ?? new CategorySignalR() { CategoryID = 1 };
53. 
54.        //Clients.OthersInGroup(GetGroupName()).SendAsync("create", task);
55.        Clients.Others.SendAsync("create", task);
56. 
57.        return task;
58.    }
59. 
60.    public void Update(TaskViewModel task)
61.    {
62.        //Clients.OthersInGroup(GetGroupName()).SendAsync("update", task);
63.        Clients.Others.SendAsync("update", task);
64.    }
65. 
66.    public void Destroy(TaskViewModel task)
67.    {
68.        //Clients.OthersInGroup(GetGroupName()).SendAsync("destroy", task);
69.        Clients.Others.SendAsync("destroy", task);
70.    }
71. 
72.    //public string GetGroupName()
73.    //{
74.    //    return GetRemoteIpAddress();
75.    //}
76. 
77.    //public string GetRemoteIpAddress()
78.    //{
79.    //    return Context.GetHttpContext()?.Connection.RemoteIpAddress.ToString();
80.    //}
81.}

 

And i use Kendo Grid with SignalR datasource to show the hub data like this:

@(Html.Kendo().Grid<TaskViewModel>()
    .Name("TaskList")
    .Columns(columns =>
    {
        columns.Bound(t => t.Name).Width(140);
        columns.Bound(t => t.LastRunTime).Format("{0:yyyy-MM-dd hh:mm:ss}").Width(150);
        columns.Bound(t => t.Duration).HtmlAttributes(new { style = "text-align:right" }).Width(130);
        columns.Bound(t => t.Schedule).Width(100);
        columns.Bound(t => t.Status).Width(80);
        columns.Bound(t => t.Result).Filterable(false).Width(250);
        columns.Bound(t => t.Exception).Filterable(false).Width(150);
    })
    .Sortable()
    .Scrollable()
    .Filterable()
    .Resizable(resize => resize.Columns(true))
    .HtmlAttributes(new { style = "maxheight:530px;" })
    .DataSource(dataSource => dataSource
        .SignalR()
        .AutoSync(true)
        .Events(events => events.Push("onPush"))
        .Events(events => events.Error("onError"))
        .Sort(s => s.Add("CreatedAt").Descending())
        .Transport(tr => tr
            .Promise("hubStart")
            .Hub("hub")
            .Client(c => c
                .Read("read")
                .Create("create")
                .Destroy("destroy")
                .Update("update"))
            .Server(s => s
                .Read("read")
                .Create("create")
                .Destroy("destroy")
                .Update("update")))
        .Schema(schema => schema
            .Model(model =>
            {
                model.Id("ID");
                model.Field("ID", typeof(string)).Editable(false);
                model.Field("CreatedAt", typeof(DateTime)).Editable(false);
                model.Field("Name", typeof(string)).Editable(false);
                model.Field("LastRunTime", typeof(DateTime)).Editable(false);
                model.Field("Duration", typeof(TimeSpan)).Editable(false);
                model.Field("Schedule", typeof(string)).Editable(false);
                model.Field("Status", typeof(string)).Editable(false);
                model.Field("Result", typeof(string)).Editable(false);
                model.Field("Exception", typeof(string)).Editable(false);
            })
        )
    )
)

 

The hub is connected and the data are loaded, but not visible in the grid. I can see the like of my task in the grid because of mouse hovering but the fields are empty. (see screenshot1.png)

 

The secound problem i have is, that when the data is updated from server the client want to invoke "create" method. Why is the client doing this?

I get this error message: (see screenshot2.png)

 

And why is the ASP.NET Core Grid SignalR demo not working: https://demos.telerik.com/aspnet-core/grid/signalr

 

 

 

 

 
 
Michael
Top achievements
Rank 1
Veteran
Iron
 answered on 27 Feb 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?