Telerik Forums
Kendo UI for jQuery Forum
0 answers
78 views

Hi,

I checked your  AutoComplete and MultiColumnComboBox examples.But any example , you did not send a parameter to Controller using by UI Jquery AutoComplete and MultiColumnCombobox.How to send a parameter to Controller for server filtering? When I try to implement your example codes, The parameter i send to controller returns null.


Zafer
Top achievements
Rank 1
 asked on 29 Dec 2022
0 answers
62 views

I am trying to implement kendo autocomplete and I am new to Kendo.  When the user enters a character query is taken and a list is made using the database and returned to the view. Everything works fine except when the first character is typed search box loses its focus and I need to click on the search box again to type more characters. For some reason also other buttons gets doubled pic below

Here is my code


$("#query").keyup(e => { e.preventDefault(); if (e.keyCode === 13) { $("#btnSearch").click(); } let ds = new DataServices(`${bc.apiBaseUrl}TrendStations/SearchAutoComplete`); let xhr = ds.GetData({ query: $("#query").val() }); $('#query').attr('autocomplete', 'CUSTOM'); xhr.done((results) => { if (results != null) { var data = results; $("#query").kendoAutoComplete({ dataSource: data, filter: "startswith", placeholder: "Enter your search here...", separator: ", " }); } else { window.location.reload(); } }).fail(ex => { new ErrorHandler().HandleError(ex); }); });

 

I have looked for an answer but no luck! anybody knows what is going on?


Oz
Top achievements
Rank 1
 updated question on 25 Aug 2022
0 answers
122 views

We're still getting used to using Telerik's Kendo UI for jQuery. So far, we've only used one component, AutoComplete. Which works great, BTW!

There's something we'd like to do, but don't know how to do. On an ASP.NET MVC Core page (.NET 6) we want to be able to allow the user to enter multiple items of the same type. It seems like either the Grid or ListView Kendo components would work. Personally, I'm favoring the ListView. But we also need to use AutoComplete work when the user is entering values to a new row. So, for example, we need to collect LotNumber and ProgramName, multiple times, because there can be and often is, multiple items to be entered, along with other details on the same page. I've looked at the ListView component, the Add method, etc. In the example given, it references an identified (by using the HTML id property) control on the page. So, how does one apply AutoComplete to both LotNumber and ProgramName, when entering a new LotNumber/ProgramName pair in a ListView?

Rod
Top achievements
Rank 1
 asked on 19 Aug 2022
0 answers
92 views

Auto complete for Document type works as expected when i add new file (Tool bar add file).
How do I achieve the same auto complete and validation if user clicks edit/Update? I am using ScaffoldColumn to make the Doc type editable when user clicks Edit in Kendo Grid??

 @(Html.Kendo().Grid<FileDataModel>()
                  .Name("grid")
                  .Columns(columns =>
                  {
                  columns.Bound(c => c.FileName);
                  columns.Bound(c => c.Title);
                  columns.Bound(c => c.SelectedDocType);
                  columns.Template(@<text></text>).Title("<b>Download</b>")
                          .ClientTemplate("<a href='" + Url.Action("Download", "Home", new { @id = "#=Id#" }) + "'>Download</a>")
                          .HtmlAttributes(new { style = "text-align: left;" });
                      columns.Command(command =>
                      {
                          command.Edit();
                          command.Destroy();
                      }).Title("<b>Action</b>");
                  }).Events(e => e.DataBound("onDataBound"))
                  .Scrollable(a=>a.Height("auto"))
                  .Selectable()
                  .Groupable()
                  .Sortable()
                  .Editable(config => config.Mode(GridEditMode.PopUp))
                  .Pageable(pageable => pageable
                      .Refresh(true)
                      .PageSizes(true)
                      .ButtonCount(5))
                  .ToolBar(toolBar => toolBar.Template("<a class='k-button  k-button-icontext' onclick='addFilePopup()' href='#' id='addNewFile'></span>Add new file</a>"))
                  .DataSource(dataSource => dataSource
                      .Ajax()
                      .Batch(false)
                      .PageSize(20)
                  .Model(model =>
                  {
                      model.Id(p => p.Id);
                      model.Field(p => p.Id).Editable(false);
                      model.Field(p => p.CreatedDate).Editable(false);
                      model.Field(p => p.DateSigned).Editable(false);
                      model.Field(p => p.DateSubmitted).Editable(false);
                      model.Field(p => p.DjjNumber).Editable(false);
                      model.Field(p => p.ScanDate).Editable(false);
                      model.Field(p => p.ScanUser).Editable(false);
                  })
                  .Read(read => read.Action("GetFiles", "Home", new { djjNumber = Model.DjjNumber }))
                  .Update(update => update.Action("EditingInline_Update", "Home"))
                  .Destroy(destroy => destroy.Action("EditingInline_Destroy", "Home"))
          ))

</div>


