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

kendo 2015.1.318 \ JQuery 1.10.2 \ MVC 5

@(Html.Kendo().MultiSelectFor(m => m.SelectedUsers)
.Name("SelectedUsersBox")
.DataTextField("DisplayName")
.DataValueField("UserId")
.BindTo(Model.AllUsers)
)

When there are pre-existing items in the box and additional items are added (by typing in some letters and allowing the list to be filtered), some of the existing items which don't match the filter will be removed from the underlying select list. This causes empty items to be posted with the form.

For example a preexisting list of Andrea, Bob. The underlying select list looks like:

<select name="SelectedUsersBox" id="SelectedUsersBox" style="display: none;" multiple="multiple" data-role="multiselect">
    <option value="1" selected="selected">Andrea</option>
    <option value="2">Allan</option>
    <option value="3" selected="selected">Bob</option>
</select>

If the letter "A" is typed into the box, "Andrea" is shown highlighted and "Allan" is not highlighted. As soon as the choice list is filtered to names beginning with "A", the underlying select list looks like (no name is selected\clicked):

<select name="SelectedUsersBox" id="SelectedUsersBox" style="display: none;" multiple="multiple" data-role="multiselect">
    <option value="1" selected="selected">Andrea</option>
    <option value="2">Allan</option>
    <option selected="selected"/>
</select>

If "Allan" is selected the list looks like:

 <select name="SelectedUsersBox" id="SelectedUsersBox" style="display: none;" multiple="multiple" data-role="multiselect">
    <option value="1" selected="selected">Andrea</option>
    <option value="2" selected="selected">Allan</option>
    <option selected="selected"/>
</select>

If the form is posted at this point "Bob" is not one of the selected choices. In fact, one of the selected choices has no value!

Is this expected behavior? Am I missing a configuration\setting\property on the MultiSelectFor?

 

PS: If the user clicks on the box which brings up the entire menu, the select list is rebound and all of the values show up. Unfortunately, having a person click on the box to bring up the menu before submission is not a suitable solution.

 

 

 

Georgi Krustev
Telerik team
 answered on 25 Jun 2015
2 answers
165 views

Hi,

I have a problem that i'm not entirely sure how to describe.  So, starting from the beginning: I have a view that has a list of parts and projects.  When a part or project is clicked, a kendo window is opened and loads a partial view containing information about the part or project and other kendo objects (buttons, text boxes, drop downs).  The first time a project/part is clicked the window loads fine, and even if the user only clicks projects the window loads fine.  But if a user clicks a project/part, closes the window, and then clicks the other (either a project or a part) all kendo objects in the window stop working.  They lose their styling and their functionality.  For example, drop down boxes are no longer drop downs but just a textbox, and not  a kendo text box, just a regular one.  Buttons turn a dark blue color, lose their styling, and lost their function. And text boxes lose their styling.  I've had similar problems before, and I fixed it with name changes of the objects or fixing the javascript functions they link too.  Neither worked in this case.  I'm not sure what else to try, but all help is welcomed.

 I'm reluctant to post all of my code because of my NDA (I'm an intern) but here is the code of the buttons for one of my partial views.  The names of all the objects in both windows are different, as in a button that serves the same purpose and displays the same info in partial1 is named differently than in partial2, and neither share a name with an object in the rest of the project.

  <div style="width:100%;text-align:center;">
        <div style="display:inline-block; vertical-align:central">
            <table>
                <tr>
                    <td>
                        @Html.Kendo.Button.Name("test1").Content("Add Costs").Events(Sub(events) events.Click("enterActualInfo"))
                    </td>
                
                    <td>
                        @Html.Kendo.Button.Name("test2").Content("View Change History").Events(Sub(events) events.Click("showProjectHistory"))
                    </td>
                
                    <td>
                        @Html.Kendo.Button.Name("test3").Content("Target").Events(Sub(events) events.Click("addTarget"))
                    </td>
                </tr>                
            </table>
        </div>
    </div>
    
   
