Drupal - 7
Views: 7.x-3.10
Data module: 7.x-1.0-alpha7
DB: MySQL

I use data module to adopt my custom table into views, after views generated by data module, I start to make some configuration on views page. But right now I hit an issue, that is how to pick up the data and showed in "exposed filter" for users. I want to add some "exposed filters" at views table as "select box", and inside the select box, which contains all possible values of a specific column of data in database. But right now, the "exposed filters" only has one value "-ANY-". How can I adopt other column data to the exposed filters?

For example.
In my database table "test", it has 2 column "id", and "name". And there are 3 rows of data inside the table. (1, "alice"), (2, "bob") and (3, "Cindy"). After adopt the table "test" into view by data module, I edit the view and add an "exposed filter" for "name". I wish the filter can be "select box" and inside there are 3 values "alice", "bob" and "cindy".

Can I do that? And how?

Very appreciate for your help!

Thanks
Jason

Thank you Ayesh. It works!

I am new to drupal but have some experience on php. When I get touch on drupal at beginning like now, I feel sometimes easy to have a website but confused when hit issues, because I don't know how to fix them before reading code of each modules one by one. It is tough to get familiar with all of related modules at same time. I guess it will take months to go smoothly. I am reading your blogs and bad practice for drupal. It is good, thank you!

Comments

ayesh’s picture

Try this module: https://www.drupal.org/project/views_selective_filters

I personally don't use it due to performance reasons. I noticed sinilar questions on DrupalAnswers and here on d.o. Using Data module just to avoid writing your your own Views integration comes with issues like this. I'd rather write the integration myself. You'll probably save some time using the Data module, but when you account the time it takes to research and workaround, you actually take more time for that.

There is no requirement in Views API that the module defining the Views integration must also introduce the schema. In fact, you can take over the database connection as well. Views To access other databases? See https://www.lullabot.com/blog/article/querying-slave-database-views