Telerik Forums
Kendo UI for jQuery Forum
1 answer
606 views
I saw some examples using Kendo UI autocomplete text box with templates. 
http://demos.kendoui.com/web/autocomplete/template.html
However I could not find an example that uses templates on auto completion using
kendo.observable

My approach is that I use MVVM observable to binds the data to an input box as below.

<div id="form-container">
    <h2>
        Advisors</h2>
    Select Advisor:
    <div class="autocomplete">
        <input id="div-template" data-role="autocomplete" data-text-field="AdvisorName" data-filter="contains" data-bind="source: advisorsSource, value: selectedAdvisor" />
    </div>
</div>
 
<script type="text/javascript">
 
    $(document).ready(function () {
 
        var viewModel = kendo.observable({
            advisorsSource: new kendo.data.DataSource({
                minLength: 2,
                template: '<tr>' +
	                    '<td>${ AdvisorCode }</dt><td>${ AdvisorName }</td><td>${ Organisation }</td>' +
        	          '</tr>',
                transport: {
                    type: "json",
                    serverFiltering: true,
                    read: "Home/Advisors",
                    parameterMap: function(options, operation) {
                        if (operation !== "read" && options.models) {
                            return {
                                models: kendo.stringify(options.models)
                            };
                        }
                        return {
                            prefix: options.filter.filters[0].value
                        };
 
                    }
                },
                schema: {
                    model: { id: "AdvisorCode" }
                }               
            })
        });
 
        kendo.bind($("#form-container"), viewModel);
    })
 
</script>

MVC Action:

public JsonResult Advisors(string prefix)        {

                      var list = new List<Advisor>()

                           {

                               new Advisor { AdvisorCode = 002, AdvisorName = "Alex" , Organisation = "Blue Co"},

                               new Advisor { AdvisorCode = 003, AdvisorName = "Foo" , Organisation = "Yellow Co"},

                               new Advisor { AdvisorCode = 004, AdvisorName = "Smith", Organisation = "Green Co" },

                               new Advisor { AdvisorCode = 005, AdvisorName = "David", Organisation = "Yellow Co" },

                               new Advisor { AdvisorCode = 006, AdvisorName = "Alex" , Organisation = "Blue Co"},

                               new Advisor { AdvisorCode = 007, AdvisorName = "Foo" , Organisation = "Yellow Co"},

                               new Advisor { AdvisorCode = 008, AdvisorName = "Smith", Organisation = "Green Co" },

                               new Advisor { AdvisorCode = 009, AdvisorName = "David", Organisation = "Yellow Co" }

                           };

            return Json(list, JsonRequestBehavior.AllowGet);

        }

The auto completion works ok.  However it only shows  AdvisorName. It seems like my template does not work. I need to display multi-column (AdvisorCode, AdvisorName, Organisation) in the drop down, and the search should be based on any of these columns ( not just the AdvisorName). Can you please advise me on how to use the template and make the search based on multiple columns?

King Regards,
Raj

Burke
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
173 views



I can not set viewbag.x to datasource property of kendoAutoComplete.

var friends = "@ViewBag.Friends2";
var friends2 = $('<div/>').html(friends).html();


$.each(friends2, function (key, value)
{
$("#pResult").append(key.Name +" " + value.Name);
});

when I try change the datasource viewbag to other ,it worked.
Burke
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
120 views
Hi,
I have DateTimePicker on the page but it ignores any  format configuration settings on first render.
This code:
$("#absStart").kendoDateTimePicker({format: "dd-MM-yyyy HH:mm", timeFormat:"HH:mm" }); 
renders:
11/1/2012 2:20:00 PM
After selecting date or time everything is ok
I forgot something?
jr

Georgi Krustev
Telerik team
 answered on 30 Nov 2012
1 answer
165 views
I would like to display both description and Date in my kendo auto complete. THe following code will display as expected except the date. The date is displaying weird format 


if i type Nike

xml schmea
<d:SDate  m:type="Edm.DateTime">2012-11-21T18:30:51.097</d:SDate>
it will come up Nike (/Date(13534560000)/)    


 $("#titles").kendoAutoComplete({
                minLength: 3,
                dataTextField: "SDesc",
                dataValueField: "RefID",
                template: '${ data.SDesc } ' + '(' + '<span>${ data.SDate }</span>' + ')',
                                 
                dataSource: {
                    type: "odata",
                    serverFiltering: true,
                    serverPaging: true,
                    pageSize: 20,
                    transport: {
                        read: "http://localhost:54329/HH_WcfDataService.svc/Product"
                    }
                }
            });
Burke
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
123 views
Hi,


It is possible to use autocomplete with style tags? So how is Facebook or gmail when selecting the recipients e-mail?


Example: http://www.webresourcesdepot.com/dynamic-form-autocomplete-facebook-style/






Sorry for my bad English
Burke
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
60 views
Hello ..
need some help before my brain explodes..
cant seem to understand what im doing wrong

have a quite simple autocomplete.

$(document).ready(function () {
 
var data =new kendo.data.DataSource({
        serverFiltering: true,
        transport: {
            read: "data/output.txt" 
        }
    });
  $("#input").kendoAutoComplete({
            dataSource: data
      });
        });
But no matter how hard i try i dont get the result i want, just the list with one letter vertical..?
I dont know how am the external file supposed to look? as now it just is:
"value1",
"value2",
"value3"

Burke
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
187 views
I am not sure how I should map this data to get it to the datasource. I have read the docs but am not sure how to map this data.  If I change the url back to the demo.kedoui.com/service the data: event fires and binds ok.  With my url I get error event with msg error, but I do not see any data returned or how to fix this so the data is mapped correctly and the data event fires using my url json service.

Thanks

Data:
{"__entityModel":"People","__COUNT":3,"__SENT":3,"__FIRST":0,"__ENTITIES":[{"__KEY":"27","__STAMP":11,"ID":27,"firstName":"dan","lastName":"qqqq"},{"__KEY":"26","__STAMP":14,"ID":26,"firstName":"dan","lastName":"rrrr"},{"__KEY":"25","__STAMP":13,"ID":25,"firstName":"dan","lastName":"eeee"}]}
Code:
   $(document).ready(function () {
                   //var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                  //  var crudServiceBaseUrl = "http://127.0.0.1:8081/rest",
var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "http://127.0.0.1:8081/rest/People",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            }
        },
        schema: {
            data: function (data) {
                alert("got data")
                alert(data);   /*Data Return Successfully*/
                return data;
            }
        },
        error: function (e) {
            debugger;
            alert("Error");
        },
        change: function (e) {
            alert("Change");
        },
        requestStart: function (e) {
            debugger;
            alert("Request Start");
        }
    });
 
                    $("#grid").kendoGrid({
                        dataSource: dataSource,
                        pageable: true,
                        height: 400,
                        toolbar: ["create"],
                        columns: [
                            "firstName",
                               "lastName",
                            { command: ["edit", "destroy"], title: " ", width: "210px" }],
                        editable: "inline"
                    });
                });
Christopher Tallos
Top achievements
Rank 1
 answered on 30 Nov 2012
1 answer
126 views
Is there away to either bind a ButtonGroup to a model or programmatically modify it's collection?

Thanks,

Bron
Iliana Dyankova
Telerik team
 answered on 30 Nov 2012
1 answer
378 views
Hi,

I am using the Kendo Grid with the MVC helpers, and want to make a conditional area in ClientRowTemplate.
Currently I have the following ClientRowTemplate:
.ClientRowTemplate("<tr>" +
                       "<td >" + 
                           "${ FirstName} " +
                       "</td>" +
                       "<td> " +
                           "${ LastName} " +
                       " </td>" +
                   "</tr>" +
                   "${optionalNotes(Notes)}")
and this JavaScript:    
function optionalNotes(t) {
    if (t.length > 0) {
        return "<tr><td colspan='2'>" + t + "</td></tr>";
    } else {
        return "";
    }
}
This works partially. My JavaScript is being fired, but the result is escaped before it is being added into the grid. So, instead of getting an optional tablerow with Notes, I get the html displayed.
Is there any way to indicate to Kendo to treat the JavaScript output as raw HTML in this context?
Thanks,
Ewald
Petur Subev
Telerik team
 answered on 30 Nov 2012
1 answer
184 views
How to add multiple check boxes in Kendo grid column. I am using trial version of kendo grid in SharePoint.

Please advice.
Atanas Korchev
Telerik team
 answered on 30 Nov 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Effects
Accessibility
PivotGridV2
ScrollView
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
TimePicker
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
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
Bronze
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?