UNPKG

jqwidgets-framework

Version:

jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.

91 lines (86 loc) 4.03 kB
<!DOCTYPE html> <html ng-app="demoApp" lang="en"> <head> <title id='Description'>In this example is demonstrated how to use the jqxListBox with Search field. ListBox is automatically updated when a character is entered into the search field.</title> <meta name="description" content="AngularJS ListBox example. This example demonstrates a ListBox with remote search." /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../../scripts/angular.min.js"></script> <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../scripts/demos.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxinput.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script> <script type="text/javascript"> var demoApp = angular.module("demoApp", ["jqwidgets"]); demoApp.controller("demoController", function ($scope, $timeout) { $scope.searchValue = ""; var source = { datatype: "jsonp", datafields: [ { name: 'countryName' }, { name: 'name' }, { name: 'population', type: 'float' }, { name: 'continentCode' }, { name: 'adminName1' } ], url: "http://api.geonames.org/searchJSON", data: { featureClass: "P", style: "full", maxRows: 50, username: "jqwidgets" } }; var dataAdapter = new $.jqx.dataAdapter(source, { formatData: function (data) { data.name_startsWith = $scope.searchValue; return data; } } ); $scope.settings = { width: 320, height: 350, source: dataAdapter, selectedIndex: 0, displayMember: "name", valueMember: "countryName", renderer: function (index, label, value) { var item = dataAdapter.records[index]; if (item != null) { var label = item.name + "(" + item.countryName + ", " + item.adminName1 + ")"; return label; } return ""; } }; var me = this; $scope.keyupHandler = function (event) { if (me.timeout) { $timeout.cancel(me.timeout); } me.timeout = $timeout(function () { dataAdapter.dataBind(); }, 300); }; }); </script> </head> <body ng-controller="demoController"> <div> <div> <span style='float: left; margin-top: 5px; margin-right: 4px;'>Search for a City: </span> <jqx-input ng-model="searchValue" ng-keyup="keyupHandler(event)" jqx-place-holder="'Type a City name here'" jqx-height="23" jqx-width="197" style="float: left;"></jqx-input> </div> <div style="clear: both;"></div> <jqx-list-box style="margin-top: 10px;" jqx-settings="settings"></jqx-list-box> </div> </body> </html>