bootstrap-table-filter icon indicating copy to clipboard operation
bootstrap-table-filter copied to clipboard

bootstrapTableFilter doesn't reload table

Open maxfrz21 opened this issue 10 years ago • 1 comments

Hello,

I have this problem with your plugin: after applying filters with the command "bootstrapTableFilter (' getData ')", the linked table isn't reloaded. Filters are not executed.

I'm using last version of plugin.

The code is this:

$('#filter-bar').bootstrapTableFilter({ filters:[ { field: 'descrizioneComune', // field identifier label: 'descrizione Comune', // filter label type: 'search' // filter type }, { field: 'supTot', // field identifier label: 'Sup. (Kmq)', // filter label type: 'range' // filter type }, ], connectTo: '#comuniGALJson', onSubmit: function() { var data = $('#filter-bar').bootstrapTableFilter('getData'); console.log(data); } });

Thanks in advance, Max

maxfrz21 avatar Oct 05 '15 09:10 maxfrz21

I've found a solution for my issue...

  1. I've found a bug in "bs-table.js". At line 63 "filter" is not defined, so i've add declaration "var filter;"
  2. I've configured my custom table in this way:

$( document ).ready(function() { $('#comuniGALJson').bootstrapTable( { queryParams: function(params) { var values = $('#filter-bar').bootstrapTableFilter('getData'); if ( !jQuery.isEmptyObject(values)) { var elabFilter = JSON.stringify(values); return elabFilter; } return params; } } );

        $('#filter-bar').bootstrapTableFilter({
            filters:[
                {
                    field: 'descrizioneComune',   
                    label: 'descrizione Comune',  
                    type: 'search'   
                },
                {
                    field: 'supTot',    
                    label: 'Sup. (Kmq)',   
                    type: 'range'   
                },
            ],
            connectTo: '#comuniGALJson',
            onSubmit: function() {
                var data = $('#filter-bar').bootstrapTableFilter('getData');
                console.log(data);
            }
        });
    });

maxfrz21 avatar Oct 06 '15 10:10 maxfrz21