Sunday, June 25, 2023

DataTables.net table rows can be toggled (hide or show) using a checkbox based on some conditions.

If you are planning to display only certain data rows based on a condition in DataTables.net, here is the JavaScript code to do that.


function ToggleDataTableRows() {
    if (dataTableObject != null) {
        let hideSomeDataChecked = $("#hideSomeDataCheckBox").is(":checked");
        if (hideSomeDataChecked == true) {
            $.fn.dataTable.ext.search.push(
                function (settings, data, dataIndex) {
                    // If data in 6th Column does not meet some condition
// return true. Which means some rows are being hidden now.
                    if (data[5] != "SomeCondition") {
                        return true;
                    }
                }
            );
        }
        else {
            // Retrieve data
            // var data = hpDataTable.column(1, { search: 'applied' }).data();
            // Restore search criteria
            $.fn.dataTable.ext.search.pop();
        }
        displayTableObject.draw();
    }
}

Saturday, March 26, 2022

ASP.NET Core Transient, Scoped and Singleton

 Transient operations are always different, a new instance is created with every retrieval of the service.

Scoped operations change only with a new scope but are the same instance within a scope.

Singleton operations are always the same, a new instance is only created once.

All Blogs so far ...