Kendo Autocomplete and Validation function.
$("#txtDocType").kendoAutoComplete({
            dataSource: new kendo.data.DataSource({
                type: "json", // specifies data protocol
                pageSize: 3,//This is to set search limit
                serverFiltering: true,
                transport: {
                    read: '@Url.Action("GetDocumentTypes", "Home")',
                    parameterMap:function(){
                        return {filterKey:$("#txtDocType").data("kendoAutoComplete").value()};
                    }
                },
            }),
            dataTextField:"Type",
            filter: "contains",
            minLength: 3,//This is to set minimum character length for autocomplete
        });
    });

    function ValidateDocumentType(){
        var isValidDocType=true;
        $.ajax({
            data:{documentType:$("#txtDocType").val()},
            url:'@Url.Action("GetDocumentType", "Home")',
            async: false,
            success:function(data) {
                if(data==false)
                    isValidDocType=false;
                complete=true;
            },
        });
        return isValidDocType;
    }

Sai
Top achievements
Rank 1
 asked on 07 Oct 2016
0 answers
46 views
Hello,

I am working through the dojo tutorial using asp.net MVC.  I am able to see the kendo.web.min.js file, but it still doesn't properly create the autocomplete control.  Could you look at my code and see what I am doing wrong?  Thanks!

Master Layout.cshtml page:

<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Styles/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Styles/kendo.silver.min.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo.web.min.js")" type="text/javascript"></script>
</head>
<body>
    <div>
        @RenderBody()
    </div>
    <script src="@Url.Content("~/Scripts/Custom.js")" type="text/javascript"></script>
