How can i join values seprated by "|" in leftjoin to obtain multiple value

How can i join values seprated by "|" in leftjoin to obtain multiple value

Aryan1703Aryan1703 Posts: 65Questions: 15Answers: 1

Currently i am storing mutiple values like "1|2|3".

  {
          label: "Additional Actions",
          name: 'checkbox',
          type: 'checkbox',
          separator: "|",
          options: [
            { label: 'Logs Requested', value: 1 },
            { label: 'Logs Retrieved', value: 2 },
            { label: 'VATC Log Reviewed', value: 3 },
            { label: 'VCU Log Reviewed', value: 4 },
            { label: 'Datalogger Log Reviewed', value: 5 }
          ]
        },
 Field::inst('AC.label'),
 ->leftJoin('ops_analysisCheckbox AC', 'AC.id', '=', 'OL.checkbox')

This only gives us the first value and not the other ones

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    Your checkbox column is stored as a string, such as 1|2|3 - is that correct? Can you show me the JSON response from the server please as well as the full controller?

    Allan

  • Aryan1703Aryan1703 Posts: 65Questions: 15Answers: 1
    edited May 6 Answer ✓

    Sorry for the late response but I figured out another way where instead of storign them as seprated by "|" i am seprating them using ",". I am calling the query directly in the serverside script for that field. Below is how I have done it


    Field::inst('OL.followOn', 'followOn') ->getFormatter(function ($val, $data, $field) { $follow = $val; $followvalue = ''; $options = []; $checkbox = $data['OL.checkbox'] ?? null; if ($checkbox) { $query = "SELECT C.label FROM ops_analysisCheckbox C WHERE FIND_IN_SET(C.id, '$checkbox')"; $result = query($query); while ($row = mysqli_fetch_assoc($result)) { $options[] = $row['label']; } } if (!empty ($options)) { $followvalue = '<br><div class="data-detail col">[Additional Actions: ' . implode(',', $options) . ']</div>'; } $followvalue = $follow . '<br><div class="row">' . $followvalue . '</div>'; return $followvalue; }),
Sign In or Register to comment.