Skip to content

Instantly share code, notes, and snippets.

View iamrealfarhanbd's full-sized avatar
💻
always do code

Farhan Ahmed iamrealfarhanbd

💻
always do code
View GitHub Profile
jQuery(document).ready(function($) {
// Use a delay to ensure the chart is fully rendered
setTimeout(function() {
// Find the canvas element dynamically
var canvas = $('#ninja-charts-container canvas').first();
var canvasId = canvas.attr('id');
// Get the Chart.js instance
var chart = Chart.getChart(canvasId);
@iamrealfarhanbd
iamrealfarhanbd / Ninja-Tables hide show columns.js
Created August 27, 2024 10:45
You can add the below code into your table custom js field to hide/show column for dropdown checkbox near the search field.
/*
::::::::::::::::::::::
:: hide/show columns::
::::::::::::::::::::::
*/
jQuery('.dropdown-menu-right input').on('change',function(e){
e.preventDefault();
jQuery('.dropdown-menu-right input').each(function(e){
console.log(jQuery(this).is(":checked"));
@iamrealfarhanbd
iamrealfarhanbd / Custom Dropdown for Ninja Tables: Frontend Editing Enhancement.js
Last active August 15, 2024 11:59
This JavaScript solution addresses an issue with dropdown select fields in Ninja Tables' frontend editing interface. It replaces the default Select Field with a custom modal that allows users to select multiple options more effectively. The script hides the original select field and displays a custom input field with selected options, resolving …
// Custom Dropdown CSS
/*
/* Hidden select field */
.nt_input_YourColumnKey_a,.nt_input_YourColumnKey_b {
display: none; /* Hide the original select field */
}
/* Custom dropdown trigger (input field) */
.custom-dropdown-trigger {
display: inline-block;
width: 100%;
@iamrealfarhanbd
iamrealfarhanbd / Workaround for Ninja Tables Custom Filter - Reset All Button.js
Last active August 7, 2024 06:54
This Gist provides a workaround for issues with the "Reset All" button in Ninja Tables when using multiple select options. This code ensures that the "Reset All" button properly interacts with the filter controls, even when they are dynamically generated or modified.
$(document).ready(function() {
console.log("Document is ready");
// Use event delegation to handle clicks on dynamically generated .reset-all elements
$(document).on('click', '.reset-all', function() {
console.log("Reset all button clicked");
if ($('.optWrapper').hasClass('isFloating')) {
// Check if the .fooicon element has the class .fooicon-remove
if ($('.fooicon').hasClass('fooicon-remove')) {
console.log("Class fooicon-remove found");
@iamrealfarhanbd
iamrealfarhanbd / Ninja Tables Image Tooltip with Hover Effect.js
Last active July 11, 2024 05:09
This Gist contains a jQuery and CSS to create a tooltip for Ninja Tables that displays an image preview when hovering over a link. The tooltip will only appear if the link contains an href attribute. I have recorded a video for you where I have demonstrated the whole process; please take a moment to view the video: https://jam.dev/c/23acad4a-72b…
/*
* This code snippet allows you to add image tooltips to cells in a Ninja Table.
* The tooltip displays an image when hovering over a table cell containing a link.
* Add the JS code to the custom JS field, the CSS code to the custom CSS field,
* and use the provided HTML structure in your table cells.
*/
<!-- HTML structure for table cells with image tooltips -->
<a class="imageTooltip" href="https://fairsnail.s4-tastewp.com/wp-content/uploads/woocommerce-placeholder.png">
<img src="https://fairsnail.s4-tastewp.com/wp-content/uploads/woocommerce-placeholder.png" />
@iamrealfarhanbd
iamrealfarhanbd / How To Use Excel Formulas in Ninja Tables.md
Last active May 22, 2024 10:08
How To Use Excel Formulas in Ninja Tables

Documentation: Using Excel Formulas in Ninja Tables

Ninja Tables supports various Excel formulas to manipulate data directly within the table. Below is a list of supported Excel formulas along with examples of how to use them in Ninja Tables.

Supported Excel Formulas:

For a comprehensive list of supported Excel formulas, please refer to Screenshot link.

Usage Example:

Documentation: Display Entries Submitted by Current User in Ninja Tables

This guide will help you display only the entries submitted by the current logged-in user using the Ninja Tables plugin in WordPress.

Steps to Achieve Current User Entries Display

1. Add User Information to Table Column

Ensure that the table includes a column with the user's name, email, or any user unique identifier.

@iamrealfarhanbd
iamrealfarhanbd / Modify Ninja Tables Data: Apply Filter Before Limiting Results.php
Created May 22, 2024 05:20
Modify Ninja Tables Data: Apply Filter and Limit in ninja_tables_get_public_data Filter Hook
add_filter('ninja_tables_get_public_data', function ($data, $tableId) {
// Set the limit and filter name here (you can adjust these values as needed)
$limit = Your_Limit_Value;
$filter_name = 'Your_Filter_Key_Word';
// Check if the current table ID matches the targeted table ID
if ($tableId == 426) { // Replace 426 with the actual table ID
// Apply the filter first
@iamrealfarhanbd
iamrealfarhanbd / Modify Ninja Tables Data Retrieval for Full-Size Image Display.php
Created May 18, 2024 05:58
This PHP code snippet demonstrates how to use the ninja_tables_get_raw_table_data filter hook to modify data fetched from Ninja Tables. Specifically, it replaces thumbnail image URLs with their corresponding full-size image URLs in the image column of a Ninja Table with YourTableID. This customization ensures that larger images are used when dis…
add_filter('ninja_tables_get_raw_table_data', function ($data, $tableId) {
// Adjust this condition based on your target table ID
if ($tableId == YourTableID) { //Change YourTableID with your table ID
foreach ($data as &$row) {
foreach ($row as $key => $value) {
// Check if the value is an array with 'image_thumb' and 'image_full' keys
if (is_array($value) && isset($value['image_thumb']) && isset($value['image_full'])) {
// Replace the 'image_thumb' URL with the 'image_full' URL
$row[$key]['image_thumb'] = $value['image_full'];
}
@iamrealfarhanbd
iamrealfarhanbd / Enhanced Pagination with Goto Input Field for Ninja Tables.js
Last active May 9, 2024 07:13
This jQuery code snippet enhances the pagination of Ninja Tables by adding a numeric input field where users can input the page number they want to navigate to directly. The input field ensures smoother navigation through large datasets, allowing users to jump to specific pages effortlessly.
jQuery(document).ready(function() {
// Function to add goto page functionality
function addGotoPageFunctionality() {
// Check if the goto input field already exists
if ($('#gotoPage').length === 0) {
// Create the goto input field and button
var gotoInput = $('<input>', { type: 'number', id: 'gotoPage', placeholder: 'Go to page', class: 'form-control', min: "1" , max: $('.footable-page').length,style: 'width:100px;padding:17px 0!important;text-align:center;' });
var gotoButton = $('<button>', { id: 'gotoButton', class: 'btn btn-default', text: 'Go' });
var gotoElement = $('<li>', { class: 'nt_goto_pager', 'aria-label': 'goto page', style: 'display:inline-flex!important;align-items:center;' }).append(gotoInput, gotoButton);