Skip to content

Order on column of included table #331

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

Open
SirTrollsalot opened this issue Jan 18, 2018 · 9 comments
Open

Order on column of included table #331

SirTrollsalot opened this issue Jan 18, 2018 · 9 comments
Assignees

Comments

@SirTrollsalot
Copy link

Is it possible to order a List by an includet Column?

for example:
api.php/tbl_contacts?columns=contact_id,Name,EMail,tbl_contacttype.Description&include=tbl_contacttype&order=tbl_contacttype.Description&page=1,30

@mevdschee
Copy link
Owner

mevdschee commented Jan 18, 2018

Hi, thank you for reaching out. That is not possible, but you may list the included table and include the original table and then list by the included column. I hope that helps.

Alternatively you can do client side sorting (using your own JavaScript implementation).

@mevdschee mevdschee self-assigned this Jan 18, 2018
@mevdschee mevdschee changed the title Order on Includet columns Order on column of included table Jan 18, 2018
@SirTrollsalot
Copy link
Author

SirTrollsalot commented Jan 18, 2018

Then i guess i also can't filter on those columns, client side sorting and filtering is not an option, because if i use pages i can only filter one page.

Thanks for the help tho, will try your first suggestion

@mevdschee
Copy link
Owner

Yes or you can do two request, where you retrieve id's in the first and then do an "in" filter in the second. You need to combine those two results (manually) in JavaScript. Good luck!

@mevdschee
Copy link
Owner

I'll keep this open as a feature request.

@mevdschee mevdschee reopened this Jan 18, 2018
@SirTrollsalot
Copy link
Author

SirTrollsalot commented Jan 19, 2018

Hey it's me.... again...i'm sorry...
Is there any way i can combine All and Any in the Filter?
so logically:
Filter[]=id,cs,1 AND (Filter[]=name,cs,text OR Filter[]=adress,cs,text)

I do not want to download it and combine it manually, because i am using pages.
Downloading everything would also be bad because of performance reasons

Edit:
I want to Apply the one Filter on a Column that is also on an includet table. i tried using adding the table to the attribute and using different satisfy like said in your description but this did not work:

table: api.php/tbl_contacts?
columns: columns=contact_id,Name,EMail,tbl_contacttype.ID_contacttype,tbl_contacttype.Description
filter: &filter[]=tbl_contacttype.ID,eq,1&filter[]=Name,cs,text&filter[]=EMail,cs,text
include: &include=tbl_contacttype
order: &order=Name
page: &page=1,30
satisfy: &satisfy=tbl_contacttype.all,tbl_contact.any

Edit 2.0:
I found out that it works if i add the table to every attribute. Now it filters every table like it should, the only Problem is that every contact is shown, and only the one with the filtert contact type have the attribute. But i can work with that by just filtering out the one that does not have a contacttype.

Sorry for wasting your time and thanks for the help yesterday again.

@mevdschee
Copy link
Owner

mevdschee commented Jan 19, 2018

Hey it's me.... again...i'm sorry...

Sure.. no problem. Although different issues would be better in different tickets :-).

Is there any way i can combine All and Any in the Filter?

This currently not supported as there is no nesting syntax.

Sorry for wasting your time and thanks for the help yesterday again.

Don't be. I'm glad you got it working. Enjoy the software!

@mevdschee
Copy link
Owner

You asked:

Is there any way i can combine All and Any in the Filter?

I answered:

This currently not supported as there is no nesting syntax.

But this is no longer true (in v2), see:

https://github.com/mevdschee/php-crud-api#multiple-filters

You can now combine AND and OR :-)

Enjoy!

@mevdschee
Copy link
Owner

There are no plans to support sorting on fields of included tables.

@mevdschee mevdschee reopened this Mar 24, 2019
@mevdschee
Copy link
Owner

I'll keep this open as a feature request.

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

No branches or pull requests

2 participants