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

Gridfield sortable button #56

Closed
vinnie-watson opened this issue Apr 30, 2014 · 5 comments
Closed

Gridfield sortable button #56

vinnie-watson opened this issue Apr 30, 2014 · 5 comments

Comments

@vinnie-watson
Copy link

Hi,
I'm not sure if this is where I submit requests but here goes,
I am working on a site where the client has requested to be able to sort DataObjects which are in visible in a ModelAdmin GridField, they have too many objects to sort by hand so I was woundering if you have thought of making a simple selectbox in the GridField actions to update the sort order alphabetically quickly and efficiently?

@UndefinedOffset
Copy link
Owner

Totally the perfect place to submit the request, how ever in this case I don't think it is a good fit for this module. Are you simply trying to sort these DataObjects always alphabetically? If that's the case I would suggest you look into the default_sort static. If this is a one off to get an initial sort so they can drag and drop sort after that I would recommend looking into doing some query right on the database that would set the sort column starting at 1.

@vinnie-watson
Copy link
Author

I was using alphabetical sort as an example, if that was the case I can already use the DataList::sort method in Silverstripe but with my problem the client would like a way to sort the DataObjects by aspecified criteria that would be reflected on the front-end. I see that I can add an action to a GridField and that would allow me to update the database to change the sort order like you have done when you drag them around. The point I am trying to make is that if there are 100 DataObjects you may not want to sort all of them by dragging and a select box( or other option ) could help sort by alphabetically or any DB field that is on the DataObjects.

it might be worth me forking this repo and seing if I can figure out how

@UndefinedOffset
Copy link
Owner

You know what might be an idea since it sounds like the client wants to control the sort column have a dropdown maybe in settings. That lets the client pick from a columns to sort the data on, then use that in your datalist sort call. Regardless I think at the core of the issue your trying to solve rather than re-index 100s of rows when from what it sounds to me could be better done by using a call to sort() on a datalist. Again if this is a static sort and the client does not want to be able to change it I would look at the $default_sort static on data objects, this does get taken into account in grid field and by default on the front end.

@vinnie-watson
Copy link
Author

right I have realized that I'll be able to update the sort by using default sort which would make it a great deal easier, I still think that the drop-down would be better suited as a GridField action just for better usability since the client would like to control the sort and I can see that this would be used alot in my websites, anyway thanks for your thought on this it has cleared up alot of my thinking space lol!

@UndefinedOffset
Copy link
Owner

Haha no problem

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

2 participants