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?

Issue fork datatables-2114991

Command icon 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

ey’s picture

Assigned: Unassigned » ey
Category: support » feature
Status: Active » Needs review
StatusFileSize
new1.75 KB

Excluding 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.

ey’s picture

I'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}

spelcheck’s picture

Issue summary: View changes

Works excellent, exactly what I was looking for and very minimal patch. Nice work, thank you.

chris64’s picture

Version: 7.x-1.2 » 2.x-dev
StatusFileSize
new1.23 KB

Here some thing for 2.x-dev in a short way. Is complementary to search on specific columns.

anybody’s picture

Assigned: ey » Unassigned
Status: Needs review » Needs work

@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?

chris64’s picture

@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.bSearchable column 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.
bSearchable value is a boolean TRUE|FALSE.
$column_options['bSearchable'] = 'thead_unsearchable' !== ($options['filter_columns'][$field] ?? '');
provide a boolean value only FALSE if $options['filter_columns'][$field] is set to 'thead_unsearchable', as required.

chris64’s picture

Status: Needs work » Needs review
chris64’s picture

StatusFileSize
new1.39 KB

A new patch with comments.

anybody’s picture

Status: Needs review » Needs work

@Chris64 could we have this as MR also?

That's always the better modern alternative to patches.

chris64’s picture

@Anybody, here is the MR.

chris64’s picture

Status: Needs work » Needs review
anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, 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.

chris64’s picture

Indeed @Anybody. A lot of tests to do.

diqidoq made their first commit to this issue’s fork.

  • diqidoq committed b67f8fba on 2.x authored by Chris64
    Issue #2114991 by Chris64, Elin Yordanov, Anybody: Exclude columns from...
dqd’s picture

Let'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

dqd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.