Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Jquery - Autocomplete Question

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Jquery - Autocomplete Question
 Login/Join
 
Gold member
posted
I'm experimenting with Jquery Autocomplete using the car file. So far jquery is working quite nicely but I'm looking to tweak the html front screen.

How do I limit the dropdown list to 20 items instead of the full file?

I have a file which contains 10000 items and I do not want to show all the items when users click the dropdown.

Sample Jquery Autocomplete - Car file
DEFINE FILE CAR
CARLIST/A180  = '<OPTION VALUE="' || MODEL || '"> ' |CAR || ' ' | MODEL;
END
TABLE FILE CAR
SUM
CARLIST
BY CAR NOPRINT
ON TABLE SAVE AS CARPICK
END


-HTMLFORM BEGIN
< !DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>BOD Search</title>
	<link rel="stylesheet" href="hostserver/approot/jquery/development-bundle/themes/base/jquery.ui.all.css">
	<script src="hostserver/approot/jquery/jquery-1.7.1.js"></script>
	<script src="hostserver/approot/jquery/development-bundle/ui/jquery.ui.core.js"></script>
  	<script src="hostserver/approot/jquery/development-bundle/ui/jquery.ui.widget.js"></script>
	<script src="hostserver/approot/jquery/development-bundle/ui/jquery.ui.button.js"></script>
	<script src="hostserver/approot/jquery/development-bundle/ui/jquery.ui.position.js"></script>
	<script src="hostserver/approot/jquery/development-bundle/ui/jquery.ui.autocomplete.js"></script>
	<link rel="stylesheet" href="hostserver/approot/jquery/development-bundle/demos/demos.css">
	<style>
	.ui-button { margin-left: -1px; }
	.ui-button-icon-only .ui-button-text { padding: 0.01em; }
	.ui-autocomplete-input { margin: 0.2; padding: 0.10em 0.10em 0.10em; width:300px;}
	</style>
	<script>
	(function( $ ) {
		$.widget( "ui.combobox", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "[*]" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "<button type='button'>&|nbsp;</button>" )
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Items" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// work around a bug (likely same cause as #5265)
						$( this ).blur();

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#combobox" ).combobox();
		$( "#toggle" ).click(function() {
			$( "#combobox" ).toggle();
		});
	});
	</script>
</head>



<FORM name='form' action='/ibi_apps/WFServlet'
 method='get' target='main' >
<input type='hidden' name='IBIMR_domain' value='&DOMAIN.EVAL/&DOMAIN.EVAL.htm'>
<input type='hidden' name='IBIMR_action' value='MR_RUN_FEX'>
<input type='hidden' name='IBIMR_sub_action' value='MR_STD_REPORT'>
<input type='hidden' name='IBIMR_folder' value='&FOLDER'>
<input type='hidden' name='IBIMR_fex' value='app/&FOCEXEC.EVAL.fex'>
<input type='hidden' name='IBIF_ex' value='app/&FOCEXEC.EVAL.fex'>
<input type='hidden' name='IBIMR_defer' value=''>



<div class="demo">
<div class="ui-widget">
[b]Within [/b]
	<FORM ACTION="/ibi_apps/WFServlet" METHOD="GET">
	<label>Select Car Model: </label>
	<select id="combobox" name="NODE" SIZE="8">>>
    !IBI.FIL.CARPICK;
	</select>
</div>

<INPUT NAME="submit" TYPE=SUBMIT style="text-decoration: BOLD"
 VALUE="Run Report">
<INPUT NAME="reset"  TYPE=RESET  VALUE="Reset Parameters">
</div>< !-- End demo -->
-HTMLFORM END

This message has been edited. Last edited by: Kerry,


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Platinum Member
posted Hide Post
Have you tried RECORDLIMIT?


WebFOCUS 8201M/Windows Platform
 
Posts: 109 | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
PLEASE USE
[ CODE ] [/ CODE ]
TAGS
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
<FreSte>
posted
Maybe this can be of any inspiration.
(I multiplied the same list of cities a couple of times to make the list quite long).

-Fred-
 
Report This Post
Gold member
posted Hide Post
I'm inspired Fred.

Thanks!!!


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Jquery - Autocomplete Question

Copyright © 1996-2020 Information Builders