Telerik Forums
UI for ASP.NET MVC Forum
4 answers
579 views

Hi,

I have specific requirements for keyboard navigation within a grid. I have implemented custom navigation in the grid that works very well for text box inputs.  However, it does not work well when I navigate across cells containing dropdownlists, as the arrow keys change the values in the list as the user navigates away from these cells.

 

I use the following function to capture keydown events within the grid:

 

            // Key-down event handler to provide custom navigation within the grid.
            $("#auto_gen_conn_mngr_grid table").on("keydown", "td", function (e) {
                switch (e.keyCode ? e.keyCode : e.which) {
                    case kendo.keys.UP:
                        e.preventDefault();
                        e.stopPropagation();
                        NavigateVertically(this, navDirection.UP);
                        break;
                    case kendo.keys.ENTER:
                    case kendo.keys.DOWN:
                        e.preventDefault();
                        e.stopPropagation();
                        NavigateVertically(this, navDirection.DOWN);
                        break;
                    case kendo.keys.LEFT:
                        e.preventDefault();
                        e.stopPropagation();
                        NavigateHorizontally(this, navDirection.LEFT);
                        break;
                    case kendo.keys.TAB:
                        e.preventDefault(); // Keep Tab from navigating to elements outside of the grid.
                        e.stopPropagation();
                    case kendo.keys.RIGHT:
                        e.preventDefault();
                        e.stopPropagation();
                        NavigateHorizontally(this, navDirection.RIGHT);
                        break;
                }
            });

 

The problem is, that before this function executes, the dropdown list has already received the 'select' event and modified it's selected item. I can add an event handler to my list's editor template, which uses preventDefault() to cancel the selection. But I can't tell how to differentiate between events that should vs. should not modify the selection.

 

I would like the selection to be modified only when the user uses holds the 'ctrl' key while pressing the navigational key (i.e. arrows, tab, or enter) or uses a mouse click to click the new selection.

 

I can do this in one of two ways, but I am stuck on both:

method 1: intercept the keydown event before it is handled at the dropdownlist.

problem 1: the event has already gone to the dropdownlist before I capture it, using the code above.

 

method 2: add a handler in the list's editor template for the 'select' event, then use e.preventDefault() when the user is pressing a navigational key without holding down the 'ctrl' key.

problem 2: I don't know if it is possible to get the keystroke information from the context of the list editor's onSelect handler.

 

And finally, if there is no way to accomplish either of the above, disabling keyboard navigation within the dropdown list would be an acceptable compromise. This is not the preferred approach, but if it is possible to configure the dropdownlist to only accept mouse clicks in order to change the selection, that would enable the users to navigate the grid with the keyboard without modifying the selections in the dropdown lists.

 

Thanks,

Ryan

Ryan
Top achievements
Rank 1
 answered on 10 Aug 2018
3 answers
490 views

Hi,

Is it possible to prevent certain scheduled tasks from being deleted in the user interface?

Ivan Danchev
Telerik team
 answered on 10 Aug 2018
3 answers
546 views

     I'm looking to show/hide the "require input" asterisk (*) once a value is not selected/selected. Is there a way to do this with MultiSelect? I see that there are onSelectAll & onDeselectAll but there's no function that handles onSelect of any value -- how would I handle this with MultiSelect?

 

My current markup:

<div id="@(Model.Name + "InitialLoading")" class="CheckboxListInitializing"><img style="height: 13px;margin-right: 5px;" src="../Content/images/loading.gif">Loading...</div>
                     <span id="@(Model.Name + "Loading")" style="display:none;position: absolute;">
                         <img src='../Content/kendo/2016.1.406/Bootstrap/loading.gif' />
                     </span>
                     <script>
                     $(function ()
                     {
                         $("#@(Model.Name)").multiselect({
                             includeSelectAllOption: true
                             //, selectAllValue: "[All]"
                             , selectAllText: "(Select All)"
                             , enableFiltering: true
                             , enableCaseInsensitiveFiltering: true
                             , onDropdownShown: function (event) {
                                 this.$select.parent().find("button.multiselect-clear-filter").click();
                                 this.$select.parent().find("input[type='text'].multiselect-search").focus();
                                 $(".@(Model.ItemName)").hide();
                             }
                             , nonSelectedText: "  "
                             , onInitialized: function () { $("#@(Model.Name)InitialLoading").hide(); $(".@(Model.ItemName)").hide(); }
                             , onChange: function () { ListChangeHandler( $("select[id=@Model.Name]"));}
                             , onSelectAll: function () { ListChangeHandler( $("select[id=@Model.Name]"));  $(".@(Model.ItemName)").hide();}
                             , onDeselectAll: function () { ClearWholeList($("select[id=@Model.Name]")); ListChangeHandler($("select[id=@Model.Name]")); $(".@(Model.ItemName)").show(); }
                             @*@(!string.IsNullOrEmpty(Model.ChangeHandler) ? ", onChange: " + Model.ChangeHandler + ", onSelectAll: " + Model.ChangeHandler + ", onDeselectAll: " + Model.ChangeHandler : "")*@
                         });
 
                         LoadListBox("@(!string.IsNullOrEmpty(Model.CascadedFromName) ? Model.Name : "")");
 
                     })
                     </script>

 

 