<script>
    function enterActualInfo() {
        debugger;
        alert("test1");
    }
    function showProjectHistory() {
        alert("test2");
    }
    function addGPC() {
        alert("test3");
    }
</script>

 

I noticed some differences between buttons that work and buttons that don't in the IE DOM Explorer. It seems that the objects are not inheriting the kendo properties.       Functioning button: <button tabindex="0" class="k-button" id="addPart" role="button" aria-disabled="false" data-role="button">Add Part</button>Not functioning button: <button  id="addPart" role="button">Add Part</button> 

I've attached pictures of the difference between functioning and non functioning buttons.

 

Thanks in advance!

 

-Eric

 

Eric
Top achievements
Rank 1
 answered on 25 Jun 2015
5 answers
582 views

Hi Team,

Please provide the sample code for kendo grid  cascading drop down using model. 

And also please share, how to get the entire source(all rows of existing grid) of grid.

 

Thanks

Senthilkumar N

Atanas Korchev
Telerik team
 answered on 25 Jun 2015
1 answer
198 views

Hi Team, 

 Please let me know how to get the foreign key drop down (InstanceTypeIds) selected value using Jquery to send input value to cascading drop down (InstanceId) of grid row.      @(Html.Kendo().Grid<Flextronics.DevFactory.Ingrex.Entity.IngrexDataEntity.IngrexGlobalNewRequest>()

    .Name("GridGlobalNewRequest")
    .Columns(columns =>
    {
        columns.ForeignKey(p => p.InstanceTypeIds, (System.Collections.IEnumerable)ViewData["listofinstanceTypes"], "InstanceTypeId", "InstanceTypeName").Title("InstanceType").Width(120).EditorTemplateName("InstanceTypeIds");
        columns.ForeignKey(p => p.InstanceId, (System.Collections.IEnumerable)ViewData["listofInstance"], "InstanceId", "InstanceNm").Title("Instance").Width(120).EditorTemplateName("InstanceId").Width(120);
        columns.Bound(p => p.StartCompany).Title("Start").Width(90);
       // columns.Command(command => command.Edit()).Width(80).HtmlAttributes(new { style = "text-align:center" });
        columns.Command(command => command.Destroy()).Width(80).HtmlAttributes(new { style = "text-align:center" });
    })
            .ToolBar(toolbar => {
                toolbar.Create();
                toolbar.Save();
            })

    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable(page => page.Enabled(true).PageSizes(new int[] { 10, 50, 100, 500}))
    .Sortable()
    .Scrollable()

    .DataSource(dataSource => dataSource
                .Ajax()

                .PageSize(20)                

                .Model(model =>
                {
                    model.Id(p => p.InstanceTypeIds);
                    model.Field(p => p.InstanceId);
                    model.Field(p => p.InstanceTypeIds);
                })


            //.Create(update => update.Action("EditingInline_Create", "NewRequest"))
            //.Read(read => read.Action("EditingInline_Read", "NewRequest"))
            //.Update(update => update.Action("EditingInline_Update", "NewRequest"))
            //.Destroy(update => update.Action("EditingInline_Destroy", "NewRequest"))

                .Create("EditingInline_Create", "NewRequest")
                .Read("EditingInline_Read", "NewRequest")
                .Update("EditingInline_Update", "NewRequest")
                .Destroy("EditingInline_Destroy", "NewRequest")

    )

    )

Kiril Nikolov
Telerik team
 answered on 25 Jun 2015
5 answers
1.7K+ views

I'm using batch-mode and server-side operations. it looks like you do some special things in the parameterMap function (behind the scenes) when the operation == "read" and filtering is applied.  For example, when a filter is applied to a column, it seems you put the filtering parameters in a special format before sending to the server. Even though I'm using the MVC wrappers, I can still wire-up the parameterMap feature using JavaScript. I did this for ONLY the "destroy" operation (I want to send just the IDs and not the models), but then the "read" operation no longer works when filtering is applied, because my use of parameterMap overwrites what you are doing for "read".

