Stupid-Table-Plugin icon indicating copy to clipboard operation
Stupid-Table-Plugin copied to clipboard

Added 'data-sort-ignore' so we can exclude certain <tr> in the sorting

Open ollejacobsen opened this issue 8 years ago • 5 comments

This change is Reviewable

ollejacobsen avatar Apr 26 '16 20:04 ollejacobsen

+1

tomsommer avatar Jul 07 '16 13:07 tomsommer

Hi there. What is the use case for this?

joequery avatar Nov 05 '16 16:11 joequery

Tag one/many row that will be sticky. In my case I needed the top row to be ignored when sorting. You can see a sample of this here on the top .. directory.

http://corebrowser20161026075844.azurewebsites.net/Images

Kind regards, Olle

Den 5 nov. 2016 17:28 skrev "Joseph McCullough" [email protected]:

Hi there. What is the use case for this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joequery/Stupid-Table-Plugin/pull/163#issuecomment-258622556, or mute the thread https://github.com/notifications/unsubscribe-auth/AAp8XHhtYXXhJf4JD6Y2PJB1SHeZuQWRks5q7K6cgaJpZM4IQUpv .

ollejacobsen avatar Nov 05 '16 16:11 ollejacobsen

it's pretty easy to fix this manually. My solution:

pass a settings to the plugin, which I called skipRowsSelector and there one can pass a selector, then you simply need to find all the tr elements which are not the skipRowsSelector

.find("tbody").find("tr").not(settings.skipRowsSelector)

yairEO avatar Sep 06 '17 13:09 yairEO

I think transforming this line into a settings function would allow this to be flexible enough to accommodate this request.

var trs = $table.children("tbody").children("tr");

Something like:

  $.fn.stupidtable.default_settings = {
    get_table_rows: function($table){
      return $table.children("tbody").children("tr");
    },
    ...
    ...
  };

And you could override this via

var $table = $("#mytable");
$table.stupidtable_settings({
    get_table_rows: function($table){
        return $table.children("tbody").children("tr").slice(1);
    }
});
$table.stupidtable();

This issue was created before the stupidtable_settings was introduced, but I think the settings infrastructure can accommodate it well.

joequery avatar Sep 06 '17 16:09 joequery