A few questions and some bug reports

A few questions and some bug reports

RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
edited November 2013 in General
Hello,

I am using the last version of DataTables 1.10 available on GitHub
I've got some questions or possible bugs to post:

The "sorting: []" option doesn't seem to work as it should. Instead of starting DataTable with no sorting applied, it applies ascending sorting, and it looks like it applies it to the first column, even if it is set to "sortable: false"

Example:
http://fiddle.jshell.net/8jb8j/8/

For the second bug, you need to include ColReorder. Switch the position of columns Module and Name ("oColReorder":{"aiOrder":[0,1,3,2,4,5]}), and then sort Name by ascending order ("sorting":[[2, 'asc']]). The column Name is highlighted, as it should be, because it is the one being sorted, but the sorting arrow, stays at Module, making you think you're sorting Module instead of Name.

Example:
http://fiddle.jshell.net/8jb8j/9/

Third feature addition needs ColVis. Whenever you hide a column with ColVis, it hides the column, and sends a request to the server (when server-side is used). I don't see the point of querying the server, at least for my application. So would it be possible to get an option where we could choose whether to hide the column or hide & fire request?

Fourth request is for the function row.child.hide() to be renamed to something less misleading, as it removes the elements, instead of actually hiding it, as you would expect for such name.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited November 2013
    Hi,

    Thanks for the comments!

    > The "sorting: []" option doesn't seem to work as it should.

    Yup - looks broken :-(. I'll look into it.

    > ColReorder

    You have server-side processing enabled in the example. If you remove that, and have client-side processing it appears to work as expected.

    > Third feature addition needs ColVis. Whenever you hide a column with ColVis, it hides the column, and sends a request to the server (when server-side is used).

    Agreed - I need to sort this out. It does an Ajax call because of the need to redraw they able, but it does technically have all the information needed. I need to add code to "short cut" this.

    > Fourth request is for the function row.child.hide() to be renamed to something less misleading, as it removes the elements, instead of actually hiding it, as you would expect for such name.

    It removes them from the DOM, but you can put them back using `row().child.show()` - however your point is taken, `hide()` means something else in jQuery. I could call it remove() but not sure what to call the show method then...

    Allan
  • RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
    edited November 2013
    [quote]You have server-side processing enabled in the example. If you remove that, and have client-side processing it appears to work as expected.[/quote]

    I need server side processing. But I noticed that removing the "aiOrder":[0,1,3,2,4,5]" makes it work as expected. So this is the part that is somehow messing with the logic.

    [quote]It removes them from the DOM, but you can put them back using row().child.show() - however your point is taken, hide() means something else in jQuery. I could call it remove() but not sure what to call the show method then...[/quote]

    I am loading them with Ajax, so re-creating them with .show() would require a new request to the server each time I am show()ing it. That is why an option to pass a true/false argument whether to destroy the elements or just hide them would be very handy, where .hide(true) would remove the elements and .hide() would just hide them.

    Also, thank you for taking the time to look into these issues! I appreciate it very much :)
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    [quote]I could call it remove() but not sure what to call the show method then...[/quote]

    reshow
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > I need server side processing

    But there is no sever-side processing script in the example. So I don't think the example truly reflects the issue. However, given that you posted it, I assume you are seeing this in a "real" environment. Something else I'll also look into!

    > That is why an option to pass a true/false argument whether to destroy the elements or just hide them would be very handy

    Interesting idea! The elements will be destroyed when you next append new child elements, but there isn't currently a method of explicitly destroying the child rows.

    > reshow

    Not a bad suggestion - thanks! It doesn't work if you haven't yet shown the child rows though, since this method can be used for the first show.

    Possibly `append` which is a bit more jQuery like in its action...?

    Allan
  • RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
    [quote]But there is no sever-side processing script in the example. So I don't think the example truly reflects the issue.[/quote]

    Here I've put up an example with server-side processing script, where you can see it actually work as I wrote:
    http://famnit.goo.si/Test/DataTables/Test

    Switch two columns and then try sorting them to see the effect that I'm talking about. Hope this helps.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thanks for the link! When I click to sort a column on that page it reloads the whole page - am I doing something wrong?

    Is your server-side script taking into account the reordered columns? DataTables will send information about which column index is being sorted upon, and you might have to translate that into the column to be used in your script - like is done in this example: http://datatables.net/release-datatables/extras/ColReorder/server_side.html

    Allan
  • RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
    edited November 2013
    You're not doing it wrong, that is exactly how we have it set up.

    Part of our page (with DT) reloads on each action, and we send all the needed info back to the DT initialization object, so it can re-construct itself. (we do so, so that we can dynamically change the grid in runtime while developing, and spare one action in the controller)

    This part you can see in this fiddle:
    http://fiddle.jshell.net/8jb8j/9/

    Where on the bottom left window, at the end of the initialization object, you can see
    [code]"sorting":[[2, 'asc']],"oColReorder":{"aiOrder":[0,1,3,2,4,5]}[/code]

    Just passing these settings to DT init object gives the sorting arrow to one column (wrong one) while highlighting another (right one). And this is the bug I am talking about.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I've just committed a fix for the `sorting: []` issue: https://github.com/DataTables/DataTablesSrc/commit/6ebbd9f . It is in the src and built repos now.

    Still to take a look at the ColReorder stuff though.

    Allan
This discussion has been closed.