Added QAutoCompleteTextBox Using JQuery from:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
You can download the QControl File from here:
<http://www.qcodo.com/downloads/item.php/132>
==== Installation ====
Download JQuery plugins from above link and save into the folder: /assets/js/
1> jquery.autocomplete.js
2> dimensions.js
3> jquery.bgiframe.min.js
Also Download the JQuery library from <http://jquery.com/> [Make sure the name is jquery.js]
4> jquery.js
And also save css into the folder: /assets/css/
5> jquery.autocomplete.css
Finally save the QAutoCompleteTextBox.class.php into the /includes/qcodo/qform folder
6> QAutoCompleteTextBox.class.php
====== Local Data set Example =====
$this->txtCompanyName = new QAutoCompleteTextBox($this);
$this->txtCompanyName->Name = QApplication::Translate('Keyword');
$objListItem = new QListItem('test', 1);
$this->txtCompanyName->AddItem($objListItem);
====== Modification of the jquery.autocomplete.js [included in zip download] =====
Just in case the jquery.autocomplete.js have new release in the future or you need some modification.
We have to modify the jquery.autocomplete.js to make it talks to Qcodo, look for the function request() and commented few lines from `jquery.ajax(` and replace with the code below:
// [Start]
jQuery.post( options.url,{
q: lastWord(term),
limit: options.max,
Qform__FormId: options.extraParams['Qform__FormId'],
Qform__FormState: $(“#Qform__FormState”).val(),
Qform__FormUpdates: '',
Qform__FormCheckableControls: '',
Qform__FormParameter: lastWord(term),
Qform__FormEvent: 'QAutoCompleteTextBoxEvent',
Qform__FormCallType: 'Ajax',
Qform__FormControl: options.extraParams['Qform__FormControl'] },
function(data) {
var parsed = options.parse && options.parse(data) || parse(data);
cache.add(term, parsed);
success(term, parsed);
}
);
// [End]
/*
jQuery.ajax({
url: options.url,
data: jQuery.extend({
q: lastWord(term),
limit: options.max
}, options.extraParams),
success: function(data) {
var parsed = options.parse && options.parse(data) || parse(data);
cache.add(term, parsed);
success(term, parsed);
}
});
*/
====== QCodo Example =====
Sample Code:
$this->txtCompanyName = new QAutoCompleteTextBox($this);
$this->txtCompanyName->Name = QApplication::Translate('Keyword');
// $this->txtCompanyName->TextMode = QTextMode::MultiLine;
$this->txtCompanyName->UseAjax = true; // QAutoCompleteTextBoxEvent Action is needed for Ajax respond
$this->txtCompanyName->AddAction(new QAutoCompleteTextBoxEvent(), new QAjaxAction('txtCompanyName_Change'));
The function handle the Ajax autocompleter, $strParameter is user input:
public function txtCompanyName_Change($strFormId, $strControlId, $strParameter){
$objMemberArray =
Member::QueryArray( QQ::Like(QQN::Member()->Name,$strParameter.'%'), QQ::Clause(QQ::OrderBy(QQN::Member()->Name)));
foreach($objMemberArray as $objMember){
echo $objMember->Name."\n";
}
exit;
}
.bc