Liooo / jquery-datatables-row-grouping

Automatically exported from code.google.com/p/jquery-datatables-row-grouping
0 stars 0 forks source link

_fnGetCleanedGroup does not replace all occurrences #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. If you have more than one space in the grouping text only the first space 
gets replaced thus some words get interpreted as a class (i.e. ' error' )
2. Another slightly related issue is if you have tags in the grouped content 
and quotes get used in them sometimes and are not always escaped

What is the expected output? What do you see instead?
Only the first space gets turned into a dash as is the default behavior in the 
JavaScript replace function

Please provide any additional information below.
The fix to really clean the group would be to use a regular expression 
parameter as follows:

  function _fnGetCleanedGroup(sGroup) {
                return sGroup.toLowerCase().replace(/ /g, "-").replace(/</g, "-").replace(/>/g, "-").replace(/"/g, "-");
            }

Original issue reported on code.google.com by isa...@gmail.com on 12 Nov 2013 at 4:08

GoogleCodeExporter commented 8 years ago
I am using this for the first time and noticed that if we set 
"bExpandableGrouping": true and my group header text has some special 
characters then expand/collapse will throw exception.
I tried following things: 
1.  Add new method to replace all special characters with –
(implementation can be improved)
        function _fnGetCleanedGroup(sGroup){
            sGroup= sGroup.replace(/\./g, '-');
            sGroup= sGroup.replace(/\//g, '-');
            sGroup= sGroup.replace(/\(/g, '-');
            sGroup= sGroup.replace(/\)/g, '-');
            sGroup= sGroup.replace(/\ /g, '-');
            sGroup= sGroup.replace(/\\/g, '-');
            sGroup= sGroup.replace(/\!/g, '-');
            sGroup= sGroup.replace(/\,/g, '-');
            return sGroup;
        }
2.  Replace following strings in method $(nCell).click:
sGroup = _fnGetCleanedGroup(sGroup);

Thanks,
Ashish U

Original comment by ubgadeas...@gmail.com on 21 Mar 2014 at 4:40