</body>
</html>
Custom.js file (where I call the auto complete wiget:

$(document).ready(function () {
    $(function () {
        $("countriesAutoComplete").kendoAutoComplete();
    });
});

.cshtml page that tries to use the autocomplete widget:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
       <p>
           Country: <input id="countriesAutoComplete" class="k-input" />
       </p>
    </div>
    <script type="text/javascript" src="~/Scripts/Custom.js"></script>
</body>
</html>
When I assign the class "k-input" it doesnt change styles like it does in the tutorial.  I checked to make sure the stylesheet is being sent to the browser.
Colin
Top achievements
Rank 1
 asked on 08 Sep 2013
0 answers
124 views
Do you enjoy Google’s instant search feature?  If so, this is the tutorial for you.  Basically we want to create a widget that will update search results as you type in a text box. Google calls this “Instant”.  We can achieve this same functionality by combining the AutoComplete widget and the Grid widget.

Setup the AutoComplete control.
<li>
  @(Html.Kendo().AutoComplete()
        .Name("BenefitID")
        .Suggest(false)
        .MinLength(2)
        .DataSource(
            ds => ds.Read(
                r => r.Action("BenefitSearch", "Home").Data("setTemplateListFilters")
                    ).ServerFiltering(true)).DataTextField("Description").HtmlAttributes(new { style="width:450px",placeHolder = "Search Existing Benefits"  })
                    .Events(e=>e.DataBound("BenefitDataBound").Open("OnOpen"))
                     
                    )
 
        </li>
We need to set Suggest = false, otherwise the control will attempt to suggest a value within the search textbox.  The magic happens in our event handlers, “BenefitDataBound” and “OnOpen”.

When the AutoComplete widget is databound, we simply want to extract the JSON data from the datasource and pass it off to a method that will create and bind a Grid.

function BenefitDataBound(e, args) {
 
       bindGrid(this.dataSource.data());
 }
   function bindGrid(data) {
       $("#gridResults").kendoGrid(
 
           {
               dataSource: {
                   data: data,
                   group: {
                       field:"Category"
                   }
               },
               change: rowSelection,
               selectable: "single",
               height: 430,
               navigatable: true,
               scrollable: {
                   virtual: false
               },
               columns: [
                   "ID",
                   "Name",
                   "Description"
               ]
           }
 
 
      );
   }
Or if you prefer to create everything using the MVC wrappers, you can do the following:

@(Html.Kendo().Grid<Sbc.Domain.ArtifactSummary>().Name("ContentReport")
 
   .Columns(c =>
   {
       c.Bound(x => x.Name);
       c.Bound(x => x.Category);
       c.Bound(x => x.Type);
       c.Bound(x => x.Version);
       c.Bound(x => x.LocalVersion).Title("Local Version");
       
   })
   .DataSource(dataSource => dataSource
       .Ajax()
       .PageSize(20)
       .ServerOperation(false)
    )
   .Scrollable(x => x.Height(200))
   .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
  )
function BenefitDataBound(e, args) {
 
 
                var grid = $("#ContentReport").data("kendoGrid");
                grid.dataSource.data(this.dataSource.data());
  }


Lastly we need to prevent the AutoComplete widget from displaying any UI.  This can be handled by the OnOpen event handler.

function OnOpen(e) {
 
      e.preventDefault();
  }
There you have it.  Enjoy!
Jason Tully
Top achievements
Rank 1
 asked on 25 Apr 2013
0 answers
64 views
Ive just started using AutoComplete and Im having a few problems, basically nothing shows up when I start typing in the box, hopefully someone might be able to give me a few pointers.

in my controller (AccountController)  I have this method

[HttpGet]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public JsonResult GetCountries()
        {
            RegisterModel model = new RegisterModel();
            return Json(model.Countries, JsonRequestBehavior.AllowGet);
        }

in my model (AccountModel)  I have this property and method

public IEnumerable<EbsData.TimeZone> Countries { get {return GetCountries();} set{value = GetCountries();} }


/// <summary>
        /// get all the current countries from cache or repository
        /// </summary>
        /// <returns></returns>
        private IEnumerable<EbsData.TimeZone> GetCountries()
        {
            Service.InMemoryCache cacheProvider = new Service.InMemoryCache();
            using (var context = new EbsData.EBSEntities())
            {
                var countries = cacheProvider.Get("countries", () => (from c in context.TimeZones select c).ToList());
                return countries;
            }

        }

and in my view, I have this markup


<li>
                @Html.LabelFor(m => m.Country)
                @Html.Kendo().AutoCompleteFor(m => m.Country).Name("countriesAutoComplete").Animation(true).IgnoreCase(true).DataTextField("Country").DataSource(source =>
                                                                                                                                                         {
                                                                                                                                                                source.Read(read =>
                                                                                                                                                                {
                                                                                                                                                                    read.Action("GetCountries", "AccountController").Data("onAdditionalData"); //Set the Action and Controller name
                                                                                                                                                                })
                                                                                                                                                                .ServerFiltering(true); //If true the DataSource will not filter the data on the client.
                                                                                                                                                         })                                                                                                                                                     

            </li>


which creates this hmtl

<li>
<label for="Country">Country</label>
<span class="k-widget k-autocomplete k-header k-state-default" tabindex="-1" role="presentation" style="">
<input id="countriesAutoComplete" class="k-input" type="text" name="countriesAutoComplete" data-val-required="The Country field is required." data-val="true" data-role="autocomplete" style="width: 100%;" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-owns="countriesAutoComplete_listbox" aria-autocomplete="list">
</span>
<script>
jQuery(function(){jQuery("#countriesAutoComplete").kendoAutoComplete({"dataSource":{"transport":{"read":{"url":"/AccountController/GetCountries","data":onAdditionalData}},"serverFiltering":true,"filter":[],"schema":{"errors":"Errors"}},"dataTextField":"Country","ignoreCase":true});});
</script>
</li>


there is data available for the autocomplete to use, and the javascript function is there, but none of the server code is being executed.  Can anyone see where Im going wrong ?




mww
Top achievements
Rank 1
 asked on 18 Jan 2013
0 answers
323 views
Hi,

I ran in some cross browser compability issues with the placeholder property. Apperently this is because Internet Explorer up to version 9 cannot handle the "placeholder" attribute correctly.

Issues were:
  1. In Internet Explorer the color of the placeholder text was equal to the color of the text typed in the input field, all other browsers showed the placeholder in light grey.
  2. When clicking in the field the placeholder would not disappear in browsers like Firefox for example, but simply changed color to the normal input color. It only disappeared as soon as you started typing. IE, however, removed the placeholder text as soon as the input field is clicked in and shows the user a empty input field, which was my desired behaviour.

To fix these issues i came up with some event handlers that can be easily attached to your autocomplete setup script plus two lines browser specific of CSS code.

JS Autocomplete setup code:

$("input.autoComplete")
        .kendoAutoComplete({...})
        .focusin(function () {         
            //If IE the placeholder will be hidden, but typed text
// would be in the placeholders colour, so change it here to your normal
// input color
            if ($.browser.msie === true) {                 $(this).css('color''black');             }         }).focusout(function () {             //If IE and the value is empty, the placeholder will be shown;
// make sure it has the right colour
            if ($.browser.msie === true && $(this).val() === '') {                 $(this).css('color''#6d6d6d');             }                }).ready(function () {             var el = $("input.autoComplete");             var value = $(el).val();             if (value !== $(el).data('kendoAutoComplete').options.placeholder) {                 //every browser except IE return empty value if input is empty
// but placeholder is shown
                if (value !== '') {                     $(el).css('color''black');                 }             }  else {                 //if IE change color for your place holder;                 if ($.browser.msie === true) {                     $(el).css('color''#6d6d6d');                 }             }         });

CSS Code:
/*This will make the placeholder invisible in Gecko/WebKit browsers on focus*/
input:focus::-webkit-input-placeholder { colortransparent !important; }
input:focus:-moz-placeholder {colortransparent !important; }


I hope the code helps others, with the same cross browser issues.

Joachim
Top achievements
Rank 1
 asked on 08 Nov 2012
0 answers
39 views
hi,

It is possible to use kendoAutoComplete in mobile application.

it is work or not

Thanks,
Raghwenda
Nick
Top achievements
Rank 1
 asked on 07 Aug 2012
0 answers
60 views
what is the best way to handle the combobox request when serverFilter is true
how to bind filter[filters][0][field] in mvc3 like DataSourceRequest for kendo grid
Ibrahim
Top achievements
Rank 1
 asked on 02 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?