The custom filters are incompatible with ajax data. The Json generated by django-datatables-views does not support custom filters

I am using the djando-datatables-view tool to generate JSON data for the datatables jQuery plugin. The data is being displayed correctly and sorting is working as expected. I have added an additional <input> field to search data only in the second column of my table. However, when I input text into the 'search-input-text' field, I can see the processing modal but the table rows are not being filtered at all. I have been unable to find any information on how to create custom filters using ajax.data. As a newbie, I have spent the last three days trying to find a solution. Please help me:) Here is my code:

$(document).ready(function() {
  var dataTable = $('#datatabletest').DataTable({
    "processing": true,
    "serverSide": true,
    "ajax":{
      "url" :"http://...tojson",
      "type" : "get",
      error: function(){  
        $(".datatabletest-error").html("");
        $("#datatabletest").append('<tbody class="datatabletest-error"><tr><th colspan="3">ERROR</th></tr></tbody>');
        $("#datatabletest_processing").css("display","none");
      }
    }           
  });
  $("#datatabletest_filter").css("display","none");
  $('.search-input-text').on( 'keyup', function () {
    var i = $(this).attr('data-column');
    var v = $(this).val();
    dataTable.columns(i).search(v).draw();
  });
});

Answer №1

Take a look at this response here: DataTables: Custom Response Handling

Although it discusses Tastypie interaction, the idea of modifying search criteria by passing a function to datatables AJAX option can be applied to any API provider.

If you add a console.log(data) to your ajax function, you'll be able to see exactly what is being submitted.

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

Having issues with templateURL not working in AngularJS routeProvider

I've been experimenting with ngRoute and I'm facing an issue with templateURL not working as expected. The functionality works perfectly except for when I attempt to use templateURL. Here are the 4 files involved: test.html <p>{{test}}&l ...

The onEnter and onExit functions within a React Native Component using react-native-router-flux

Within my app's router definitions, I have successfully utilized the onEnter/onExit method at the root level: <Scene key="arena" hideNavBar={true} onEnter={() => console.log("Entered")} component={ArenaPage} /> Is there a way to achieve th ...

Group of objects containing an inner group of objects

Here is an array of objects that I am working with: let prova: ActiveRoute[] = [ { path: '/Root', method: 'GET', children: [ { path: '/Son', method: 'GET', chi ...

When clicking on an item in the wishlist, only the text for that specific item should change,

Hi all, I'm in need of some assistance. I have successfully created a wishlist toggle where clicking on the heart icon changes it from an outline to solid. However, my issue lies in changing the tooltip text from "add to wish list" to "added to wish l ...

Executing a 'WebMethod' using jQuery in ASP.NET WebForms

I've placed a breakpoint inside the WebMethod below, but it never seems to get hit. cs: [WebMethod] public static string search() { return "worked"; } aspx: function search() { $.ajax({ type: "POST", url: "ProcessAudit/re ...

Unable to transmit a variety of text or variables via email through PHP

Can someone assist me in figuring out how to send more content in an email? I have been attempting to include additional information in the email, but haven't been successful. I am using ajax to call and send the email, however, only basic emails seem ...

During real-time data updates in ZingChart's timeseries feature, there seems to be a problem with the xValue when using

I'm currently working on building a real-time timeseries graph using ZingChart. What I aim for is an accumulative graph where all points accumulate as new data appends. To achieve this, I use "appendseriesvalues" in each AJAX poll to append the data a ...

Utilizing vanilla JavaScript or ES6 to extract data from a JSON file

I am currently working on an HTML project where I need to extract data from a JSON file that cannot be modified. I am looking to accomplish this using pure JavaScript or ES6, but I am struggling to make it work. Specifically, I am trying to retrieve a link ...

Pull the Bootstrap radio value from hyperlink buttons

Is anyone else having trouble retrieving values of radio buttons using jQuery? Here are the radio buttons in question: <div class="input-group"> <div id="radioBtn" class="btn-group"> <a class="btn btn-warning radio-selector btn ...

Ways to transfer GET form information to Express?

I am working on a form that needs to pass parameters correctly <form action="./search" method="GET"> <div class="form-group text-center"> <input type="text" name="keyword" placeholder="Search Term" /> ...

The list in Jquery UI Autocomplete is not updating correctly

Currently, I am using jQuery UI Autocomplete in conjunction with WebSockets to fetch and display a list of options. Each time a keystroke is detected on the input field (.keyup()), a call is made to retrieve the list. However, I have encountered an issue w ...

Vuetify's autofocus feature is limited to functioning only when the modal is first opened

When attempting to utilize Vuetify's v-text-field with the autofocus attribute, I am facing an issue where it only works the first time. Once I close the dialog, the autofocus functionality no longer works. This is the code snippet I am trying to imp ...

Error encountered during TypeScript execution - 'undefined'

I'm encountering errors while trying to instantiate a basic class named Point using HTML and TypeScript. Whenever I click on the hyperlink, I receive the following error messages within each try/catch block: Errors: Cannot read property 'Empty ...

What is the best way to showcase specific rows with Vue.js?

After fetching data from a specific URL, I am looking to display only the 2nd and 4th rows. { "status": "ok", "source": "n", "sortBy": "top", "articles": [ { "author": "Bradford ", "title": "friends.", ...

utilizing the default placeholder image for videos and audios within the tags

In my web application, users can share music and videos that will be stored on a server used by the application. Some audio/video files come with posters or thumbnails attached to them. I want to display these posters along with the audio or video using HT ...

Sending data from form inputs to an array using the GET method

I'm trying to pass an array from form inputs (checkboxes) using the get method. In my AJAX call, I have the following code: var subcat_checked = new Array(); $.each($("input[name='subcategories']:checked"), function() { subcat_checked.p ...

Python - Combining techniques: giving back `self` versus creating a fresh replicated entity

In a project I'm currently working on, certain restrictions forced me to create a custom QuerySet class as a replacement for Django's. One of the main features of QuerySet objects is that their methods can be chained (for example QuerySet().filte ...

The magic of handling buffers in NodeJS with JavaScript!

In my project, I am working on developing a client-server application. The goal is for the client to send a list of filenames to the server in an array format like this: let files = ["Cat.jpeg", "Moon.gif"]. To accomplish this task, I plan to utilize Buffe ...

Troubleshooting template routing issues in Angular UI

Below is the content of my router.js: angular.module('app.routes', []).config(function($stateProvider, $urlRouterProvider) { $stateProvider.state('tabsController.dashboard', { url : '/page2', views : { ' ...

Step-by-step guide for importing a octet-stream 3d model into Three.js

I uploaded a model in .glb format to S3 services and obtained the URL https://test-image-prevaa-123.s3.amazonaws.com/test/1626336255367.octet-stream. How can I load this model into three.js? When I tried loading it from my code, the model failed to display ...