Is there a way to divide and utilize alphabet search and datatable in separate HTML divs on a single page?

I have integrated responsive data tables with alphabet search functionality in my app and everything seems to be set up correctly.

The code snippet I provided is not working on StackOverflow or I am unable to include it properly there. Please refer to the code on jsfiddle

$(document).ready(function() {
  var table = $('#example').DataTable({
    ajax: 'https://api.myjson.com/bins/qgcu',
    dom: 'Alfrtip',
    alphabetSearch: {
      column: 0
    },
    responsive: true
  });
});
table.dataTable.select tbody tr,
table.dataTable thead th:first-child {
  cursor: pointer;
}
<script src="https://gyrocode.github.io/jquery-datatables-alphabetSearch/1.1.1/js/dataTables.alphabetSearch.min.js"></script>
<link href="https://gyrocode.github.io/jquery-datatables-alphabetSearch/1.1.1/css/dataTables.alphabetSearch.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/v/dt/dt-1.10.15/r-2.1.1/datatables.min.css" rel="stylesheet" />
<script src="https://cdn.datatables.net/v/dt/dt-1.10.15/r-2.1.1/datatables.min.js"></script>
<h3><a href="http://www.gyrocode.com/articles/jquery-datatables-alphabetical-search/">jQuery DataTables – Alphabetical Search</a></h3>
<a href="http://www.gyrocode.com/articles/jquery-datatables-alphabetical-search/">See full article on Gyrocode.com</a>
<hr><br>

<table id="example" class="display nowrap" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th>Name</th>
      <th>Position</th>
      <th>Office</th>
      <th>Extn</th>
      <th>Start date</th>
      <th>Salary</th>
    </tr>
  </thead>
  <tfoot>
    <tr>
      <th>Name</th>
      <th>Position</th>
      <th>Office</th>
      <th>Age</th>
      <th>Start date</th>
      <th>Salary</th>
    </tr>
  </tfoot>
</table>

I now want to display the alphabets separately in a different division on the same page, without showing them on top of the datatable.

Is there a way to call and display only the alphabets in a different div? Any help would be greatly appreciated.

Answer №1

SOLUTION

Utilize the dom option to customize the markup for the alphabet feature and the table layout. Adjust the appearance of the alphabet control using custom CSS.

For instance,

JavaScript

var table = $('#example').DataTable({
   dom: '<"alphabet-container"A><"table-container"lfrtip>',
   alphabetSearch: {
      column: 0
   },
   responsive: true
});

CSS

.alphabet-container {
   float: left;
   width: 10%;   
}

.table-container {
   float: left;
   width: 90%;
}

.alphabet-container .alphabet-info,
.alphabet-container .alphabet-info-display { 
   display: none 
}

.alphabet-container .alphabet ul,
.alphabet-container .alphabet li,
.alphabet-container .alphabet a {
   display: block;
}

.alphabet-container .alphabet {
   margin: 0 15px 0 0;
}

.alphabet-group td:first-child::before {
   display:none !important;
}

EXAMPLE

View this demo for code implementation and illustration.

LINKS

jQuery DataTables AlphabetSearch - a plugin for jQuery DataTables library offering A-Z alphabetical search feature.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unlimited Rotation with CSS3

I'm attempting to create a spinning image effect that rotates 360 degrees infinitely on hover. However, it seems that the background element I've used to display the image might be causing issues. I'm not sure how else to display the image w ...

What are some ways to utilize CSS variables for enhancing component styles within Svelte?

Presented here is a straightforward component called Text.svelte. It utilizes a CSS variable to prevent unnecessary duplication: <div> <span class="t1">t1</span> <span class="t2">t2</span> </div> ...

Utilize CSS and Bootstrap to ensure equal-sized responsive images in a row by scaling them down to the same dimensions

I am new to web design and struggling with resizing images using the img-fluid class in a particular portfolio view where they function as thumbnails. I will upload some images to clarify my goal. The challenge is maintaining consistency in size for each i ...

"Exploring databases with MySQL and displaying dynamic outcomes with PHP

I am a beginner in PHP and I am attempting to create a basic search engine. My goal is to display a summary of the search results on an HTML page after each search, showing all the items that match the query. Each item summary should include a link to a sp ...

The value of input text in AngularJS forms is consistently evaluated as undefined

Here's my form: <form> <input class="text_box1" type="text" name="email" ng-model="forget.email" > <button style="width:auto" class="sign_up" ng-click="doForget(forget)">Get a Password</button> </form> In my app.js, I h ...

Triggering a click event on an anchor <a> element

Seeking help with a Javascript event query. I have an <a> tag set up like this: <a id='aTag' href='http://example.com'>Click to redirect</a> When attempting to trigger the click event using: <script> $('#a ...

Issues with aligning text in a flexbox using Bootstrap 4's text-center property

I am currently working on a project to create a webpage with two vertical columns that are clickable and lead to different pages. Here is what I have so far. HTML <!-- Choices --> <div class="container-fluid"> <div class="row"> ...

Unusual outcome observed when inputting a random number into HTML using JavaScript

In my HTML file, I am trying to input a number within 50% of a target level into the "Attribute" field. Here is the code: <!DOCTYPE html> <html> <body> <input type = "number" name = "playerLevel" onchan ...

Pictures fail to load on Safari browser for desktop and iPhone, yet display correctly on various other smartphones and Windows browsers

Having trouble with images not displaying on Safari browsers for Mac and iPhones, but they load fine on Windows and Android. Even after updating to the latest version of Bootstrap, the issue persists. Here are the current Bootstrap content delivery networ ...

Submitting HTML form data to a Java class via JavaScript, following validation with JavaScript within a JSP file

I am struggling with posting data obtained from an html form created in a jsp file using javascript and sending it to a java class after validating the form data. I was exploring alternatives to Ajax since I am not well-versed with those tools, but if you ...

determine a distinctive identification for an HTML ID

<div id=Pear1> <div id=Circle></div> </div> <div id=Pear2> <div id=Circle></div> </div> <div id=Pear3> <div id=Circle></div> </div> <div id=Pear4> <div id=Circ ...

The comparison between 'typeof error' and 'undefined' reveals that the data is

I am encountering an issue with a piece of code that is generating an error, and I have been unable to find a suitable solution in JavaScript. var data = new FormData(); $.each(files, function(key, obj) { data.append(o ...

What is the best way to assign a distinct identifier to every hyperlink within a specific class using jquery?

For a project I'm working on, I need to create a list of links and a save button. My goal is to hide the save button if a link has already been saved. To achieve this, I am thinking of assigning a unique ID to each link based on a specific number in t ...

A tutorial on utilizing a bundle in webpack based on certain conditions

My project consists of an app.bundle.js (the main app bundle) and two cordova bundles: iosCordova.bundle.js and androidCordova.bundle.js. Depending on whether the user is logging in on an iOS or Android device, I only script src one of them. All the bundle ...

jQuery Ajax functionality is functional in Internet Explorer, but experiences major issues in Firefox

When running this block of Javascript code, it always returns null in Firefox and Chrome, but it works perfectly fine in Internet Explorer: $.ajax({ url: "http://example.com/webservice.asmx/myfunction", data: "{ 'q': 'hotels&apos ...

Guide on integrating jQuery-Plugin into WordPress

I've been attempting to integrate the jquery.contenthover.js Plugin into my WordPress site, but I'm encountering some difficulties. Initially, I removed the jQuery version loaded by WordPress because the plugin requires a higher version. I then ...

Issues are arising with Bootstrap's functionality within the Vite React app

I am new to working with react and vite. I am currently developing a vite react application that requires the use of bootstrap. I followed the instructions provided on the official Bootstrap website here. However, not all Bootstrap functionalities are work ...

The Jquery click function seems to be malfunctioning when triggered using a laptop mouse tracking pad, but functions properly otherwise

I am facing an issue on my webpage where I use a typing input to search for certain IDs using the typeahead library from jQuery. Oddly, when I click on the search results that are displayed in a list by an external mouse, everything works perfectly fine. H ...

CSS code that causes the animated photo banner to reset instead of continuously looping back to the first

I followed a tutorial and created this banner using HTML and CSS. However, I encountered an issue where instead of the banner continuing in loops, it keeps resetting. Since we haven't covered JavaScript yet in university, I'm looking for help to ...

Form Validation using AJAX, Jquery, and PHP

Struggling with the jQuery code below. It is intended to validate form input upon submission. The password seems to be set correctly, but on the first submit, err is true. When submitting a second time (with an unchanged password), err is properly set to f ...