Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:37:10+00:00 2026-06-05T12:37:10+00:00

I have the data in the following format: (Dummy Entries)(id=posGridView) As I process the

  • 0

I have the data in the following format:

(Dummy Entries)(id=posGridView)

enter image description here

As I process the sale, a small receipt print automatically with selected columns, not all the columns.

Because all data is available in this grid view, How can I print it dynamically with any format with jquery?

Edited

Actually I want to print in this format dynamically from the above grid view

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:37:13+00:00Added an answer on June 5, 2026 at 12:37 pm

    Printing

    There’s no need for jQuery for printing a page, you just need the JavaScript function: window.print();.

    If you need to print an specific content, you can hide the rest (and format the printed area) by CSS:

    <style media="screen">
      .noPrint{ display: block; }
      .yesPrint{ display: block !important; }
    </style> 
    <style media="print">
      .noPrint{ display: none; }
      .yesPrint{ display: block !important; }
    </style>
    

    As you can see, by setting the media attribute of your style tag, you can set up styles for both the normal view (screen) and the printing view (print). Full article is here.

    Dynamism

    You can add certain dynamism to the process, but keep in mind that it can be dinamically for the user, but in your code you’ll have to find and event to attach the printing. That event could be a click in an anchor:

    <a href='javascript:window.print();'>Print</a>

    It could be the onload event of your page:

    window.onload = function () {
        window.print();
    }
    

    Or any other event that you might need to be aware (notice that now I’m using jQuery):

    var doPrintPage;
    
    function printPage(){
        window.print();
    }
    
    $(document).ready(function(){
        $('input').blur(function(){
            //3sec after the user leaves the input, printPage will fire
            doPrintPage = setTimeout('printPage();', 3000);
        });
        $('input').focus(function(){
            //But if another input gains focus printPage won't fire
            clearTimeout(doPrintPage);
        });
    });
    

    The code above is pretty straight-forward: after three seconds of the user leaving an input, printPage will fire. If an input get the focus in those three seconds, printPage won’t be called. I don’t really think this precise code is what you need, but I’ll make the point how to emulate dynamism. Here can see the setTimeout and clearTimeout definitions.

    EDIT: I hardly suggest you to hide your unwanted-to-print html through CSS as explained above and call window.print. Anyway, here I’m adding some code for doing it through a new page.

    Printing from a brand new page

    If you want to print from a totally different page that the one you’re showing, you can ask for that page, manage the html in your server-side and then tell the page to print as soon as get loaded. There’s at least two ways to do this. Let see them step by step:

    A) The first choice is to send your GridView to your new page and print it from there. The problem is that you can’t easily open a new page to do this, so you’ll have to browse from your page to a new one showing your html-to-print.

    A1) For this, you need to surround your GridView with a form:

    <form runat="server">
    <asp:GridView id="gridView" />
    <asp:Button id="btnPrint" Text="Print" runat="server" OnClick="btnPrint_Click" />
    </form>
    

    A2) Then from *btnPrint_Click* you’ll call your “printPage.aspx”. Remember that if you changed your GridView with JS/jQuery, those changes could be not available (since it’s likely that .NET reads a hidden state variable rather than your GridView).

    B) The second way to do it is through JavaScript. But remember that with this choice you’ll have a hard time if you want to edit your table in your new page (because you won’t be receiving a GridView, you’ll receiving html). The good thing is that you can easily open a new page:

    B1) Off course, you’ll need a form (notice its target and action), something like:

    <form id="myPageForm" name="myPageForm" target="_blank" action="printPage.aspx">
        <input type="hidden" name="htmlToPrint" id="htmlToPrint" />
        <input type="button" value="submit">Print</button>
    </form>
    

    B2) Then you’ll have to pass your data to that anchor. Before submitting the form, set the input with your table data:

    $(document).ready(function(){
        $('#myPageForm').submit(function(){
            //Filling the hidden input
            var htmlToPrint = $(".posGridView").html(); //I'm using a class and not an ID 'cause .NET will change your GridView's ID when rendering you page
            $("#htmlToPrint").value(htmlToPrint);
            return true;
        });
    });
    

    Once you have the data in your server side (printPage.asx), you can easily create your HTML-to-print and call window.print() on that page onload, as described above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data in the following format: 4:How do you do? 10:Happy birthday 1:Purple
I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort
I have a text file containing the data in following format 12345 Abdt3 hy45d
I have a string of data with the following format: xpos-ypos-zoom (i.e. 8743-12083-15) that
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234
I have a file which contains lines of data in the following format: a11
I have a txt file which contains data in the following format: X1 Y1
I have a log of following format << [ABC] some other data some other
i have data in following format: colA colB 2010 10 2010 20 2010 30
I have soccer results data in the following format (thousands of observations): Div date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.