Click here to Skip to main content
15,913,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone,

I have 1 problem need your idea. I have 1 report that have 3 parameters ( From Month, To Month and Year). My report will display between From Month and To Month of year only. ex: From Month=Apr and To Month=June==> My report will display Apr May and Jun.
I use Javascript with Jquerty to hide like this:
JavaScript
// For Hide From Jan to From Month
$.each($("#product>tbody>tr:gt(0)"), function (i, v) {
      $.each($(v).find("td").slice(1, start), function (i1, v1) {
          $(v1).css("display", "none");
      });
  });
// For Hide To Month=> Dec
  $.each($("#product>tbody>tr:gt(0)"), function (i, v) {
      $.each($(v).find("td").slice(end, 37), function (i1, v1) {
          $(v1).css("display", "none");
      });
  });

After i used this code, my report display correctly. it means that it displays between From Month and To Month.

But when i export to excel, It still display 12 months. It means that in excel is not the same with report form. like example above: The report displays Apr May Jun ( Correct) but In Excel, it displays 12 months (start from Jan to Dec) ( Incorrect). the correct in excel should be displayed Apr May Jun ( the same col with report).

So Does anybody know how i can remove col of html's table using javascript or jquery to remove unused month?

Note: in my sql, it already has 12 months

Thanks
Posted

1 solution

display: none will only hide the data from the UI. it is not removing.

If you are creating your table dynamically from jQurey, Instead of hiding the row can you remove it dynamically. like
JavaScript
$(v1).remove();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900