Ivan Danchev
Telerik team
 answered on 10 Aug 2018
4 answers
206 views

Hi,

I have some issues with sass themes.

My context : Asp.Net MVC & scss files from https://github.com/telerik/kendo-theme-default

 

1) IE11 & grid

There are positioning problems with the filter, column and refresh icons on the grid (cf themebuilder & filter icon on header).
One of them comes from the use of nested calc for the bottom property

 

2) IE11 & charts

When launching the themebuilder/asp.net  on IE11, the first time the charts don't display correctly.
If we change the theme via color swatch, they are OK.

 

3) Tabstrip color

When you put an item (Treeview, ...) in a tab, it takes the main color ($accent) instead of the text color ($text-color).

This is due to the class '.k-tabstrip .k-item' which must be replaced by '.k-tabstrip .k-tabstrip-items .k-item'

 

Regards

Ivan Zhekov
Telerik team
 answered on 10 Aug 2018
5 answers
1.4K+ views

I want the grid to be responsive just like this page (https://demos.telerik.com/aspnet-mvc/grid), but I don't see any sample code that make it works. 

Here is my code:

@{
    Html.Kendo().Grid(Model)
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(request => request.Id).Filterable(ftb => ftb.Cell(cell => cell.Template("integerFilter").Operator("eq").ShowOperators(false)));
            columns.Bound(request => request.Requestor).Encoded(false);
            columns.Bound(request => request.RequestDate).Format("{0:MM/dd/yyyy}").Encoded(false).HeaderHtmlAttributes(new { @class = "hidden - xs" }).HtmlAttributes(new { @class = "hidden - xs" });;
            columns.Bound(request => request.ChangeStartDateTime).Format("{0: M/d/yyyy h:mm tt}").Encoded(false).HeaderHtmlAttributes(new { @class = "hidden - xs" }).HtmlAttributes(new { @class = "hidden - xs" });
            columns.Bound(request => request.ChangeEndDateTime).Format("{0: M/d/yyyy h:mm tt}").Encoded(false).HeaderHtmlAttributes(new { @class = "hidden - xs" }).HtmlAttributes(new { @class = "hidden - xs" });
            columns.Bound(request => request.RequestSubject).Encoded(false).HeaderHtmlAttributes(new { @class = "hidden - xs" }).HtmlAttributes(new { @class = "hidden - xs" });
            columns.Bound(request => request.CurrentStatus).Encoded(false);
            columns.Bound(request => request.CompletedFlag).Encoded(false);
        })
.Filterable(filterable => filterable
   .Extra(false)
   .Operators(operators => operators
       .ForString(str => str.Clear()
           .Contains("Contains")
           .StartsWith("Starts With "))
       .ForNumber(num => num.Clear()
       .IsEqualTo("Equal to"))
       .ForDate(d => d.Clear())
    )
   .Mode(GridFilterMode.Row))
.Pageable(pageable => pageable
   .Refresh(true)
   .PageSizes(true)
   .ButtonCount(5))
.Resizable(resize => resize.Columns(true))
.Selectable()
.Sortable()
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(request => request.Id))
)
.Render();
}
<script>
    function integerFilter(e) {
        e.element.kendoNumericTextBox({
            spinners: false,
            format: "#",
            decimals: 0
        });
    };  
    $(function() {
        $("div.k-grid-content").find("col").addClass("hidden-xs");
        $("div.k-grid-header").find("col").addClass("hidden-xs");
    });

</script>

Please see attached image.  I would like to show all columns from desktop but should be able to hide some columns from smart devices.  How can I accomplish the followings? 

1) Responsive Grid

2) Freeze curtain grid columns

 

Thank you very much in advance!

Anieda

 

 

Anieda Hom
Top achievements
Rank 1
 answered on 09 Aug 2018
3 answers
614 views

Hello Telerik Team,

 

