par
R00T » 22 mars 2022, 01:09
je vous remercie de votre repense j'ai compris un peux le mode de fonctionnement mai j'ai pas pu faire ce que je voulais vu que je connais pas grade chose en ajax
voila les appel ajax
var product_table;
var columns = [];
//var filter_by_category_list = [];
obj = {};
obj['data'] = 'select_product';
obj['className'] = 'select_product';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'image';
obj['className'] = 'image';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'name';
obj['className'] = 'name';
obj['orderable'] = true;
columns.push(obj);
obj = {};
obj['data'] = 'price';
obj['className'] = 'price';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'stock';
obj['className'] = 'stock';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'categories';
obj['className'] = 'categories';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'date';
obj['className'] = 'date';
obj['orderable'] = true;
columns.push(obj);
obj = {};
obj['data'] = 'status';
obj['className'] = 'status';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'actions';
obj['className'] = 'actions';
obj['orderable'] = false;
columns.push(obj);
product_table = $('#product_table').DataTable({
'ordering': true,
'searching': false,
"processing": true,
"serverSide": true,
"lengthChange": false,
"responsive": true,
"language": {
"emptyTable": "Aucun produit trouvé !",
"processing": "En cours...",
"info": "Affichage de _START_ à _END_ sur _TOTAL_ produits",
"infoEmpty": "Affichage 0 à 0 de 0 produits",
"lengthMenu": "Nombre de lignes _MENU_",
"zeroRecords": "Aucun produit correspondant trouvé",
"search": "Recherche :",
"paginate": {
"next": "Suivant",
"previous": "Précédent"
},
},
"drawCallback": function(settings){
//$( "#product_cat" ).detach();
$('thead tr th.select_product').removeClass('sorting_asc');
$('thead tr th.image').removeClass('sorting_asc');
// var product_cat_sel = $('<select id="product_cat" class="wcmp-filter-dtdd wcmp_filter_product_cat form-control">').appendTo("#product_table_length");
// product_cat_sel.append($("<option>").attr('value', '').text('Sélectionnez une catégorie'));
// $(filter_by_category_list).each(function () {
// product_cat_sel.append($("<option>").attr('value', this.key).text(this.label));
// });
// if(settings.oAjaxData.product_cat){
// product_cat_sel.val(settings.oAjaxData.product_cat);
// }
if(settings.json.notices.length > 0 ){
$('.wcmp-wrapper .notice-wrapper').html('');
$.each(settings.json.notices, function( index, notice ) {
if(notice.type == 'success'){
$('.wcmp-wrapper .notice-wrapper').append('<div class="woocommerce-message" role="alert">'+notice.message+'</div>');
}else{
$('.wcmp-wrapper .notice-wrapper').append('<div class="woocommerce-error" role="alert">'+notice.message+'</div>');
}
});
}
},
"ajax": {
url: '/wp-admin/admin-ajax.php?action=wcmp_vendor_product_list',
type: "post",
data: function (data) {
data.products_filter_action = $('form#wcmp_product_list_form').serialize();
data.post_status = "all";
data.product_cat = $('#product_cat').val();
data.bulk_action = $('#product_bulk_actions').val();
data.search_keyword = $('#pro_search_key').val();
},
error: function(xhr, status, error) {
$("#product_table tbody").append('<tr class="odd"><td valign="top" colspan="9" class="dataTables_empty" style="text-align:center;">'+error+' - <a href="javascript:window.location.reload();">Recharger</a></td></tr>');
$("#product_table_processing").css("display","none");
}
},
"columns": columns,
"createdRow": function (row, data, index) {
$(row).addClass('vendor-product');
}
});
new $.fn.dataTable.FixedHeader( product_table );
// $(document).on('change', '#product_cat', function () {
// product_table.ajax.reload();
// });
$(document).on('click', '#pro_search_btn', function () {
product_table.ajax.reload();
});
$(document).on('click', '#product_list_do_filter', function (e) {
product_table.ajax.reload();
});
$(document).on('click', '#product_list_do_bulk_action', function (e) {
product_table.ajax.reload();
});
});</script>
mon but est de supprimer le tableaux et faire un affichage classique du genre
nom du produit 1
stock
prix
date
action
nom du produit 2
stock
prix
date
action
...
pouvez vous SVP me dire comment je peux faire sa ?
je vous remercie de votre repense j'ai compris un peux le mode de fonctionnement mai j'ai pas pu faire ce que je voulais vu que je connais pas grade chose en ajax
voila les appel ajax
[PHP]var product_table;
var columns = [];
//var filter_by_category_list = [];
obj = {};
obj['data'] = 'select_product';
obj['className'] = 'select_product';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'image';
obj['className'] = 'image';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'name';
obj['className'] = 'name';
obj['orderable'] = true;
columns.push(obj);
obj = {};
obj['data'] = 'price';
obj['className'] = 'price';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'stock';
obj['className'] = 'stock';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'categories';
obj['className'] = 'categories';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'date';
obj['className'] = 'date';
obj['orderable'] = true;
columns.push(obj);
obj = {};
obj['data'] = 'status';
obj['className'] = 'status';
obj['orderable'] = false;
columns.push(obj);
obj = {};
obj['data'] = 'actions';
obj['className'] = 'actions';
obj['orderable'] = false;
columns.push(obj);
product_table = $('#product_table').DataTable({
'ordering': true,
'searching': false,
"processing": true,
"serverSide": true,
"lengthChange": false,
"responsive": true,
"language": {
"emptyTable": "Aucun produit trouvé !",
"processing": "En cours...",
"info": "Affichage de _START_ à _END_ sur _TOTAL_ produits",
"infoEmpty": "Affichage 0 à 0 de 0 produits",
"lengthMenu": "Nombre de lignes _MENU_",
"zeroRecords": "Aucun produit correspondant trouvé",
"search": "Recherche :",
"paginate": {
"next": "Suivant",
"previous": "Précédent"
},
},
"drawCallback": function(settings){
//$( "#product_cat" ).detach();
$('thead tr th.select_product').removeClass('sorting_asc');
$('thead tr th.image').removeClass('sorting_asc');
// var product_cat_sel = $('<select id="product_cat" class="wcmp-filter-dtdd wcmp_filter_product_cat form-control">').appendTo("#product_table_length");
// product_cat_sel.append($("<option>").attr('value', '').text('Sélectionnez une catégorie'));
// $(filter_by_category_list).each(function () {
// product_cat_sel.append($("<option>").attr('value', this.key).text(this.label));
// });
// if(settings.oAjaxData.product_cat){
// product_cat_sel.val(settings.oAjaxData.product_cat);
// }
if(settings.json.notices.length > 0 ){
$('.wcmp-wrapper .notice-wrapper').html('');
$.each(settings.json.notices, function( index, notice ) {
if(notice.type == 'success'){
$('.wcmp-wrapper .notice-wrapper').append('<div class="woocommerce-message" role="alert">'+notice.message+'</div>');
}else{
$('.wcmp-wrapper .notice-wrapper').append('<div class="woocommerce-error" role="alert">'+notice.message+'</div>');
}
});
}
},
"ajax": {
url: '/wp-admin/admin-ajax.php?action=wcmp_vendor_product_list',
type: "post",
data: function (data) {
data.products_filter_action = $('form#wcmp_product_list_form').serialize();
data.post_status = "all";
data.product_cat = $('#product_cat').val();
data.bulk_action = $('#product_bulk_actions').val();
data.search_keyword = $('#pro_search_key').val();
},
error: function(xhr, status, error) {
$("#product_table tbody").append('<tr class="odd"><td valign="top" colspan="9" class="dataTables_empty" style="text-align:center;">'+error+' - <a href="javascript:window.location.reload();">Recharger</a></td></tr>');
$("#product_table_processing").css("display","none");
}
},
"columns": columns,
"createdRow": function (row, data, index) {
$(row).addClass('vendor-product');
}
});
new $.fn.dataTable.FixedHeader( product_table );
// $(document).on('change', '#product_cat', function () {
// product_table.ajax.reload();
// });
$(document).on('click', '#pro_search_btn', function () {
product_table.ajax.reload();
});
$(document).on('click', '#product_list_do_filter', function (e) {
product_table.ajax.reload();
});
$(document).on('click', '#product_list_do_bulk_action', function (e) {
product_table.ajax.reload();
});
});</script>[/PHP]
mon but est de supprimer le tableaux et faire un affichage classique du genre
nom du produit 1
stock
prix
date
action
nom du produit 2
stock
prix
date
action
...
pouvez vous SVP me dire comment je peux faire sa ?