Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I see what you mean. Unfortunately, this is not totally easy. You will basically have to keep the “Last Name” column in addition to the (new) full name column.
    We can then instruct the sorting algorithm to use the “Last Name” column for the sorting, but to hide it from the user.
    For that, you would then have to add something like this to the “Custom Commands” text field on the table’s “Edit” screen:

    "columnDefs": [ { "orderData": [ 0 ], "targets": [ 1 ]  }, { "visible": false, "targets": [ 0 ]  } ]

    This would basically instruct column 2 to use the data from column 1 for the sorting (note that counting the columns in that code starts with 0).

    Regards,
    Tobias

    Thread Starter izie

    (@izie)

    Thank you so much! I will try to solve this with your suggestion!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Thread Starter izie

    (@izie)

    Hi again,

    I’m still having trouble with this.

    I used the code, which worked! It allowed me to sort by the new full name column, using the information inputted into the last name column. However, when I try to hide the last name column, I am no longer able to sort the names. In fact, it takes the sorting option away.

    Any help would be greatly appreciated!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    how did you hide the “Last Name” column? The JS command from above should actually already do that (if the number are correct).

    Regards,
    Tobias

    Thread Starter izie

    (@izie)

    Hi again,

    Here is the command you suggested, but edited to correlate to my table:
    "columnDefs": [ { "orderData": [ 2 ], "targets": [ 1 ] }, { "visible": false, "targets": [ 2 ] } ]

    Here is the same one, but it combines the commands I previously had:
    "columnDefs": [ { "orderData": [ 2 ], "targets": [ 1 ] }, { "visible": false, "targets": [ 2 ] }, { "orderable": false, "targets": [ 0, 9 ] } ]
    …I don’t want columns 0 and 9 to be sortable, but with this command I can no longer sort column 1 using the inputted information from column 2.

    So I tried this, and just made column 2 hidden manually (by selecting the column and then selecting ‘hide column’):
    "columnDefs": [ { "orderData": [ 2 ], "targets": [ 1 ] }, { "orderable": false, "targets": [ 0, 9 ] } ]

    But once hidden, I don’t get the option to sort.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    using the “Hide column” button on the “Edit” screen is indeed no option here, as that would result in the data not even being available to the JavaScript code.

    Now, when setting the column numbers in your “Custom Command”, did you start counting the columns with 0?

    Can you set up the combined command again so that I can take a direct look?

    Regards,
    Tobias

    Thread Starter izie

    (@izie)

    Hi!

    I actually copied and pasted the command again, and as I went to make the page public I saw that the table may be doing more of what I need it to.

    Thank you!

    I’ll be in touch if more questions arrive!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Consolidating columns without changing sorting options’ is closed to new replies.