Telerik Forums
UI for ASP.NET MVC Forum
2 answers
628 views
Hi,

I need to attach an autocomplete to  "ManagerName" and selected manager employeeId should be populated to "EmployeeId".

CSHTML
---------
@Html.TextBoxFor(m => m.ManagerName)
@Html.TextBoxFor(m => m.EmployeeId)

JavaScript
---------------
 $(function () {

 var GetManagerURL = '@Url.Action("GetManager", "Employee", new { Area = "Employee" })';

$("#ManagerName").kendoAutoComplete({
            placeholder: "Enter your manager name",
            minLength: 3,
            dataTextField: "EmployeeName",            
            dataSource: {
                transport: {
                    read: GetManagerURL,
                    parameterMap: function (data) {
                        return {
                            input: $("#ManagerName").val(),
                            take: data.take,
                            skip: data.skip
                        };
                    }
                },               
                select: onManager_select,               
                serverFiltering: true,
                serverPaging: true,
                pageSize: 10
            }
        });

});

  function onManager_select(e) { // debugger is not hitting this function
        alert("select");
        //debugger;
        var selectedOne = $("#ManagerName").dataItem(e.item.index());
        $("#EmployeeId").val(selectedOne.EmployeeId);

    }


Controller
-------------

public JsonResult GetManager(string input, int take, int skip)
       {
            List<EmployeeViewModel> mgrList = new List<EmployeeViewModel>();
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 1, EmployeeName = "Prashad" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 2, EmployeeName = "Ashreewad" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 3, EmployeeName = "Sathish" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 11, EmployeeName = "Prashad1" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 21, EmployeeName = "Ashreewad1" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 31, EmployeeName = "Sathish1" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 12, EmployeeName = "Prashad2" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 22, EmployeeName = "Ashreewad2" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 32, EmployeeName = "Sathish2" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 13, EmployeeName = "Prashad3" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 23, EmployeeName = "Ashreewad3" });
            mgrList.Add(new EmployeeViewModel() { EmployeeId = 33, EmployeeName = "Sathish3" });
            try
            {
                if (!string.IsNullOrWhiteSpace(input))
                {

                    if (mgrList != null)
                    {
                        mgrList = mgrList.Where(e => e.EmployeeName.ToLower().StartsWith(input.ToLower())).Take(take).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                //
                return null;
            }
            return Json(mgrList, JsonRequestBehavior.AllowGet);
        }

-----------------------------------------------------------

AutoComplete is populated fine.
But when I select an item from the populated list it is not hitting the "select" event function.

So how can we get selected Employee Object?

Thanks & Regards,
Kumar

Dimiter Madjarov
Telerik team
 answered on 01 May 2014
5 answers
2.1K+ views
All -

I have a multiselect and I would like to clear the "selected values" and bring the control back to its default state once I click the Add button. (see images for a better understanding). When viewing the images:

1. "1-DefaultState.png" shows what the control looks like on load.
2. "2-Add Clicked.png" shows what the control looks like after I select an item and click "Add"
3. Essentially, after I click the "Add" button I want the multi select control to look like it does in the image 1-DefaultState.png" 

I have tried several options such as changing the values array to null, but nothing seems to work.

Thanks,
Andrew
Tyrone
Top achievements
Rank 1
 answered on 30 Apr 2014
1 answer
541 views
Hi,

I have a grid of records that are editable (popup). 

When I click edit and launch the popup editor template I have another grid that is populated by passing a value to a controller method. I'm trying to access this value from the ViewModel that the original selected record is built from.

I understand the editor template serialization and there has been a similar question posted here: http://www.telerik.com/forums/model-not-initialized-in-grid-popup-editor-

Does anyone know how to access the bound data from within a template?

Regards
Petur Subev
Telerik team
 answered on 30 Apr 2014
4 answers
545 views
I upgrade my kendo UI for MVC to 2014.1.415

I want to add rule to the masked text box.  So I copied the example from this page:
http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/maskedtextbox/overview

Here is my view:
--------------------
@{
    ViewBag.Title = "MaskedTextWithRule";
}

<h2>MaskedTextWithRule</h2>


<div class="demo-section">
    <h2>Mask Input </h2>
    <ul id="fieldlist">
        <li>
            <label for="phone_number">Phone number:</label>
            @(Html.Kendo().MaskedTextBox()
                  .Name("phone_number")
                  .Mask("(999) 000-0000")
                  .Value("555 123 4567")
            )
        </li>

        <li>
            @(Html.Kendo().MaskedTextBox()
                  .Name("maskedtextbox")
                  .Rules(rules => {
                      rules.Add("~", "/[+-]/");
                  })
                  .Mask("~0000") //Set a mask with custom rule
            )
        </li>

    </ul>
</div>

<style>
    .demo-section {
        width: 300px;
        margin: 35px auto 50px;
        padding: 30px;
    }

    .demo-section h2 {
        text-transform: uppercase;
        font-size: 1.2em;
        margin-bottom: 10px;
    }

    #fieldlist
    {
        margin:0;
        padding:0;
    }

    #fieldlist li
    {
        list-style:none;
        padding:10px 0;
    }

    #fieldlist label {
        display: inline-block;
        width: 130px;
        margin-right: 5px;
        text-align: right;
    }
