DataTables - using class names in aTargets
Hi, There have been a fair number of bugs filed for fixing table sorting as columns get added to or removed from tables. At root, they stem from our current habit of referring to columns by numeric position in aoColumns and aoColumnDefs/aTargets, e.g., { "aTargets": [ 1, 2 ], "sType": "natural" } and "aoColumns": [ { "sType": "title-string" },{ "sType": "html" },null,{ "sType": "title-string" },null,null,null,null,null,null[% IF ( exports_enabled ) %],null[% END %] ], However, the documentation for DataTables says that aTargets doesn't have to be just an array of integers; it can also be "a string - class name will be matched on the TH for the column". To reduce the risk of silly columns-sorting bugs, I suggest that we adopt a practice of using descriptive CSS class names for table headers and using the class names in aoColumnsDefs/aTarget specifications, and dropping the use of aoColumns. Thoughts? Regards, Galen -- Galen Charlton Manager of Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org
Sounds like an excellent idea! If everyone is in agreement, I think it should be added to coding guidelines, and to koha-qa.pl if possible. Kyle http://www.kylehall.info ByWater Solutions ( http://bywatersolutions.com ) Meadville Public Library ( http://www.meadvillelibrary.org ) Crawford County Federated Library System ( http://www.ccfls.org ) Mill Run Technology Solutions ( http://millruntech.com ) On Tue, Feb 25, 2014 at 12:34 PM, Galen Charlton <gmc@esilibrary.com> wrote:
Hi,
There have been a fair number of bugs filed for fixing table sorting as columns get added to or removed from tables. At root, they stem from our current habit of referring to columns by numeric position in aoColumns and aoColumnDefs/aTargets, e.g.,
{ "aTargets": [ 1, 2 ], "sType": "natural" }
and
"aoColumns": [ { "sType": "title-string" },{ "sType": "html" },null,{ "sType": "title-string" },null,null,null,null,null,null[% IF ( exports_enabled ) %],null[% END %] ],
However, the documentation for DataTables says that aTargets doesn't have to be just an array of integers; it can also be "a string - class name will be matched on the TH for the column".
To reduce the risk of silly columns-sorting bugs, I suggest that we adopt a practice of using descriptive CSS class names for table headers and using the class names in aoColumnsDefs/aTarget specifications, and dropping the use of aoColumns.
Thoughts?
Regards,
Galen -- Galen Charlton Manager of Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
To reduce the risk of silly columns-sorting bugs, I suggest that we adopt a practice of using descriptive CSS class names for table headers and using the class names in aoColumnsDefs/aTarget specifications, and dropping the use of aoColumns.
I'm fine with making this an official coding guideline. -- Owen -- Web Developer Athens County Public Libraries http://www.myacpl.org
However, the documentation for DataTables says that aTargets doesn't have to be just an array of integers; it can also be "a string - class name will be matched on the TH for the column".
By the way, we do have some instances of this if anyone is looking for an example. See opac-user.tt in the bootstrap and prog themes. -- Owen -- Web Developer Athens County Public Libraries http://www.myacpl.org
participants (3)
-
Galen Charlton -
Kyle Hall -
Owen Leonard