Select Multiple with comma in field causing issues

QuestionsSelect Multiple with comma in field causing issues
Michael Sheppard asked 6 years ago

When using “select-multiple” in a drop-down, if the field being returned has a comma it does not search correctly. When viewing the ‘debug’ it splits the field into two-parts with the comma.

Is there a way to escape the comma so it combines the field into a single search-string?

 

Thanks for any help

9 Answers
Abu Ghufran Staff answered 5 years ago

Hello Mike,

Apologies for the delay in ticket reply. Can you share some screenshot showing this issue?

I tried it on demo but unable to generate this issue.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael Sheppard answered 5 years ago

The issue isn’t the display – it’s the actual selection criteria once you select the field with a comma.

In your example if you select that entry it will not search for “Client = ‘Ana Trujilos'”, It will search for “Client in (‘Ana’,’Trujilos’)

So we never get a match on any fields that contain a comma when searching because it splits the field out into a comma separated list, not a single entry.

Thanks

Mike

Abu Ghufran Staff answered 5 years ago

By my findings, It currently uses contains search in finding results. It is not related to comma. You need exact search, it is not supported in the version of multiselect-filter we are using now.

If you mean something else, please share steps with test data. and screenshot.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael Sheppard answered 5 years ago

The search doesn’t work at all. If you select a field using multi-select and the field has a comma it will NOT find any results for the field that has the comma. That is the problem.

So if a field has a comma the multi-select doesn’t work. That is what  I need a work-around for.

 

Thank you

Abu Ghufran Staff answered 5 years ago

Can we have a remote session on google hangouts?

I want to see the issue live, perhaps i am not understanding it correctly till now.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael Sheppard answered 5 years ago

I’ll see what I can do time-wise  . . . I’m back and forth between projects tomorrow then I’m out of town for a couple of days.

I’ll try to explain it a bit better.

We have a drop-down field of business names and some of them have commas.

If I add a multi-select and select one of the names without a comma in it, the report will display results for that name correctly.

If I select one of the names with a comma in the field, nothing is displayed on the report. It’s almost like it is not there. If I convert to a single select it works fine.

I think the issue is the comma is being interpreted as a field delimiter and splitting the field – rather than wrapping the entire field in a single quote.

So using your example again, if I select a field that is in the database as “Ana, Trujilos” I would expect the quer to be:

SELECT * FROM TABLE WHERE NAME in (‘Ana, Trujilos’)

But instead, when I turn-on the debugger, the SQL Query is being sent like this:

SELECT * FROM TABLE WHERE NAME IN (‘Ana’, ‘Trujilos’)

As you can see it splits-out the field into two entries rather than one and it won’t ever match.

Hope this helps

Thanks again!

Mike

Abu Ghufran Staff answered 5 years ago

Your last reply helped much and i’ve regenerated the issue. Will be updating back after some working.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 5 years ago

Just resolved it and emailed you an update.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 5 years ago

Forget to tell, little modification in code is also required. As multi-select expect the keys to be numeric so it passes values as “2,3,4,5,6”. Now as you are using STRING as keys, you need to cover string in quotes. e.g.

$str = $g->get_dropdown_values(“select distinct concat(\”‘\”,note,\”‘\”) as k, note as v from invheader limit 10″);
$col[“editoptions”] = array(“value”=>”:;”.$str);
$col[“stype”] = “select-multiple”;
$col[“searchoptions”][“value”] = $str;

The single quotes around key will help differentiating records when using with IN operator of sql.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

15 + 20 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?