How can I set scheduler title date range to the current week (dynamic)?  How to set the Agenda view to default view whenever the calendar load?  How to make the text with all day schedule to hyper link (however, this text is linkable in agenda view)? 

 

This is the code:

@(Html.Kendo().Scheduler<HomeTaskViewModel>()
                .Name("scheduler")
                .Date(new DateTime(2018, 5, 7))
                .StartTime(new DateTime(2018, 5, 7, 0, 00, 00))
                .EndTime(new DateTime(2018, 5, 7, 23, 59, 59))
                .Editable(false)
                .Height(600)
                .EventTemplate(
                    "<div class='task-template'>" +
                    //"#= kendo.toString(start, 'hh:mm') # - #= kendo.toString(end, 'hh:mm') #" +
                    //"<br />" +
                    //"<a href='#= Url #'>#= description #</a>" +
                    "<a href='" + @Url.Action("Read","Request") + "/" + "#= RequestId #'>#= description #</a>" +
                    "</div>")
                .Views(views =>
                {
                    views.DayView();
                    views.WorkWeekView(workWeekView => workWeekView.Selected(true));
                    views.WeekView();
                    views.MonthView();
                    views.AgendaView();
                    //views.TimelineView();
                })
                .Resources(resource =>
                {
                    resource.Add(m => m.GroupId)
                      .Title("Owner")
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .DataColorField("Color")
                      .BindTo(Model.Select(x => new {Text = x.GroupName, Value = x.GroupId, Color = x.Color}));
                })
                //.BindTo(Model)
                .DataSource(d => d
                           .Model(m => {
                               m.Id(f => f.RequestId);
                               m.Field(f => f.Description).DefaultValue("No title");
                               m.Field(f => f.GroupId).DefaultValue(1);
                               m.Field(f => f.Title).DefaultValue("No title");
                               m.RecurrenceId(f => f.RecurrenceID);
                           })
                           .Read("ReadRequests", "Home", "Scheduler")
                      )
                )
<script type="text/javascript">
    $(function () {
        $(".GroupNames :checkbox").change(function (e) {
            var checked = $.map($(".GroupNames :checked"), function (checkbox) {
                return parseInt($(checkbox).val());
            });
            var filter = {
                logic: "or",
                filters: $.map(checked, function (value) {
                    return {
                        operator: "eq",
                        field: "GroupId",
                        value: value
                    };
                })
            };
            var scheduler = $("#scheduler").data("kendoScheduler");
            scheduler.dataSource.filter(filter);
        });
    })
</script>

Thank you very much in advanced for your help!

Anieda

Anieda Hom
Top achievements
Rank 1
 answered on 09 Aug 2018
4 answers
219 views

