I have a view with a lot of columns. I want to use the search function only for one column for now. How can I exclude other columns from searching?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | datatables-bsearchable-2114991-8.patch | 1.39 KB | chris64 |
| #4 | datatables-bsearchable-2114991-4.patch | 1.23 KB | chris64 |
| #1 | exclude-columns-from-searching-21149941-1.patch | 1.75 KB | ey |
Issue fork datatables-2114991
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
ey commentedExcluding columns from search was not implemented in this module, although datatables has this option in its API. I've created a patch that implements this functionality to the views plugin so that we can exclude some columns from search.
Comment #2
ey commentedI've posted another issue and patch #2116143: Option to add manual column properties, which makes it possible to add extra option manually for each column. This patch makes it also possible to exclude any columns, adding an option
{"bSearchable": false}Comment #3
spelcheck commentedWorks excellent, exactly what I was looking for and very minimal patch. Nice work, thank you.
Comment #4
chris64Here some thing for 2.x-dev in a short way. Is complementary to search on specific columns.
Comment #5
anybody@Chris64 could you please explain the changes a bit to understand why we should use #4 instead of #2 and what's the background of your implementation?
Comment #6
chris64@Anybody, these old patches are outdated. Patch #2 purpose is more general than column search property. The patches here enable search to several columns and not only one as asked in the issue. Such a feature is needed since only one search box might be used and some columns should not be used for search.
bSearchablecolumn property is right for this. Each datatable need its own configuration. Better than an hook.'thead_unsearchable' => $this->t('Table Column: Unsearchable'),To enable to tell explicitly the column is unsearchable.
bSearchablevalue is a booleanTRUE|FALSE.$column_options['bSearchable'] = 'thead_unsearchable' !== ($options['filter_columns'][$field] ?? '');provide a boolean value only
FALSEif$options['filter_columns'][$field]is set to'thead_unsearchable', as required.Comment #7
chris64Comment #8
chris64A new patch with comments.
Comment #9
anybody@Chris64 could we have this as MR also?
That's always the better modern alternative to patches.
Comment #11
chris64@Anybody, here is the MR.
Comment #12
chris64Comment #13
anybodyThanks, the MR LGTM! Still it would be super helpful to have tests for all of this, so we could be sure it works as expected.
Comment #14
chris64Indeed @Anybody. A lot of tests to do.
Comment #17
dqdLet's have some courage to get on with the next release. *hides* I hope I will not complain about this later ;-)
Again: thanks for all the hard work on this! +1
Comment #18
dqd