-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add "order nulls last" option #242
Conversation
I'm open to also creating a per column option. But I'm unsure where that would go and how to pass it to the SimpleOrder class. Any ideas would be helpful. Thanks! |
well, you have to add method a public into def nulls_last
@view_column.fetch(:nulls_last, true)
end and then you can access from |
@ajahongir I'm running into an issue in the test where I can't call |
where is your test falling? |
It's failing in the simple_order_spec. But it traces back to simple_order.rb where I'm calling |
@@ -20,6 +20,14 @@ def column | |||
def direction | |||
DIRECTIONS.find { |dir| dir == @options[:dir].upcase } || 'ASC' | |||
end | |||
|
|||
def sort_nulls_last(sort_column) | |||
if column.nulls_last == true || AjaxDatatablesRails.config.nulls_last == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort_column.nulls_last
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sort_column
is just a string so that doesn't work. I need access to the column options.
@@ -1,13 +1,37 @@ | |||
require 'spec_helper' | |||
|
|||
describe AjaxDatatablesRails::Datatable::SimpleOrder do | |||
|
|||
let(:datatable) { ReallyComplexDatatable.new(double('view', params: sample_params)) } | |||
let(:sorted_datatable) { DatatableOrderNullsLast.new(double('view', params: sample_params)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seams here you datatable instance returning nil
…nstead of just the double.
So, I got things worked out. But the build is failing on the Oracle tests. I don't think it is related to my changes. What do I need to do to get them passing? |
Also, does this need readme documentation? I'm happy to add that to this PR if you want it. |
Any ideas on how to get the Oracle tests passing? |
What can I do to get this Oracle test passing? |
@natebird the Oracle tests now pass, can you please rebase? |
Yep. I’ll do it later tonight. Thanks! |
be careful there's a lot of changes :/ |
…on to be overridden.
…nstead of just the double.
Closing in favor of the cleaner, #279 PR. I couldn't do a clean rebase so I just recreated the branch. :-) |
config.nulls_last = true
in theajax_datatables_rails.rb
file.nulls_last: true
to the view_columns method in the datatable class.