<commit_before><jq:jquery>
%{--todo - toate proprietatile de dus in config --}%
    var oTable = $('#${gridConfig.id}').dataTable( {

        bFilter : true,
       "oLanguage": {
                "sSearch": "Search all columns:"
            },

       "bStateSave": false,
        'sPaginationType': 'full_numbers',

       "fnInitComplete": function() {

            //hack - removes the filter div
            $('#${gridConfig.id}_filter').remove();
            var oSettings = $('#${gridConfig.id}').dataTable().fnSettings();
            for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ){
                if(oSettings.aoPreSearchCols[i].sSearch.length>0){
                    console.log(oSettings.aoPreSearchCols[i].sSearch);
                    $("tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
                    $("tfoot input")[i].className = "";
                }
            }
       },

       "bSort": true,
       "bProcessing": true,
       "bServerSide": true,
       "sAjaxSource": "${g.createLink(action: "${gridConfig.id}Rows")}" ,
       "aoColumns": [
    <g:each in="${gridConfig.columns}" var="col" status="idx">
        { "sName": "${col.datatable.name}", "bSortable": true }  <g:if
            test="${idx < gridConfig.columns.size() - 1}">,</g:if>
    </g:each>
    ]

} );


    /* Add the events etc before DataTables hides a column */
   $("tfoot input").keyup( function () {
       /* Filter on the column (the index) of this element */
       oTable.fnFilter( this.value, oTable.oApi._fnVisibleToColumnIndex(
           oTable.fnSettings(), $("thead input").index(this) ) );
   } );

   /*
    * Support functions to provide a little bit of 'user friendlyness' to the textboxes
    */
   $("tfoot input").each( function (i) {
       this.initVal = this.value;
   } );

   $("tfoot input").focus( function () {
       if ( this.className == "search_init" )
       {
           this.className = "";
           this.value = "";
       }
   } );

   $("tfoot input").blur( function (i) {
       if ( this.value == "" )
       {
           this.className = "search_init";
           this.value = this.initVal;
       }
   } );

</jq:jquery>

<table cellpadding="0" cellspacing="0" border="0" class="display"
       id="${gridConfig.id}">%{--width="${gridConfig.datatable.width}">--}%
    <thead>
    <tr>
        <g:each in="${gridConfig.columns}" var="col">
            <th %{--width="${col.datatable.width}"--}%>${message(code: col.label, default: col.label)}</th>
        </g:each>
    </tr>


    </thead>
    <tbody>
    <tr>
        <td colspan="${gridConfig.columns.size()}" class="dataTables_empty">Loading data from server</td>
    </tr>
    </tbody>
    <tfoot>

    <tr>
        <g:each in="${gridConfig.columns}" var="col">
            <td width="${col.datatable.width}">
                <g:if test="${col.datatable.search}">
                    <input type="text" name="search_${col.datatable.name}" class="search_init"
                           width="${col.datatable.width}"/>
                </g:if>
                <g:else>
                    &nbsp;
                </g:else>
            </td>
        </g:each>
    </tr>

    %{--
        <tr>
            <g:each in="${gridConfig.columns}" var="col">
                <th width="${col.datatable.width}">${message(code: col.label, default: col.label)}</th>
            </g:each>
        </tr>
    --}%
    </tfoot>
</table>
<commit_msg>added search form for datatables<commit_after>%{--<jq:jquery>--}%
<script type="text/javascript">jQuery(function () {

    %{--todo - move some hardcodings to the config --}%
    var oTable = $('#${gridConfig.id}').dataTable({
        bFilter:true,
        "bStateSave":false,
        'sPaginationType':'full_numbers',
        "fnInitComplete":function () {
            //hack - removes the filter div
            $('#${gridConfig.id}_filter').remove();
            var oSettings = $('#${gridConfig.id}').dataTable().fnSettings();
            for (var i = 0; i < oSettings.aoPreSearchCols.length; i++) {
                if (oSettings.aoPreSearchCols[i].sSearch.length > 0) {
                    console.log(oSettings.aoPreSearchCols[i].sSearch);
                    $("tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
                    $("tfoot input")[i].className = "";
                }
            }
        },
        "bSort":true,
        "bProcessing":true,
        "bServerSide":true,
        "sAjaxSource":"${g.createLink(action: "${gridConfig.id}Rows")}",
        "aoColumns":[
            <g:each in="${gridConfig.columns}" var="col" status="idx">
            { "sName":"${col.datatable.name}", "bSortable":true }  <g:if test="${idx < gridConfig.columns.size() - 1}">,
            </g:if>
            </g:each>
        ]

    });

    /* Add the events etc before DataTables hides a column */
    $("tfoot input").keyup(function () {
        /* Filter on the column (the index) of this element */
        oTable.fnFilter(this.value, oTable.oApi._fnVisibleToColumnIndex(oTable.fnSettings(), $("tfoot input").index(this)));
    });

    /*
     * Support functions to provide a little bit of 'user friendlyness' to the textboxes
     */
    $("tfoot input").each(function (i) {
        this.initVal = this.value;
    });

    $("tfoot input").focus(function () {
        if (this.className == "search_init") {
            this.className = "";
            this.value = "";
        }
    });

    $("tfoot input").blur(function (i) {
        if (this.value == "") {
            this.className = "search_init";
            this.value = this.initVal;
        }
    });

});
</script>

%{--</jq:jquery>--}%

<table id="${gridConfig.id}" cellpadding="0" cellspacing="0" border="0"
       class="display">%{--width="${gridConfig.datatable.width}">--}%
    <thead>
    <tr>
        <g:each in="${gridConfig.columns}" var="col">
            <th %{--width="${col.datatable.width}"--}%>${message(code: col.label, default: col.label)}</th>
        </g:each>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td colspan="${gridConfig.columns.size()}" class="dataTables_empty">Loading data from server</td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
        <g:each in="${gridConfig.columns}" var="col">
            <td>%{--width="${col.datatable.width}">--}%
                <g:if test="${col.datatable.search}">
                    <input type="text" name="search_${col.datatable.name}" class="search_init" size="10"/>
                </g:if>
                <g:else>
                    &nbsp;
                </g:else>
            </td>
        </g:each>
    </tr>
    </tfoot>
</table>

{'fraction_non_alphanumeric': 0.1913839687781447, 'fraction_numerical': 0.0021014710297208045, 'mean_word_length': 1.9865531151949798, 'pattern_counts': {'":': 20, '<': 85, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6197880', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2071, 'n_words': 371}