Can I still use the parameterMap feature for only "destroy", and not interfere with what you do with "read" ?  My desire is to send just the IDs and not the models when batch-saving deletes.

Curt Rabon
Top achievements
Rank 1
Veteran
 answered on 24 Jun 2015
2 answers
371 views

I have a chart with many colors. The tooltip should appear as black or white depending on the background color of the chart's bar. The only option I can think of is handle this with the series.name. But nothing works.

This code does accurately put a white or a black piece of text onto the screen as a tooltip:

.Tooltip(tooltip => tooltip
   .Visible(true)
   .Template("# if ((series.name === 'foo') || (series.name === 'bah')) { return '<strong style=\"color: black\">bar</strong>'; } else { return '<strong style=\"color: white\">bar</strong>'; } #")
)

However, once I plug in #= series.name # #= value # instead of bar the function breaks down and it no longer works.

Next, I tried both SharedTemplate and Template as such (one at a time of course):

.Tooltip(tooltip =>
   tooltip.Visible(true).Template("mytemplate")
   tooltip.Visible(true).SharedTemplate("mytemplate")
)

<script id="mytemplate" type="text/x-kendo-template">
   # if ((series.name === 'foo') || (series.name === 'bah')) { #
      <strong style="color: black">bar</strong>
   # } else { #
      <strong style="color: white">bar</strong>
   # } #
</script>

This didn't do anything and instead displayed a tooltip of "mytemplate".

Is this possible to do? If not is there any kind of work around?

Paul
Top achievements
Rank 1
 answered on 24 Jun 2015
3 answers
212 views

hello, I have using the scheduler and when I inspect the control in the javascript console I can see that there is data in the resources.datasource object but for some reason the resources are not displaying in the Timeline. I'm just trying to load resources right now without events. Do I have to have events for the resources to load properly. In the old webforms scheduler you didn't need that. Also, once loaded how do I change them dynamically so that users can manipulate the timeline and look at specific combination of resources. 

 

 @(Html.Kendo().Scheduler<Avianis.Models.Scheduler.AppointmentViewModel>()
        .Name("scheduler")
        .Date(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day))
        .Views(views =>
        {
            views.TimelineView(timeline => timeline.EventHeight(50));
            views.TimelineWeekView(timeline => timeline.EventHeight(50));
            views.TimelineMonthView(timeline => timeline.EventHeight(50));
        })
        .Resources(resource => resource.Add(m => m.ResourceID)
                     .Title("Aircraft")
                     .Name("Aircraft")
                     .DataTextField("Name")
                     .DataValueField("ID")
                     .DataSource(source => source
                         .Read("GetResources", "Calendar"))
        )
        .DataSource(d => d
                .Model(m =>
                {
                    m.Id(f => f.MeetingID);
                    m.Field(f => f.Title).DefaultValue("No title");
                    m.RecurrenceId(f => f.RecurrenceID);
                    m.Field(f => f.Title).DefaultValue("No title");
                })
                .Read("Aircraft_Read", "Calendar")
        )
    )

Vladimir Iliev
Telerik team
 answered on 24 Jun 2015
3 answers
110 views

Hello, is there an option to remember the state of checkbox'ed items in the TreeView when loading them from the server? Such as when repopulating a complex control the TreeView is a part of?

 Thanks in advance for your speedy reply, Telerik! :)

Vladimir Iliev
Telerik team
 answered on 24 Jun 2015
1 answer
660 views