</style>

---------------------------------------------------

I compiled the project without problem, but when I run it, I got the following error
--------------------------------------------
Server Error in '/' Application.Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1502: The best overloaded method match for 'Kendo.Mvc.UI.Fluent.MaskedTextBoxRulesBuilder.Add(char, string)' has some invalid arguments

Source Error:

Line 22: .Name("maskedtextbox")
Line 23: .Rules(rules => {
Line 24: rules.Add("~", "/[+-]/");
Line 25: })
Line 26: .Mask("~0000") //Set a mask with custom rule


Dongfen
Top achievements
Rank 1
 answered on 29 Apr 2014
2 answers
397 views
Message: Exception: System.InvalidCastException: Unable to cast object of type 'Kendo.Mvc.CompositeFilterDescriptor' to type 'Kendo.Mvc.FilterDescriptor'.
   at Kendo.Mvc.Infrastructure.Implementation.FilterNodeVisitor.Visit(PropertyNode propertyNode)
   at Kendo.Mvc.Infrastructure.Implementation.OrNode.Accept(IFilterNodeVisitor visitor)
   at Kendo.Mvc.UI.DataSourceRequestModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
   at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
Grahame
Top achievements
Rank 2
 answered on 29 Apr 2014
3 answers
139 views
I use latest Telerik release (423) and get different rendering of the ddList in a project. First I thought I had done something wrong, this could happen sometimes. However I started a new project with the Telerik mvc5 template and got same result.
Theme bootstrap.
IE and firefox and Safari ok Chrome not so good.(latest versions)

Jan Olsmar
Top achievements
Rank 1
 answered on 29 Apr 2014
2 answers
339 views
Hello

My code is based on this thread:
http://www.telerik.com/forums/multiple-row-selection-without-holding-ctrl-key

I have a grid:
01.@(Html.Kendo().Grid(Model.globalConfigData.Countries)
02.      .Name("CountryFilter")
03.      .Columns(columns =>
04.               {
05.                   columns.Bound(p => p.value).Width(100).Title("Wert").HtmlAttributes(new { Name = "Value" });
06.                   columns.Bound(p => p.id).Width(30).Title("Id").Hidden().HtmlAttributes(new { Name = "Id" });
07.               })
08.      .Scrollable()
09.              .Selectable(selectable => selectable.Enabled(false))
12.      .DataSource(dataSource => dataSource
13.          .Server()
14.          .Model(model => model.Id(p => p.id)))
15.)

With the custom-multiselect configured:
1.$(document).ready(function ()
2.{
3.    // Enables multiselect on the grid without holding CTRL
4.    $("#CountryFilter").delegate('tbody>tr', 'click', function ()
5.    {
6.        $(this).toggleClass('k-state-selected');
7.    });
8.});

And then a function which is fired by a button:
01.function onClick_FilterButton(e)
02.{
03.    var counter = 0;
04.    var ctySelected = [];
05. 
06.    var entityGrid = $("#CountryFilter").data("kendoGrid");
07.    var rows = entityGrid.select();
08. 
09.    rows.each(function (index, row)
10.    {
11.        ctySelected[counter] = row.cells[1].innerText;
12.        counter++;
13.    });
14. 
15.    $.ajax({
16.        type: "POST",
17.        url: "/Event/FilterButton",
18.        datatype: "json",
19.        traditional: true,
20.        data: { "ids": ctySelected }
21.    });
22.}

Now to my problem:
When I use the normal selection mode of the Kendo-Grid (selectable.Mode(GridSelectionMode.Multiple)), the onClick-function works fine, but when I activate the custom multiselect-mode, the function crashes at line 7 (entityGrid.select() => value is Null or undefined)

How can I get the selected rows when I use this functionality?

A second (not urgent) question:
1.ctySelected[counter] = row.cells[1].innerText;

Is it possible to get the cell by it's name, like:
1.ctySelected[counter] = row.cells["MyValue"].innerText;

Kind regards
Jürgen
Jürgen
Top achievements
Rank 1
 answered on 29 Apr 2014
5 answers
301 views
I'm loading dropdown items like the example for cascading dropdowns.  I can see the correct JSON returned from the server in Fiddler, so I know my methods are correct and the controller is returning data.   The spinning icon still shows.  I've tried to reduce my recordset, there's only about 75 or so returned.  Nothing has worked so far.  any ideas?
Patrick
Top achievements
Rank 1
 answered on 29 Apr 2014
1 answer
43.0K+ views
Hi,

I want to mask Indian cell phone number like +91xxxxxxxxxx .
It is showing +_1__________ instead of +91__________

Please suggest how to do?

Find the attached image for my code and output of screen.

Thanks & Regards,
Bharat
Dimiter Madjarov
Telerik team
 answered on 29 Apr 2014
1 answer
497 views
I'm just getting started with UI for ASP.Net MVC and have been looking for an example on how use BootStrap and Telerik together in a MVC4 project. Have not found any examples. Does anyone know where I might find some. I want to use Bootstrap for my Layout page, and Telerik for UI Controls and widgets. Thanks
Dimo
Telerik team
 answered on 28 Apr 2014
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
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
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
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?