Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mjoin + SearchPaneOptions #4

Open
cgo123 opened this issue Aug 28, 2020 · 2 comments
Open

Mjoin + SearchPaneOptions #4

cgo123 opened this issue Aug 28, 2020 · 2 comments

Comments

@cgo123
Copy link

cgo123 commented Aug 28, 2020

Currently, SearchPaneOptions of Fields in Mjoin-Class are ignored.

Would be very helpful if there was a workarround for this.

@DataTables
Copy link
Collaborator

Thanks for flagging this up! I can't say when exactly we'll get to this, but it is now on the radar.

@cgo123
Copy link
Author

cgo123 commented Sep 2, 2020

My Workarround currently is to use a view and concat the 1:x entries:

SQL-Part:
GROUP_CONCAT(tbl_contact_types.contact_type_name SEPARATOR ', ') AS contact_type_names
...
LEFT JOIN tbl_contact_types ON tbl_contact_types.contact_uuid = tbl_contacts.uuid

PHP Part for Search Pane:

/**
 * Create data for search pane
 */
$contactTypeCounts = $contact->getContactTypeCounts();
foreach ($contactTypeCounts as $contactTypeCount) {
    $resultArray['searchPanes']['options']['contact_type_names'][] = [
        'count' => $contactTypeCount['contact_type_name_count'],
        'total' => $contactTypeCount['contact_type_name_count'],
        'label' => $contactTypeCount['contact_type_name'],
        'value' => $contactTypeCount['contact_type_name']
    ];
}

PHP Processing Search

/**
 * Special cases contact_type_names
 */
$searchedcontactTypeNames = $_POST['searchPanes']['contact_type_names'];
unset($_POST['searchPanes']['contact_type_names']);


for ($i = 0, $ien = count($_POST['columns']); $i < $ien; $i++) {
    $column = $_POST['columns'][$i];
    $search = $column['search']['value'];
        if ($column['name'] == 'contact_type_names') {
            foreach ($searchedcontactTypeNames as $searchedcontactTypeName) {
                $editor->where($editor->_ssp_field($_POST, $i), '%' . $searchedcontactTypeName . '%', 'LIKE');
            }
        }
}

With this workarround you can filter and search contact_type_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant