
Originally Posted by
Tim Toady
Yes, templates read arbitrary html. You could easily put an image in and even base that image on a value found in the record as is done with the other fields.
OK.. I followed the example. in my case I would like to retrieve the names after entering 4 letters. e.g: alic
It worked except that it returns all the names not just what contains alic ,
also, I got the result in firebug but not appears in combo box as a list
I am sure my problem is simple but still can't figure out how to fix it.
View:
Code:
items: [{
xtype: 'combo',
store: ds,
typeAhead: false,
hideLabel: true,
hideTrigger:true,
anchor: '100%',
listConfig: {
loadingText: 'Searching...',
emptyText: 'No matching posts found.',
getInnerTpl: function() {
return '<a {name}'+
'</a>';
}
}
store and model:
Code:
Ext.define("Post", {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
url: 'autocomplete.php',
reader: {
type: 'json',
root: 'names',
totalProperty: 'totalCount'
}
},
fields: [
{
name: 'name',
}
]
});
ds = Ext.create('Ext.data.Store', {
pageSize: 10,
model: 'Post'
});
and the php script:
Code:
$sql= "SELECT name FROM student_name ORDER BY name ASC";
$result = pg_query($con, $sql);
while ($row = pg_fetch_array($result))
{
$names[] = array('name' => $row[0]);
}
$name_list = array();
$name_list['success'] = true;
$name_list['names'] = $names;
$name_list['totalCount'] = count( $name_list['names'] );
echo json_encode($name_list);
pg_close($con);
Previously I used to use jQuery to do that with this query:
$sql = "SELECT name FROM student_name WHERE name ILIKE '%$search%' ORDER BY name ASC";
but now I have no idea how to send the search term to compare with in database.