Without getting into why - I am setting the DataSource.Read.Data function in javascript after the grid is initialized.  (using .AutoBind(false) so it doesn't load until after I set the Data function)

$("#myGrid").data("kendoGrid").dataSource.transport.options.read.data = function() {
  return { prop: "value" };
};

 

 

This works fine when loading the grid items. However, when I do it this way, the column filters that are .Multi(true) do NOT use this function, and pass no variables to the Action method. 

How do I get the calls to load the filters to also use this function for parameters?

Thanks

Tsvetina
Telerik team
 answered on 09 Aug 2018
10 answers
944 views

In my application, I need to assign items to groups. I would like to use the ListBox widget (https://demos.telerik.com/aspnet-mvc/listbox) because I like its built-in transfer controls. This would allow me to display the unassigned items in one ListBox, the assigned items in another ListBox, and then transfer the items from Unassigned to Assigned, or vice versa.

However, I may have several thousand items in a list and I doubt it would be performant for the ListBox to show all of these at once. Is there a way to add paging to the ListBox? If not, is there a different widget you would suggest? I did see a StackOverflow article where someone used two Kendo grids for this purpose. If that is the best option, do you have a complete example?

Mike
Top achievements
Rank 1
 answered on 09 Aug 2018
3 answers
324 views

I hope I am explaining this correctly.

I am developing a Scheduling platform for my company.  Everything is going well, except for one thing.  Our users can take half days, or get meeting requests that can split one of their recurring shifts.

For example:

User A has a repeating schedule M-F 8 - 5
A request is submitted so that on Wednesday, he has a meeting from 2-3.

I am unsure how to handle this type of exception, I would like for his Wednesday schedule to show him working 8-2, then meeting, then 3-5 and not two entries showing a meeting and then his schedule.

Is this possible using Kendo or even in the RFC 5545 standard?

Is this going to have to be done programatically in that I search my calendar for the user, find his schedule and parse his recurrence than figure out what day he works and hours and enter multiple events so that there would be 3 exceptions for the scenario listed above?  (one for 8-2, one for 2-3, and one for 3-5)

Or is there a way to create the new meeting request from 2-3 then have that appointment's ID excepted from the recurrence rule?

Nencho
Telerik team
 answered on 09 Aug 2018
2 answers
1.0K+ views

Hallo,

i'm fairly new to Kendo UI MVC and am trying to rebuild an old app with the kendo grid in .net.

What i am trying to do is: Use the Grid in batch editing mode and allow in line editing on the client side. I have some problems with the client side validation of the grid data. The grid is filled with data from the Viewmodel. If the user hit's the "kontigente speichern" button i want to validate the existing rows, because the HOTEL field is empty by default, but the  $('#kontingenteHinzu').data().kendoGrid.editable.validatable.validate() method always comes back as "true" and try's to submit the grid data/ the page is reloaded. This happens although the HOTEL field is marked as required in the mvc view model. Additionally the KONTINGENT field ist only validated once it is clicked into, otherwise the validate() methoded just reloades the page. I do not use the build in "save changes" method because we use a seperate button in oure design/layout. If the user hit's the "+ Kontigent hinzufügen" button the existing rows should be validated bevor he can do that but i'm not sure how to accomplish this since the existing rows always return true with the validate() method, although they are not "valid".

Maybe someone has an idea how to get this working or even an easyer way with the build in grid methodes.

Kind regards

Marcus

Viewmodel

public class KontingentBuchung
 {
     public int LehrgangId {get;set;}
     public List<HotelKontigent> Kontingente {get;set;}
     public bool ShowModal {get;set;}
     public bool Success {get;set;}
     public string Message {get;set;}
 
 }
public class HotelKontigent
    {
        public int Id { get; set; }
 
        [Required(ErrorMessage ="Bitte ein Hotel eintragen")]
        public string Hotel {get;set;}
        [Required]
        [Range(1, Int32.MaxValue, ErrorMessage = "Bitte ein Kontingent eintragen")]
        public int Kontingent {get;set;}
        public DateTime Zeitraum {get;set;}
        public DateTime? Frist {get; set;}
    }

cshtmlview

@model Hotelinformationen.Models.KontingentBuchung
 
@{
    Layout = "~/Views/Shared/_BCWLayout.cshtml";
    bool hasFrist = false;
    DateTime firstDay = DateTime.Now;
    DateTime frist = DateTime.Now;
    var id = Model.LehrgangId;
    var first = Model.Kontingente.FirstOrDefault();
    if (first != null)
    {
        hasFrist = first.Frist.HasValue;
        firstDay = first.Zeitraum;
        if (hasFrist)
        {
            frist = first.Frist.Value;
        }
    }
 
     
}
@Model.LehrgangId
<div class="panel panel-primary panel-content z-depth-1 fade-in">
<div class="panel-heading">Veranstaltungen ohne Kontingente</div>
<div class="panel-body">
    <div class="row">
        <div class="col-xs-10 col-xs-push-1">
            @(Html.Kendo().Grid(Model.Kontingente)
                  .Name("kontingenteHinzu")
                  .Columns(cs =>
                  {
                      cs.Bound(c => c.Hotel).Width(500);
                      cs.Bound(c => c.Zeitraum).Format("{0:dd.MM.yyyy}").EditorTemplateName("Date").Width(150);
                      cs.Bound(c => c.Kontingent).Width(500);
                      cs.Bound(c => c.Frist).Format("{0:dd.MM.yyyy}").EditorTemplateName("Date").Width(150);
                      cs.Command(command => { command.Destroy().IconClass("fas fa-trash fa-2x").Text(" "); }).Width(75);
                  })
                  .ToolBar(toolBar =>
                  {
                      toolBar.Create().Text("Kontingent hinzufügen");
                  })
                  .Editable(editable => editable.Mode(GridEditMode.InCell)
                      .DisplayDeleteConfirmation(false)
                      .CreateAt(GridInsertRowPosition.Bottom))
                  .DataSource(ds => ds.Ajax()
                      .Batch(true)
                      .PageSize(20)
                      .Model(model =>
                      {
                          model.Id(k => k.Id);
                          model.Field(k => k.Kontingent).DefaultValue(0);
                          model.Field(f => f.Frist).Editable(false).DefaultValue(frist);
                          model.Field(k => k.Zeitraum).DefaultValue(firstDay);
 
                      })
                      .ServerOperation(false)
                  ))
        </div>
    </div>
</div>
</div>

 

marcus
Top achievements
Rank 2
 answered on 09 Aug 2018
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
DropDownButton
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?