Commit 2123aa7b by Yvon Kerdoncuff

in order and product apps, remove accent before performing datatable search

parent 70860307
Pipeline #4184 failed with stage
in 0 seconds
...@@ -1918,9 +1918,19 @@ function display_products(params) { ...@@ -1918,9 +1918,19 @@ function display_products(params) {
cell.addClass('product_ref_cell'); cell.addClass('product_ref_cell');
} }
} }
} },
dom: 'lrtip', // Remove the search input from that table
});
/* In order to remove the accents in the input, we could attach a keyup event to the default
* search field generated by datatables, but then two search events would be triggered on keyup :
* the default datatable event, and ours.
* To fix this problem we create our own input search so that only our event fires.
*/
$(document).on('keyup', '#custom_products_table_filter input[type="search"]', function() {
products_table
.search(jQuery.fn.DataTable.ext.type.search.string(this.value))
.draw();
}); });
products_table.search('');
$('.main').show(); $('.main').show();
$('#main_content_footer').show(); $('#main_content_footer').show();
$('#do_inventory').show(); $('#do_inventory').show();
......
...@@ -59,7 +59,18 @@ function init(products) { ...@@ -59,7 +59,18 @@ function init(products) {
deferRender: true, deferRender: true,
processing: true, processing: true,
searching: true, searching: true,
language: {url: '/static/js/datatables/french.json'} language: {url: '/static/js/datatables/french.json'},
dom: 'lrtip', // Remove the search input from that table
});
/* In order to remove the accents in the input, we could attach a keyup event to the default
* search field generated by datatables, but then two search events would be triggered on keyup :
* the default datatable event, and ours.
* To fix this problem we create our own input search so that only our event fires.
*/
$(document).on('keyup', '#custom_products_table_filter input[type="search"]', function() {
products_table
.search(jQuery.fn.DataTable.ext.type.search.string(this.value))
.draw();
}); });
// Listener on 'Update product stock' button // Listener on 'Update product stock' button
......
<div id="custom_products_table_wrapper" class="dataTables_wrapper no-footer">
<div id="custom_products_table_filter" class="dataTables_filter">
<label for="custom_product_search_input">Recherche :
<input type="search" id="custom_product_search_input" class="form-control" placeholder="" aria-controls="products_table"/>
</label>
</div>
</div>
\ No newline at end of file
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
<div class="main" style="display:none;"> <div class="main" style="display:none;">
<div class="table_area"> <div class="table_area">
{% include "common/custom_search_input_replacing_datatable_default.html" %}
<table id="products_table" class="display" cellspacing="0" width="100%"></table> <table id="products_table" class="display" cellspacing="0" width="100%"></table>
</div> </div>
</div> </div>
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
</div> </div>
<div class="main"> <div class="main">
<table id="products_table" class="display" cellspacing="0" ></table> {% include "common/custom_search_input_replacing_datatable_default.html" %}
<table id="products_table" class="display" cellspacing="0" ></table>
</div> </div>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script> <script src="{% static "js/all_common.js" %}?v=1651853225"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment