PDA

View Full Version : Ext.form.ComboBox - autocomplete not work



evil_elf
26 Mar 2010, 7:57 AM
Ext.onReady(function(){

var store = new Ext.data.JsonStore({
url: 'json_data.php?do=clients_list',
fields: ['id', 'name'],
});

client_list = new Ext.form.ComboBox({
store: store,
forceSelection:true,
//queryParam: 'id',
//hideTrigger: true,
typeAhead:true,
mode: 'remote',
triggerAction: 'all',
width: 300,
displayField:'name',
valueNotFoundText: '???????? ???????',
emptyText:'???????? ???????',
renderTo: 'clients_list',
});

})

When iam write something from data lis in input field, autocomplete does not filter the results, given my input.For example, data list includes "ttttxxx", "tttwww", "tttyyy".When iam write "ttty", script does not show me only "tttyyy", he show all variants in data list, and in input field show first(!) element of this list, "ttttxxx".Where i have errors? :)

Animal
26 Mar 2010, 8:00 AM
Its your server which does that if you do mode: 'remote'. The combo sends the input content, and your server is supposed to return a block of values which match.

evil_elf
26 Mar 2010, 8:05 AM
if($_REQUEST['do'] == 'clients_list')
{
$query_result = $make->SelectClientsNames();
while($row_clients_names = mysql_fetch_assoc($query_result)) $clients_names[] = $row_clients_names;

for($i = 0; $i < count($clients_names); $i++)
{
if($i == 0)
{
$comma = ',';
$l_bracket = '[';
$r_bracket = '';
}
elseif($i == count($clients_names) - 1)
{
$comma = '';
$l_bracket = '';
$r_bracket = ']';
}
else
{
$comma = ',';
$l_bracket = '';
$r_bracket = '';
}

$info .= $l_bracket.'{"id":"'.$clients_names[$i]['id'].'", "name":"'.$clients_names[$i]['name'].'"}'.$comma.$r_bracket;
}
echo $info;
}

This code generadet data list...but how should I modify it and my Ext scrip so that he sent the results of processing my input?Please show me example :)

P.S. I don't use php func "json_encode". because after it use i have this:


[{"id":"107", "name":"null"}]

name is null, bad :)

Animal
26 Mar 2010, 8:11 AM
1. I don't know PHP
2. This is not a PHP forum

evil_elf
26 Mar 2010, 8:15 AM
Ok.Do I need to modify my ext script?if so, how?

Animal
26 Mar 2010, 8:28 AM
Your server needs to return only results which match the query.

evil_elf
26 Mar 2010, 8:34 AM
OK.How to sent the results of my input into server?Which function\parameter of Etx.ComboBox is responsible for this?

[UPDATE]

This code search locally
Why did not you tell about this variant? :)


Ext.onReady(function(){

var store = new Ext.data.JsonStore({
url: 'json_data.php?do=clients_list',
fields: ['id', 'name'],
autoLoad: true
});

client_list = new Ext.form.ComboBox({
store: store,
forceSelection:true,
minChars: 3,
typeAhead:true,
mode: 'local',
triggerAction: 'all',
width: 300,
displayField:'name',
valueField: 'id',
valueNotFoundText: '???????? ???????',
emptyText:'???????? ???????',
renderTo: 'clients_list',
});

})

evil_elf
26 Mar 2010, 8:44 AM
Ext.onReady(function(){

var store = new Ext.data.JsonStore({
url: 'json_data.php?do=clients_list',
fields: ['id', 'name'],
autoLoad: true
});

client_list = new Ext.form.ComboBox({
store: store,
forceSelection:true,
//queryParam: 'id',
//hideTrigger: true,
minChars: 3,
typeAhead:true,
mode: 'local',
triggerAction: 'all',
width: 300,
displayField:'name',
valueField: 'id',
valueNotFoundText: '???????? ???????',
emptyText:'???????? ???????',
renderTo: 'clients_list',
//onSelect: function(record){alert(record.id)}
});

})

This code search locally...Why did not you tell about this variant? :)

Animal
26 Mar 2010, 8:47 AM
The API docs tell you. You shouldn't rely on me. I'm unreliable.

evil_elf
29 Mar 2010, 3:51 AM
Google + mindf*cking tell me, not API docs )

Animal
29 Mar 2010, 4:05 AM
It must be a modern thing, this iron willed resistance to reading documentation.

I don't know when they bother releasing docs.

evil_elf
29 Mar 2010, 2:36 PM
And if the documentation is written not for easy reading?And if such documentation for only one Ext.Window over 200 (!) parameter that are difficult to understand and are written in technical English (not my native language), often without explicit examples of use?And such examples - from the scant documentation - I can give many.So google is really cool thing for every programmer, not API for something, for example, ExtJS :).Even your base of tutorials is outdated!There 50% for 1st version of ExtJS and 50% for the second.That's why iam (and not only iam :) ) complain about the documentation.Translate it sensibly and will have fewer problems!