3

I am using DataTables Row Grouping Add-on. I used it by select box change event.

Code

In PHP :

<select id="Group-Discoveries" name="Group-Discoveries" class="input-medium">
<option value="">None</option>
<option value="6">Domain</option>
<option value="7">Type</option>
<option value="8">Category</option>
<option value="9">Status</option>
</select>

In JS :

$(document).ready(function() {    
var DTable = $('#discovery').dataTable( {
            "sDom": "<'row-fluid'<'span3'<'toolbar'>><'span3'<'selectbar'>><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
            "bPaginate": false
        });
        $('#Group-Discoveries').live('change', function(){
            var index = $(this).val();
            if(index == ''){

            }
            else{
                DTable.rowGrouping({
                    "iGroupingColumnIndex": index,
                    "bHideGroupingColumn": false,
                    "bHideGroupingOrderByColumn": false,
                    "sGroupingClass":"group_"+index,
                    "bSetGroupingClassOnTR":true,
                    "bExpandableGrouping":true
                });
            }
        });
});

I want to remove rowgrouping when the index is empty.

Thanks.

2
  • Have you found out how to do this? Commented Jan 7, 2013 at 22:07
  • @cpoDesign No, But now I use ajax reloading for that. Commented Jan 8, 2013 at 8:14

1 Answer 1

3

I found the solution - remove the draw callback that the grouping plugin creates and reset the group sorting:

var oSettings = jQuery('#table').dataTable().fnSettings();

for (f = 0; f < oSettings.aoDrawCallback.length; f++) {
    if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') {
        oSettings.aoDrawCallback.splice(f, 1);
        break;
    }
}

oSettings.aaSortingFixed = null;

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.