jQWidgets Forums

jQuery UI Widgets Forums DataTable Data Table filter showing hidden fields

This topic contains 2 replies, has 2 voices, and was last updated by  Andrew Cooper 10 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Data Table filter showing hidden fields #60588

    Andrew Cooper
    Participant

    I’ve got a DataTable that has some hidden fields on each row (like the ID field). I’ve enabled the filtering. The hidden fields show up in the dropdown list of fields to filter on. I don’t want that behavior. Can I get it to ignore hidden fields when filtering?

    Andrew

    Data Table filter showing hidden fields #60603

    Nadezhda
    Participant

    Hello Andrew,

    You can set column “filterable” to false and “hidden” to true as the following example shows:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>    
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> 
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdatatable.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                
                // prepare the data
                var source =
                {
                    dataType: "xml",
                    dataFields: [
                         { name: 'SupplierName', type: 'string' },
                         { name: 'Quantity', type: 'number' },
                         { name: 'OrderDate', type: 'date' },
                         { name: 'OrderAddress', type: 'string' },
                         { name: 'Freight', type: 'number' },
                         { name: 'Price', type: 'number' },
                         { name: 'City', type: 'string' },
                         { name: 'ProductName', type: 'string' },
                         { name: 'Address', type: 'string' }
                    ], 
                    url: '../sampledata/orderdetailsextended.xml',
                    root: 'DATA',
                    record: 'ROW'
                };
                var dataAdapter = new $.jqx.dataAdapter(source, {
                    loadComplete: function () {
                        // data is loaded.
                    }
                });
                // create jqxDataTable.
                $("#table").jqxDataTable(
                {
                    source: dataAdapter,
                    pageable: true,
                    altRows: true,
                    filterable: true,
                    width: 850,
                    columns: [
                      { text: 'Supplier Name', cellsAlign: 'center', align: 'center', dataField: 'SupplierName', width: 250, filterable: false, hidden:true  },
                      { text: 'Name', cellsAlign: 'center', align: 'center', dataField: 'ProductName', width: 250 },
                      { text: 'Quantity', dataField: 'Quantity', cellsformat: 'd', cellsAlign: 'center', align: 'center', width: 120 },
                      { text: 'Price', dataField: 'Price', cellsformat: 'c2', align: 'center', cellsAlign: 'center', width: 120 },
                      { text: 'City', cellsAlign: 'center', align: 'center', dataField: 'City' }
                    ]
                });          
            });
        </script>
    </head>
    <body class='default'>
        <div id="table">
        </div>
    </body>
    </html>

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

    Data Table filter showing hidden fields #60606

    Andrew Cooper
    Participant

    Somehow I missed the filterable property. You are awesome. Thanks.

    Andrew

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.