Autocomplete

QuestionsAutocomplete
Cedric asked 8 years ago

Hello,
How can I have a column that is displayed as select for filtering and autocomplete for insert/edit.
The autocomplete list must be filled from another table.

Thanks
Cedric

5 Answers
Abu Ghufran answered 8 years ago

Yes, you can use select2 control.
Refer demos/integration/dropdown-select2.php

Cedric answered 8 years ago

Hello Abu,
Thanks for the reply but in this demo the autocomplete field still refer to the same table..
// set database table for CRUD operations
$g->table = "vr_deliverie

$col = array();
$col["title"] = "for";
$col["name"] = "d_for";
$col["width"] = "60";
$col["stype"] = "select";
$col["editable"] = true;
$col["editoptions"] = array("value"=>$fill_from_users);
$col["formatoptions"] = array("sql"=>"select uname FROM active_users ORDER BY uname", "update_field"=>"pn_uname");
$col["formatter"] = "autocomplete"; // display label, not value
$col["searchoptions"] = array("value" => ":;".$fill_from_users);
$cols[] = $col;

field d_for, must be an autocomplete textbox filled by the field uname from the table active_users.
When I do this, I have an error:
Couldn't execute query. Unknown column 'd_for' in 'where clause'

Anyway to use a different field name?

Abu Ghufran answered 8 years ago

Sorry for the delay. Here you need to have search_on param.
e.g.
$col["formatoptions"] = array("sql"=>"SELECT note as k, note as v FROM invheader", "update_field"=>"name","search_on"=>"note");

In your case:
search_on will be the field in active_user table which autocomplete will use in where clause.

Cedric answered 8 years ago

Have someone used autocomplete with another table?

Abu Ghufran Staff answered 5 years ago
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

0 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?