I’m using MVC Kendo grid and few drop down lists as filters and search button. Grid is bound using Ajax. The filters are defined outside of the grid. When user clicks on the search button i am passing the selected filter values to action method as Model, do the search and return the result. This is working fine when user selects the filter.
However, One of the filter is required filter, so I have [Required] attribute on the model’s property. When user don’t select the required filter, it makes the GetData() action method as expected, I see ModelState is NOT valid as expected.
But here im not sure what should I return when Model is not valid,
Questions:
I have validation summary on the layout page, how do I show model error in ValidationSummary without clearing the grid?When action method returns error, I don’t want to clear the existing result in the Grid. The error should display on top of the page.

Note:  For brevity purpose my sample below showing only one filter. Also I’m not worrying about client side validation.

 Layout Page

 

<html>
<head>
    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/kendo/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/kendo")
    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/jqueryval")
</head>
<body>   
    <div class="container body-content">     
        @Html.ValidationSummary()
        @RenderBody()
        <footer></footer>
    </div>
    @RenderSection("scripts", required: false)
</body>
</html>

 Index Page

@model MyModel
            @{
                ViewBag.Title = "Index";
                Layout = "~/Views/Shared/_Layout.cshtml";
            }
            <h2>Index</h2>
            <div>
                <br />
                @Html.ListBoxFor(x => x.SelectedIDs, new MultiSelectList(Model.States, "ID", "Name"))
                @Html.ValidationMessageFor(m => m.SelectedIDs)
            </div>
 
            <input id="btnSearch" type="submit" width="100" value="Search" />
            @(Html.Kendo().Grid<Person>()
               .Name("grid")
               .Columns(col =>
               {
               col.Bound(p => p.ID);
               col.Bound(p => p.Name);
               })
               .DataSource(ds =>
               ds.Ajax()
               .Read(r => r.Action("GetData", "Working"))
               .PageSize(3))
               .Pageable()
               .Sortable()
               .AutoBind(false)
            )
            <script src="~/Scripts/Working.js"></script>

 

 JavaScript

$(function () {
 
                var myModel = {
                    SelectedIDs: []
                };
                
                var dataSource = $("#grid").data("kendoGrid").dataSource;
                dataSource.transport.options.read.data = getFilters;
 
                $("#btnSearch").click(function () {
                    myModel.SelectedIDs = $("#SelectedIDs").val();
                    $("#grid").data("kendoGrid").dataSource.read();       
                    $("#grid").data("kendoGrid").refresh();
                })
 
                function getFilters() {
                    return myModel;
                }
            })

 Controller

public class WorkingController : Controller
            {
                public ActionResult Index()
                {
                    var model = new MyModel();
                    return View(model);
                }
                 
                public ActionResult GetData([DataSourceRequest]DataSourceRequest request, MyModel model)
                {
                    if (!ModelState.IsValid)
                    {
                        // What should i return here so that Model error message will appear in ValidationSummary ???
                    }
 
                    return Json(MockData.GetPersons().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                }
            }

 

Model

public class MyModel
    {
        [Required(ErrorMessage = "State is required.")]
        public int[] SelectedIDs { get; set; }
 
        public IEnumerable<State> States
        {
            get
            {
                return MockData.GetStatesWithAbbr();
            }
        }
 
        public IEnumerable<Person> Persons { get; set; }
    }

Laksh
Top achievements
Rank 1
 answered on 23 Jun 2015
1 answer
2.2K+ views
I'm looking to make a custom header for my grid. In the end, I want it to have the title, sorting arrows, and a custom filter image button that bypasses the built-in filtering of the grid.
To start off though, how do I get it to display the title?
01.Html.Kendo().Grid<dynamic>()
02.    .Name("grid")
03.    .Filterable(filter => filter.Enabled(false))
04.    .DataSource(ds => ds.Ajax().Read(read => read.Action("action", "controller")))
05.    .Columns(columns =>
06.    {
07.        columns.Bound("field")
08.            .Title("title")
09.            .Sortable(true)
10.            .HeaderTemplate("???");
11.    });
Dimo
Telerik team
 answered on 23 Jun 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
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
DateTimePicker
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?