jquery-barcode.js

jquery-barcode.js

BhavinBhattBhavinBhatt Posts: 27Questions: 9Answers: 0

I have put barcode for a column using jquery-barcode.js plugin.
It shows barcode well inside datatable .
Now I want to print with barcode using print button.
I've used stripHtml:false but its not showing barcode in print window and not printing also.
Please help.

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • BhavinBhattBhavinBhatt Posts: 27Questions: 9Answers: 0
    edited May 2023
                                                ,'rowCallback':function(nRow,nData,tRows)
                                                {
                                                    var intVal = function (i) {
                                                        return typeof i === 'string' ?
                                                            i.replace(/[\$,]/g, '') * 1 :
                                                            typeof i === 'number' ?
                                                            i : 0;
                                                    }
                                                    //$('td:eq(4)').html(data[4].toString());
                                                    //$(nRow).find('td:eq(4)').val(nData[3].toString());
                                                    $(nRow).find('td:eq(4)').html('<div id="dvBc"></div>');
                                                    //jquery-barcode.js
                                                    $(nRow).find('div:eq(0)').barcode(nData[3].toString(), "code128",{output:"css"});
                                                    //jsbarcode -1
                                                    //$(nRow).find('svg:eq(0)').JsBarcode(nData[3].toString(), {
                                                    //    //format: "pharmacode",
                                                    //    lineColor: "#0aa",
                                                    //    width: 2,
                                                    //    height: 25,
                                                    //    displayValue: true
                                                    //});
                                                    //$(nRow).find('svg:eq(0)').JsBarcode(nData[3].toString());
                                                }
                                                , dom: 'Bfrtip',
                                                buttons:
                                                [
                                                    //'copyHtml5',
                                                    //'excelHtml5',
                                                    //'csvHtml5',
                                                    //'pdfHtml5',
    
                                                    {
                                                        extend: 'copyHtml5',
                                                        messageTop: customMessage
                                                    },
    
                                                    {
                                                        extend: 'excelHtml5',
                                                        messageTop:  customMessage
                                                    }
                                                    ,
                                                    {
                                                        extend: 'csvHtml5',
                                                        messageTop:  customMessage
                                                    }
                                                    ,
                                                    {
                                                        extend: 'pdfHtml5',
                                                        messageTop:  customMessage
                                                    }
                                                    ,
                                                    {
                                                        extend: 'print'
                                                        ,messageTop: customMessage
                                                        , exportOptions: { stripHtml: false, columns: [4] }
                                                        
                                                    }
    
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    As Colin said, we'd need a running test case, but I suspect that it won't be possible with how the print view currently works. At least not without tweaking. The print view is constructed from the data in the table, and does not run rowCallback or anything else on it. Your bar code script is probably displaying the barcode using a canvas or something like that, so it would need to be run on the print view using the customize callback as well.

    Allan

  • BhavinBhattBhavinBhatt Posts: 27Questions: 9Answers: 0

    Thanks Colin, Allan,
    Can you please provide sample code for it.
    Or I use same barcode logic in customize function??

    Br,
    Bhavin.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Link to your page showing the issue or create an example in JSFiddle that we can look at, please.

    If you need us to build an example from scratch, we offer support packages that would cover that.

    Allan

Sign In or Register to comment.