Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from index to col name #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ajax_datatable/static/ajax_datatable/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ window.AjaxDatatableViewUtils = (function() {
var index = target.data('index');
var value = target.val();

var column = table.api().column(index);
var column = table.api().column(index + ":name");
var old_value = column.search();
console.log('Request to search value %o in column %o (current value: %o)', value, index, old_value);
if (value != old_value) {
Expand Down Expand Up @@ -136,7 +136,7 @@ window.AjaxDatatableViewUtils = (function() {
if ('choices' in item && item.choices) {

// See: https://www.datatables.net/examples/api/multi_filter_select.html
var select = $('<select data-index="' + index.toString() + '"><option value=""></option></select>');
var select = $('<select data-index="' + item.name.toString() + '"><option value=""></option></select>');
$(item.choices).each(function(index, choice) {
var option = $("<option>").attr('value', choice[0]).text(choice[1]);
if (choice[0] === item.initialSearchValue) {
Expand All @@ -149,7 +149,7 @@ window.AjaxDatatableViewUtils = (function() {
else {
var input = $('<input>')
.attr('type', 'text')
.attr('data-index', index)
.attr('data-index', item.name)
.attr('placeholder', '...')
.attr('value', item.initialSearchValue ? item.initialSearchValue : '')
html = $('<div>').append(input).html();
Expand Down